@celljs/ta-relay 4.12.0 → 4.13.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/README.en.md +26 -1
- package/README.md +26 -1
- package/esm/common/index.d.ts +3 -0
- package/esm/common/index.js +3 -0
- package/esm/common/relay-friends.d.ts +154 -0
- package/esm/common/relay-friends.js +482 -0
- package/esm/common/relay-hub-util.d.ts +9 -0
- package/esm/common/relay-hub-util.js +19 -2
- package/esm/common/relay-hubs-connection.d.ts +17 -5
- package/esm/common/relay-hubs-connection.js +40 -37
- package/esm/common/relay-hubs-protocol.d.ts +51 -7
- package/esm/common/relay-hubs.d.ts +67 -5
- package/esm/common/relay-hubs.js +305 -16
- package/esm/common/relay-identity.d.ts +2 -0
- package/esm/common/relay-info.d.ts +44 -0
- package/esm/common/relay-info.js +94 -0
- package/esm/common/relay-protocol.d.ts +7 -3
- package/esm/common/relay-protocol.js +7 -3
- package/esm/common/relay-room-chat.d.ts +6 -1
- package/esm/common/relay-room-chat.js +1 -0
- package/esm/common/relay-spot.d.ts +122 -0
- package/esm/common/relay-spot.js +179 -0
- package/esm/guest/guest-i18n.d.ts +2 -0
- package/esm/guest/guest-i18n.js +4 -0
- package/esm/guest/guest.js +9 -1
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/node/relay-file-storage.d.ts +32 -0
- package/esm/node/relay-file-storage.js +101 -0
- package/esm/node/relay-host.d.ts +63 -28
- package/esm/node/relay-host.js +145 -52
- package/esm/node/relay-server.d.ts +37 -3
- package/esm/node/relay-server.js +193 -37
- package/esm/node/relay-store.d.ts +34 -6
- package/esm/node/relay-store.js +54 -22
- package/esm/node/relays-file.d.ts +139 -0
- package/esm/node/relays-file.js +373 -0
- package/lib/common/index.d.ts +3 -0
- package/lib/common/index.js +3 -0
- package/lib/common/relay-friends.d.ts +155 -0
- package/lib/common/relay-friends.js +486 -0
- package/lib/common/relay-hub-util.d.ts +9 -0
- package/lib/common/relay-hub-util.js +19 -2
- package/lib/common/relay-hubs-connection.d.ts +17 -5
- package/lib/common/relay-hubs-connection.js +40 -37
- package/lib/common/relay-hubs-protocol.d.ts +51 -7
- package/lib/common/relay-hubs.d.ts +67 -5
- package/lib/common/relay-hubs.js +306 -17
- package/lib/common/relay-identity.d.ts +2 -0
- package/lib/common/relay-info.d.ts +45 -0
- package/lib/common/relay-info.js +97 -0
- package/lib/common/relay-protocol.d.ts +7 -3
- package/lib/common/relay-protocol.js +8 -4
- package/lib/common/relay-room-chat.d.ts +6 -1
- package/lib/common/relay-room-chat.js +1 -0
- package/lib/common/relay-spot.d.ts +123 -0
- package/lib/common/relay-spot.js +183 -0
- package/lib/guest/guest-i18n.d.ts +2 -0
- package/lib/guest/guest-i18n.js +4 -0
- package/lib/guest/guest.js +9 -1
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.js +2 -0
- package/lib/node/relay-file-storage.d.ts +33 -0
- package/lib/node/relay-file-storage.js +105 -0
- package/lib/node/relay-host.d.ts +63 -28
- package/lib/node/relay-host.js +146 -53
- package/lib/node/relay-server.d.ts +37 -3
- package/lib/node/relay-server.js +193 -37
- package/lib/node/relay-store.d.ts +34 -6
- package/lib/node/relay-store.js +54 -22
- package/lib/node/relays-file.d.ts +140 -0
- package/lib/node/relays-file.js +378 -0
- package/package.json +2 -2
- package/viewer/room.html +10 -10
package/lib/common/relay-hubs.js
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RelayHubs = void 0;
|
|
3
|
+
exports.RelayHubsUtil = exports.RelayHubs = void 0;
|
|
4
|
+
const relay_friends_1 = require("./relay-friends");
|
|
4
5
|
const relay_hub_util_1 = require("./relay-hub-util");
|
|
5
6
|
const relay_hubs_connection_1 = require("./relay-hubs-connection");
|
|
6
7
|
const relay_identity_1 = require("./relay-identity");
|
|
8
|
+
const relay_protocol_1 = require("./relay-protocol");
|
|
7
9
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
8
10
|
/**
|
|
9
11
|
* The rooms of this Ta (docs/design/ta-link.md 3): its identity and friends, the rooms it made or asked to join,
|
|
10
12
|
* and a connection to the hub of each while it runs, through which it sends, sets the shared state and hears
|
|
11
|
-
* the others; every message signed by its member and sealed with the key of the room.
|
|
13
|
+
* the others; every message signed by its member and sealed with the key of the room. The friends are a room of
|
|
14
|
+
* their own (RelayFriends).
|
|
12
15
|
*/
|
|
13
16
|
class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.book = new relay_friends_1.RelayFriends({
|
|
20
|
+
identity: () => this.identity(),
|
|
21
|
+
list: () => this.list(),
|
|
22
|
+
ownerOf: room => { var _a; return (_a = this.live.get(room)) === null || _a === void 0 ? void 0 : _a.record.owner.id; },
|
|
23
|
+
memberOf: (room, member) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const found = (_b = (_a = this.live.get(room)) === null || _a === void 0 ? void 0 : _a.roster) === null || _b === void 0 ? void 0 : _b.members.find(each => each.member === member);
|
|
26
|
+
return found && relay_identity_1.RelayIdentityUtil.publicOf(found);
|
|
27
|
+
},
|
|
28
|
+
asksOf: room => { var _a; var _b; return [...((_b = (_a = this.live.get(room)) === null || _a === void 0 ? void 0 : _a.asks.values()) !== null && _b !== void 0 ? _b : [])].map(ask => ask.body); },
|
|
29
|
+
create: input => this.create(input),
|
|
30
|
+
invite: (room, options) => this.invite(room, options),
|
|
31
|
+
join: link => this.join(link),
|
|
32
|
+
answer: (room, ask, accept) => this.answer(room, ask, accept),
|
|
33
|
+
remove: (room, member) => this.remove(room, member),
|
|
34
|
+
leave: room => this.leave(room),
|
|
35
|
+
getState: (room, prefix) => this.getState(room, prefix),
|
|
36
|
+
setState: (room, key, value) => this.setState(room, key, value),
|
|
37
|
+
offer: (room, member, link) => this.sendBody(this.member(room), { friend: link }, member),
|
|
38
|
+
}, this.options.store, event => this.notify(event));
|
|
39
|
+
}
|
|
14
40
|
/** Connects to the rooms of rooms.json, and keeps connected. */
|
|
15
41
|
start() {
|
|
16
42
|
this.stopped = false;
|
|
43
|
+
if (!this.options.guest) {
|
|
44
|
+
const migrated = relay_friends_1.RelayFriendsUtil.migrate(this.readRooms(), this.options.store.read('friends'));
|
|
45
|
+
if (migrated) {
|
|
46
|
+
this.options.store.write('rooms', { rooms: migrated.records });
|
|
47
|
+
this.options.store.write('friends', migrated.book);
|
|
48
|
+
}
|
|
49
|
+
this.book.start();
|
|
50
|
+
}
|
|
17
51
|
for (const record of this.readRooms()) {
|
|
18
52
|
const live = new relay_hubs_connection_1.Live(record);
|
|
19
53
|
this.live.set(record.id, live);
|
|
@@ -24,6 +58,7 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
24
58
|
}
|
|
25
59
|
stop() {
|
|
26
60
|
this.stopped = true;
|
|
61
|
+
this.book.stop();
|
|
27
62
|
for (const live of this.live.values()) {
|
|
28
63
|
this.disconnect(live);
|
|
29
64
|
}
|
|
@@ -43,7 +78,8 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
43
78
|
this.options.store.write('identity', identity);
|
|
44
79
|
this.own = identity;
|
|
45
80
|
for (const live of this.live.values()) {
|
|
46
|
-
|
|
81
|
+
// A room joined with another identity keeps that one's name.
|
|
82
|
+
if (live.record.status !== 'member' || live.record.identity) {
|
|
47
83
|
continue;
|
|
48
84
|
}
|
|
49
85
|
if (live.record.own) {
|
|
@@ -78,10 +114,11 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
78
114
|
const now = Date.now();
|
|
79
115
|
const record = {
|
|
80
116
|
id: relay_hub_util_1.RelayHubUtil.randomId(),
|
|
81
|
-
relay: this.options.relay().replace(/\/+$/, ''),
|
|
117
|
+
relay: this.options.relay(typeof input.use === 'string' && input.use ? input.use : undefined).replace(/\/+$/, ''),
|
|
82
118
|
kind,
|
|
83
119
|
title,
|
|
84
120
|
...(input.view ? { view: String(input.view) } : {}),
|
|
121
|
+
...(input.unlisted === true ? { unlisted: true } : {}),
|
|
85
122
|
member: relay_hub_util_1.RelayHubUtil.randomId(),
|
|
86
123
|
token: relay_hub_util_1.RelayHubUtil.randomKey(),
|
|
87
124
|
key: relay_hub_util_1.RelayHubUtil.randomKey(),
|
|
@@ -111,7 +148,7 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
111
148
|
var _a;
|
|
112
149
|
var _b, _c;
|
|
113
150
|
const live = this.owned(roomId);
|
|
114
|
-
const identity = await this.
|
|
151
|
+
const identity = await this.identityOf(live);
|
|
115
152
|
const linkOf = (invite) => ({
|
|
116
153
|
link: relay_hub_util_1.RelayHubUtil.link({
|
|
117
154
|
relay: live.record.relay,
|
|
@@ -147,10 +184,13 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
147
184
|
if (link.owner === identity.id) {
|
|
148
185
|
throw new Error('This is a room of your own.');
|
|
149
186
|
}
|
|
187
|
+
const friends = relay_friends_1.RelayFriendsUtil.isKind(link.kind);
|
|
150
188
|
const record = {
|
|
151
189
|
id: link.room,
|
|
152
190
|
relay: link.relay,
|
|
153
|
-
|
|
191
|
+
// A room of friends is known as one from its link: its Ta keeps it, whatever the owner says.
|
|
192
|
+
kind: friends ? relay_friends_1.RELAY_FRIENDS_KIND : '',
|
|
193
|
+
...(friends ? { unlisted: true } : {}),
|
|
154
194
|
title: link.title,
|
|
155
195
|
member: relay_hub_util_1.RelayHubUtil.randomId(),
|
|
156
196
|
token: relay_hub_util_1.RelayHubUtil.randomKey(),
|
|
@@ -175,6 +215,9 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
175
215
|
const friends = this.friendIds();
|
|
176
216
|
const requests = [];
|
|
177
217
|
for (const live of this.live.values()) {
|
|
218
|
+
if (this.isFriends(live)) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
178
221
|
for (const ask of live.asks.values()) {
|
|
179
222
|
requests.push(this.requestOf(live, ask.body, friends));
|
|
180
223
|
}
|
|
@@ -183,6 +226,8 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
183
226
|
}
|
|
184
227
|
/** The user's answer to one asking to join: admitted, it gets the key of the room and is in the roster. */
|
|
185
228
|
async answer(roomId, askId, accept) {
|
|
229
|
+
var _a;
|
|
230
|
+
var _b;
|
|
186
231
|
const live = this.owned(roomId);
|
|
187
232
|
const asked = live.asks.get(askId);
|
|
188
233
|
if (!asked) {
|
|
@@ -193,22 +238,23 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
193
238
|
this.request(live, { t: 'refuse', ask: askId });
|
|
194
239
|
}
|
|
195
240
|
else {
|
|
196
|
-
const identity = await this.
|
|
241
|
+
const identity = await this.identityOf(live);
|
|
197
242
|
const body = {
|
|
198
243
|
key: live.record.key,
|
|
199
244
|
kind: live.record.kind,
|
|
200
245
|
title: live.record.title,
|
|
201
246
|
...(live.record.view ? { view: live.record.view } : {}),
|
|
247
|
+
...(live.record.unlisted ? { unlisted: true } : {}),
|
|
202
248
|
};
|
|
203
249
|
const ask = asked.body;
|
|
250
|
+
const most = this.isFriends(live) ? relay_protocol_1.RELAY_FRIENDS_MAX + 1 : relay_protocol_1.RELAY_ROOM_MAX_MEMBERS;
|
|
251
|
+
if (((_b = (_a = live.roster) === null || _a === void 0 ? void 0 : _a.members.length) !== null && _b !== void 0 ? _b : 0) >= most) {
|
|
252
|
+
throw new Error('The room is full.');
|
|
253
|
+
}
|
|
204
254
|
const answer = await relay_hub_util_1.RelayHubUtil.sealAnswer(identity, live.record.id, ask, body, asked.invite);
|
|
205
255
|
const member = { ...relay_identity_1.RelayIdentityUtil.publicOf(ask), member: ask.member, ...(ask.guest ? { guest: true } : {}), at: Date.now() };
|
|
206
256
|
const roster = await this.nextRoster(live, members => [...members.filter(other => other.member !== ask.member), member]);
|
|
207
257
|
this.request(live, { t: 'admit', ask: askId, answer, roster });
|
|
208
|
-
// A guest of a browser is no Ta friend: its keys are of that browser alone.
|
|
209
|
-
if (!member.guest) {
|
|
210
|
-
this.meet(live.record.title, [member]);
|
|
211
|
-
}
|
|
212
258
|
}
|
|
213
259
|
live.asks.delete(askId);
|
|
214
260
|
this.emit({ type: 'rooms' });
|
|
@@ -263,7 +309,7 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
263
309
|
throw new Error('A key of 1 to 200 characters is needed.');
|
|
264
310
|
}
|
|
265
311
|
await this.ready(live);
|
|
266
|
-
const identity = await this.
|
|
312
|
+
const identity = await this.identityOf(live);
|
|
267
313
|
const keys = live.keys;
|
|
268
314
|
const d = await relay_hub_util_1.RelayHubUtil.seal(keys.seal, identity, live.record.member, { key: name, value: value !== null && value !== void 0 ? value : null });
|
|
269
315
|
const k = await relay_hub_util_1.RelayHubUtil.keyId(keys, name);
|
|
@@ -299,14 +345,182 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
299
345
|
}
|
|
300
346
|
return { ok: result.ok, version: result.v };
|
|
301
347
|
}
|
|
348
|
+
/** What makes this Ta who it is in rooms, private keys and all (RelayIdentityBundle): for the user's own computers alone. */
|
|
349
|
+
async exportIdentity() {
|
|
350
|
+
return { identity: await this.identity(), rooms: [...this.live.values()].map(live => live.record), friends: this.book.chosen() };
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Takes on the identity of the user's other computer, with its rooms and friends (a move, or the identity shared by
|
|
354
|
+
* sync). Another identity than this Ta's: each room this Ta is in keeps the identity it joined with
|
|
355
|
+
* (RelayRoomRecord.identity), new rooms are the other's. A room this Ta is in as another member is left as it is.
|
|
356
|
+
*/
|
|
357
|
+
async importIdentity(bundle, options = {}) {
|
|
358
|
+
const incoming = bundle === null || bundle === void 0 ? void 0 : bundle.identity;
|
|
359
|
+
if (!RelayHubsUtil.isPrivate(incoming) || !(await relay_identity_1.RelayIdentityUtil.check(incoming))) {
|
|
360
|
+
throw new Error('Not an identity of Ta.');
|
|
361
|
+
}
|
|
362
|
+
const own = await this.identity();
|
|
363
|
+
const switched = incoming.id !== own.id;
|
|
364
|
+
if (switched) {
|
|
365
|
+
for (const live of this.live.values()) {
|
|
366
|
+
if (!live.record.identity) {
|
|
367
|
+
live.record = { ...live.record, identity: own };
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const shared = options.shared || own.shared;
|
|
372
|
+
const next = { ...(switched ? incoming : own), ...(shared ? { shared: true } : {}) };
|
|
373
|
+
if (!shared) {
|
|
374
|
+
delete next.shared;
|
|
375
|
+
}
|
|
376
|
+
this.own = next;
|
|
377
|
+
this.options.store.write('identity', next);
|
|
378
|
+
let rooms = 0;
|
|
379
|
+
for (const record of Array.isArray(bundle.rooms) ? bundle.rooms : []) {
|
|
380
|
+
if (this.upsert(record)) {
|
|
381
|
+
rooms++;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const friends = this.book.merge(Array.isArray(bundle.friends) ? bundle.friends : []);
|
|
385
|
+
this.save();
|
|
386
|
+
this.emit({ type: 'rooms' });
|
|
387
|
+
return { switched, rooms, friends };
|
|
388
|
+
}
|
|
389
|
+
/** Whether the user's other computers are this Ta too (RelayIdentity.shared). */
|
|
390
|
+
async setShared(shared) {
|
|
391
|
+
const identity = { ...(await this.identity()) };
|
|
392
|
+
if (!!identity.shared === shared) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (shared) {
|
|
396
|
+
identity.shared = true;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
delete identity.shared;
|
|
400
|
+
}
|
|
401
|
+
this.own = identity;
|
|
402
|
+
this.options.store.write('identity', identity);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* A room as the user's other computer has it: added, or merged with this Ta's record of the same membership
|
|
406
|
+
* (RelayHubsUtil.merge), connected or not as its status says. False when nothing changed, or this Ta is in the room
|
|
407
|
+
* as another member.
|
|
408
|
+
*/
|
|
409
|
+
upsert(record) {
|
|
410
|
+
if (!RelayHubsUtil.isRecord(record)) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
const live = this.live.get(record.id);
|
|
414
|
+
if (!live) {
|
|
415
|
+
const added = new relay_hubs_connection_1.Live({ ...record });
|
|
416
|
+
this.live.set(record.id, added);
|
|
417
|
+
if (record.status === 'member' || record.status === 'waiting') {
|
|
418
|
+
this.connect(added);
|
|
419
|
+
}
|
|
420
|
+
this.save();
|
|
421
|
+
this.emit({ type: 'rooms' });
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
if (live.record.member !== record.member) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
const merged = RelayHubsUtil.merge(live.record, record);
|
|
428
|
+
if (JSON.stringify(merged) === JSON.stringify(live.record)) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
const was = live.record.status;
|
|
432
|
+
live.record = merged;
|
|
433
|
+
if (merged.status !== 'member' && merged.status !== 'waiting') {
|
|
434
|
+
this.disconnect(live);
|
|
435
|
+
}
|
|
436
|
+
else if (was !== merged.status || !live.socket) {
|
|
437
|
+
this.disconnect(live);
|
|
438
|
+
this.connect(live);
|
|
439
|
+
}
|
|
440
|
+
this.save();
|
|
441
|
+
this.emit({ type: 'rooms' });
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
/** A room the user's other computer left or forgot: forgotten here, without a word to the relay (that computer said it). */
|
|
445
|
+
forget(roomId, member) {
|
|
446
|
+
const live = this.live.get(roomId);
|
|
447
|
+
if (!live || live.record.member !== member) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
this.disconnect(live);
|
|
451
|
+
this.live.delete(roomId);
|
|
452
|
+
this.save();
|
|
453
|
+
this.emit({ type: 'rooms' });
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
/** Friends of the user's other computer, with those of this Ta. */
|
|
457
|
+
mergeFriends(friends) {
|
|
458
|
+
return this.book.merge(friends);
|
|
459
|
+
}
|
|
460
|
+
/** The friends, with their keys: each in the room of the other (shares to friends are sealed for them). */
|
|
302
461
|
friends() {
|
|
303
|
-
return this.
|
|
462
|
+
return this.book.friends();
|
|
463
|
+
}
|
|
464
|
+
/** The friends and those being added, for the pages. */
|
|
465
|
+
listFriends() {
|
|
466
|
+
return this.book.list();
|
|
467
|
+
}
|
|
468
|
+
/** The room of friends of this Ta, made the first time: other features keep there what they give friends. */
|
|
469
|
+
friendRoom() {
|
|
470
|
+
return this.book.room();
|
|
471
|
+
}
|
|
472
|
+
/** The link (and code) that asks to be the user's friend; with `renew`, a new one, the one before no longer working. */
|
|
473
|
+
friendLink(renew = false) {
|
|
474
|
+
return this.book.link(renew);
|
|
304
475
|
}
|
|
476
|
+
/** Asks the one of a link to be friends, on the user's word. */
|
|
477
|
+
addFriend(link) {
|
|
478
|
+
return this.book.add(link);
|
|
479
|
+
}
|
|
480
|
+
/** Asks a member of a room the user is in to be friends. */
|
|
481
|
+
offerFriend(roomId, member) {
|
|
482
|
+
return this.book.offer(roomId, member);
|
|
483
|
+
}
|
|
484
|
+
friendRequests() {
|
|
485
|
+
return this.book.requests();
|
|
486
|
+
}
|
|
487
|
+
/** The user's answer to one asking to be friends. */
|
|
488
|
+
answerFriend(id, accept) {
|
|
489
|
+
return this.book.answer(id, accept);
|
|
490
|
+
}
|
|
491
|
+
/** No longer friends, on both sides. */
|
|
305
492
|
removeFriend(id) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return
|
|
493
|
+
return this.book.remove(id);
|
|
494
|
+
}
|
|
495
|
+
isFriends(live) {
|
|
496
|
+
return live.record.own && live.record.kind === relay_friends_1.RELAY_FRIENDS_KIND;
|
|
497
|
+
}
|
|
498
|
+
friendIds() {
|
|
499
|
+
return this.book.ids();
|
|
500
|
+
}
|
|
501
|
+
heardAsk(live, ask) {
|
|
502
|
+
if (this.isFriends(live)) {
|
|
503
|
+
this.book.asked(ask);
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
super.heardAsk(live, ask);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
heardMembers(members) {
|
|
510
|
+
if (!this.options.guest) {
|
|
511
|
+
this.book.heard(members);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
offered(live, from, link) {
|
|
515
|
+
if (!this.options.guest) {
|
|
516
|
+
this.book.offered(from, link, live.record.title);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/** What changes the friends: rooms coming and going, members, the links friends leave to join back. */
|
|
520
|
+
after(event) {
|
|
521
|
+
if (!this.options.guest && (event.type === 'rooms' || (event.type === 'state' && event.key.startsWith('back:')))) {
|
|
522
|
+
this.book.changed();
|
|
523
|
+
}
|
|
310
524
|
}
|
|
311
525
|
owned(roomId) {
|
|
312
526
|
const live = this.member(roomId);
|
|
@@ -340,6 +554,8 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
340
554
|
kind: record.kind,
|
|
341
555
|
title: record.title,
|
|
342
556
|
...(record.view ? { view: record.view } : {}),
|
|
557
|
+
...(record.unlisted ? { unlisted: true } : {}),
|
|
558
|
+
relay: record.relay,
|
|
343
559
|
owner: record.own,
|
|
344
560
|
ownerName: record.owner.name,
|
|
345
561
|
status: record.status,
|
|
@@ -352,4 +568,77 @@ class RelayHubs extends relay_hubs_connection_1.RelayHubsConnection {
|
|
|
352
568
|
}
|
|
353
569
|
}
|
|
354
570
|
exports.RelayHubs = RelayHubs;
|
|
571
|
+
/** How far a membership has come: one computer heard it end, it ended for both. */
|
|
572
|
+
const STATUS_RANK = { waiting: 0, member: 1, refused: 2, gone: 3 };
|
|
573
|
+
var RelayHubsUtil;
|
|
574
|
+
(function (RelayHubsUtil) {
|
|
575
|
+
function isPrivate(identity) {
|
|
576
|
+
const value = identity;
|
|
577
|
+
return (!!value &&
|
|
578
|
+
typeof value.id === 'string' &&
|
|
579
|
+
typeof value.name === 'string' &&
|
|
580
|
+
typeof value.sign === 'string' &&
|
|
581
|
+
typeof value.box === 'string' &&
|
|
582
|
+
!!value.signKey &&
|
|
583
|
+
typeof value.signKey === 'object' &&
|
|
584
|
+
!!value.boxKey &&
|
|
585
|
+
typeof value.boxKey === 'object');
|
|
586
|
+
}
|
|
587
|
+
RelayHubsUtil.isPrivate = isPrivate;
|
|
588
|
+
function isRecord(record) {
|
|
589
|
+
const value = record;
|
|
590
|
+
return (!!value &&
|
|
591
|
+
typeof value.id === 'string' &&
|
|
592
|
+
typeof value.relay === 'string' &&
|
|
593
|
+
typeof value.member === 'string' &&
|
|
594
|
+
typeof value.token === 'string' &&
|
|
595
|
+
typeof value.status === 'string' &&
|
|
596
|
+
value.status in STATUS_RANK &&
|
|
597
|
+
!!value.owner &&
|
|
598
|
+
typeof value.owner.id === 'string' &&
|
|
599
|
+
(value.identity === undefined || isPrivate(value.identity)));
|
|
600
|
+
}
|
|
601
|
+
RelayHubsUtil.isRecord = isRecord;
|
|
602
|
+
/**
|
|
603
|
+
* Two records of one membership, as two computers of the user hold it: the further status (one heard it end), the
|
|
604
|
+
* key and the owner's keys once either has them, the invitations of both, made once either made it.
|
|
605
|
+
*/
|
|
606
|
+
function merge(local, other) {
|
|
607
|
+
var _a, _b, _c, _d, _e, _f;
|
|
608
|
+
const ahead = STATUS_RANK[other.status] > STATUS_RANK[local.status] ? other : local;
|
|
609
|
+
const behind = ahead === local ? other : local;
|
|
610
|
+
const invites = [...((_a = local.invites) !== null && _a !== void 0 ? _a : []), ...((_b = other.invites) !== null && _b !== void 0 ? _b : [])]
|
|
611
|
+
.filter((invite, index, all) => all.findIndex(each => each.secret === invite.secret) === index)
|
|
612
|
+
.sort((a, b) => a.expiresAt - b.expiresAt)
|
|
613
|
+
.slice(-3);
|
|
614
|
+
const merged = {
|
|
615
|
+
...behind,
|
|
616
|
+
...ahead,
|
|
617
|
+
kind: ahead.kind || behind.kind,
|
|
618
|
+
owner: ahead.owner.sign ? ahead.owner : behind.owner.sign ? behind.owner : ahead.owner,
|
|
619
|
+
createdAt: Math.min(local.createdAt, other.createdAt),
|
|
620
|
+
};
|
|
621
|
+
const key = (_c = ahead.key) !== null && _c !== void 0 ? _c : behind.key;
|
|
622
|
+
const joinedAt = Math.max((_d = local.joinedAt) !== null && _d !== void 0 ? _d : 0, (_e = other.joinedAt) !== null && _e !== void 0 ? _e : 0);
|
|
623
|
+
const identity = (_f = local.identity) !== null && _f !== void 0 ? _f : other.identity;
|
|
624
|
+
delete merged.key;
|
|
625
|
+
delete merged.invites;
|
|
626
|
+
delete merged.joinedAt;
|
|
627
|
+
delete merged.identity;
|
|
628
|
+
delete merged.made;
|
|
629
|
+
if (merged.status !== 'waiting') {
|
|
630
|
+
delete merged.invite;
|
|
631
|
+
delete merged.asked;
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
...merged,
|
|
635
|
+
...(key && (merged.status === 'member' || merged.status === 'waiting') ? { key } : {}),
|
|
636
|
+
...(invites.length ? { invites } : {}),
|
|
637
|
+
...(local.made || other.made ? { made: true } : {}),
|
|
638
|
+
...(joinedAt ? { joinedAt } : {}),
|
|
639
|
+
...(identity ? { identity } : {}),
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
RelayHubsUtil.merge = merge;
|
|
643
|
+
})(RelayHubsUtil || (exports.RelayHubsUtil = RelayHubsUtil = {}));
|
|
355
644
|
//# sourceMappingURL=relay-hubs.js.map
|
|
@@ -13,6 +13,8 @@ export interface RelayIdentity extends RelayPublicIdentity {
|
|
|
13
13
|
signKey: JsonWebKey;
|
|
14
14
|
boxKey: JsonWebKey;
|
|
15
15
|
createdAt: number;
|
|
16
|
+
/** The user's other computers are this Ta too: who answers in a room is agreed first (docs/design/ta-sync.md 9). */
|
|
17
|
+
shared?: true;
|
|
16
18
|
}
|
|
17
19
|
/** Keys, sealing and signatures of rooms and identities, with WebCrypto only: the same in ta serve, a browser and a Worker. */
|
|
18
20
|
export declare namespace RelayKeys {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** What a relay says of itself (docs/design/ta-relays.md 3.1): GET RELAY_INFO_PATH. */
|
|
2
|
+
export declare const RELAY_INFO_PATH = "/v1/info";
|
|
3
|
+
/** What a relay can do: forward to a host, hold rooms, keep sealed copies, serve the pages of links. */
|
|
4
|
+
export type RelayCapability = 'tunnel' | 'hub' | 'store' | 'pages';
|
|
5
|
+
export interface RelayLimits {
|
|
6
|
+
hubMembers: number;
|
|
7
|
+
/** Characters of a sealed message or value of a room. */
|
|
8
|
+
hubValueBytes: number;
|
|
9
|
+
hubKeys: number;
|
|
10
|
+
hubStateBytes: number;
|
|
11
|
+
hubIdleDays: number;
|
|
12
|
+
/** Bytes of a sealed copy, and its days at most. */
|
|
13
|
+
storeValueBytes: number;
|
|
14
|
+
storeDays: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RelayInfo {
|
|
17
|
+
v: 1;
|
|
18
|
+
capabilities: RelayCapability[];
|
|
19
|
+
limits: RelayLimits;
|
|
20
|
+
/** Whether rooms and copies stay when the relay restarts. */
|
|
21
|
+
persistent: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** A relay that answers no RELAY_INFO_PATH, made before it: all it can do, with the limits of then. */
|
|
24
|
+
export declare const RELAY_LEGACY_INFO: RelayInfo;
|
|
25
|
+
/** What a probe of a relay found. */
|
|
26
|
+
export interface RelayProbe {
|
|
27
|
+
online: boolean;
|
|
28
|
+
info?: RelayInfo;
|
|
29
|
+
/** It answers, but not RELAY_INFO_PATH: one made before it. */
|
|
30
|
+
legacy?: boolean;
|
|
31
|
+
/** Milliseconds to its answer. */
|
|
32
|
+
ms?: number;
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace RelayInfoUtil {
|
|
36
|
+
function of(persistent: boolean): RelayInfo;
|
|
37
|
+
/** The answer of RELAY_INFO_PATH: JSON, readable by any page (it says nothing secret). */
|
|
38
|
+
function response(info: RelayInfo): Response;
|
|
39
|
+
/** The address of a relay as it is kept: http(s), its origin and path, no trailing slash. Throws on what is not one. */
|
|
40
|
+
function normalize(url: string): string;
|
|
41
|
+
/** Asks a relay what it is; never throws. */
|
|
42
|
+
function probe(url: string, timeoutMs?: number): Promise<RelayProbe>;
|
|
43
|
+
function parse(value: unknown): RelayInfo | undefined;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=relay-info.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelayInfoUtil = exports.RELAY_LEGACY_INFO = exports.RELAY_INFO_PATH = void 0;
|
|
4
|
+
const relay_protocol_1 = require("./relay-protocol");
|
|
5
|
+
/** What a relay says of itself (docs/design/ta-relays.md 3.1): GET RELAY_INFO_PATH. */
|
|
6
|
+
exports.RELAY_INFO_PATH = '/v1/info';
|
|
7
|
+
/** A relay that answers no RELAY_INFO_PATH, made before it: all it can do, with the limits of then. */
|
|
8
|
+
exports.RELAY_LEGACY_INFO = {
|
|
9
|
+
v: 1,
|
|
10
|
+
capabilities: ['tunnel', 'hub', 'store', 'pages'],
|
|
11
|
+
limits: {
|
|
12
|
+
hubMembers: relay_protocol_1.RELAY_HUB_MAX_MEMBERS,
|
|
13
|
+
hubValueBytes: relay_protocol_1.RELAY_HUB_MAX_VALUE,
|
|
14
|
+
hubKeys: relay_protocol_1.RELAY_HUB_MAX_KEYS,
|
|
15
|
+
hubStateBytes: relay_protocol_1.RELAY_HUB_MAX_STATE,
|
|
16
|
+
hubIdleDays: relay_protocol_1.RELAY_HUB_IDLE_DAYS,
|
|
17
|
+
storeValueBytes: relay_protocol_1.RELAY_CONTENT_MAX_BYTES,
|
|
18
|
+
storeDays: relay_protocol_1.RELAY_BLOB_MAX_DAYS,
|
|
19
|
+
},
|
|
20
|
+
persistent: true,
|
|
21
|
+
};
|
|
22
|
+
var RelayInfoUtil;
|
|
23
|
+
(function (RelayInfoUtil) {
|
|
24
|
+
function of(persistent) {
|
|
25
|
+
return { ...exports.RELAY_LEGACY_INFO, persistent };
|
|
26
|
+
}
|
|
27
|
+
RelayInfoUtil.of = of;
|
|
28
|
+
/** The answer of RELAY_INFO_PATH: JSON, readable by any page (it says nothing secret). */
|
|
29
|
+
function response(info) {
|
|
30
|
+
return new Response(JSON.stringify(info), {
|
|
31
|
+
headers: { 'content-type': 'application/json', 'access-control-allow-origin': '*', 'cache-control': 'no-store' },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
RelayInfoUtil.response = response;
|
|
35
|
+
/** The address of a relay as it is kept: http(s), its origin and path, no trailing slash. Throws on what is not one. */
|
|
36
|
+
function normalize(url) {
|
|
37
|
+
const text = String(url !== null && url !== void 0 ? url : '').trim();
|
|
38
|
+
const parsed = new URL(text);
|
|
39
|
+
if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
|
|
40
|
+
throw new Error(`${text} is not the address of a relay.`);
|
|
41
|
+
}
|
|
42
|
+
return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, '');
|
|
43
|
+
}
|
|
44
|
+
RelayInfoUtil.normalize = normalize;
|
|
45
|
+
/** Asks a relay what it is; never throws. */
|
|
46
|
+
async function probe(url, timeoutMs = 6000) {
|
|
47
|
+
const started = Date.now();
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
50
|
+
try {
|
|
51
|
+
const response = await fetch(`${normalize(url)}${exports.RELAY_INFO_PATH}`, { signal: controller.signal, redirect: 'manual' });
|
|
52
|
+
const ms = Date.now() - started;
|
|
53
|
+
if (response.ok) {
|
|
54
|
+
const info = parse(await response.json().catch(() => undefined));
|
|
55
|
+
return info ? { online: true, info, ms } : { online: true, legacy: true, info: exports.RELAY_LEGACY_INFO, ms };
|
|
56
|
+
}
|
|
57
|
+
if (response.status === 404 || response.status === 426) {
|
|
58
|
+
// A relay of before answers its root and nothing of this path: it is one if its root says so.
|
|
59
|
+
const root = await fetch(`${normalize(url)}/`, { signal: controller.signal }).then(answer => answer.text(), () => '');
|
|
60
|
+
return root.startsWith('Ta relay')
|
|
61
|
+
? { online: true, legacy: true, info: exports.RELAY_LEGACY_INFO, ms }
|
|
62
|
+
: { online: false, ms, error: `It answers, but is not a relay of Ta (${response.status}).` };
|
|
63
|
+
}
|
|
64
|
+
return { online: false, ms, error: `It answered ${response.status}.` };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
const aborted = (error === null || error === void 0 ? void 0 : error.name) === 'AbortError';
|
|
68
|
+
return { online: false, error: aborted ? 'No answer in time.' : (error === null || error === void 0 ? void 0 : error.message) || String(error) };
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
RelayInfoUtil.probe = probe;
|
|
75
|
+
function parse(value) {
|
|
76
|
+
const info = value;
|
|
77
|
+
if ((info === null || info === void 0 ? void 0 : info.v) !== 1 || !Array.isArray(info.capabilities) || !info.limits || typeof info.limits !== 'object') {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const known = ['tunnel', 'hub', 'store', 'pages'];
|
|
81
|
+
const limits = { ...exports.RELAY_LEGACY_INFO.limits };
|
|
82
|
+
for (const key of Object.keys(limits)) {
|
|
83
|
+
const given = info.limits[key];
|
|
84
|
+
if (typeof given === 'number' && given > 0) {
|
|
85
|
+
limits[key] = given;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
v: 1,
|
|
90
|
+
capabilities: info.capabilities.filter((capability) => known.includes(capability)),
|
|
91
|
+
limits,
|
|
92
|
+
persistent: info.persistent !== false,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
RelayInfoUtil.parse = parse;
|
|
96
|
+
})(RelayInfoUtil || (exports.RelayInfoUtil = RelayInfoUtil = {}));
|
|
97
|
+
//# sourceMappingURL=relay-info.js.map
|
|
@@ -166,11 +166,15 @@ export declare const RELAY_PROOF = "ta-relay ready";
|
|
|
166
166
|
export declare const RELAY_HUB_PATH = "/v1/hub/";
|
|
167
167
|
/** Links that invite into a room (RelayHubLink): Ta opens them; a browser gets the page of guests (src/guest). */
|
|
168
168
|
export declare const RELAY_ROOM_PATH = "/r";
|
|
169
|
-
/** Members of a
|
|
170
|
-
export declare const RELAY_HUB_MAX_MEMBERS =
|
|
169
|
+
/** Members of a hub at most, its owner among them: a room of friends (its owner and RELAY_FRIENDS_MAX friends). */
|
|
170
|
+
export declare const RELAY_HUB_MAX_MEMBERS = 101;
|
|
171
|
+
/** Members of a room the user made, its owner among them: the owner's Ta lets in no more (RelayHubs.answer). */
|
|
172
|
+
export declare const RELAY_ROOM_MAX_MEMBERS = 16;
|
|
173
|
+
/** Friends of a Ta at most: the members of its room of friends (docs/design/ta-link.md 3.1). */
|
|
174
|
+
export declare const RELAY_FRIENDS_MAX = 100;
|
|
171
175
|
/** Characters of a sealed message or value of the state. */
|
|
172
176
|
export declare const RELAY_HUB_MAX_VALUE: number;
|
|
173
|
-
export declare const RELAY_HUB_MAX_KEYS =
|
|
177
|
+
export declare const RELAY_HUB_MAX_KEYS = 4096;
|
|
174
178
|
/** Characters of all of the state, sealed. */
|
|
175
179
|
export declare const RELAY_HUB_MAX_STATE: number;
|
|
176
180
|
/** Asks to join waiting for the owner, and for how long. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RELAY_HUB_RATE = exports.RELAY_HUB_IDLE_DAYS = exports.RELAY_HUB_ASK_DAYS = exports.RELAY_HUB_MAX_ASKS = exports.RELAY_HUB_MAX_STATE = exports.RELAY_HUB_MAX_KEYS = exports.RELAY_HUB_MAX_VALUE = exports.RELAY_HUB_MAX_MEMBERS = exports.RELAY_ROOM_PATH = exports.RELAY_HUB_PATH = exports.RELAY_PROOF = exports.RELAY_STALE_MS = exports.RELAY_PING_MS = exports.RELAY_PONG = exports.RELAY_PING = exports.RelayCloseCode = exports.RELAY_ID = exports.RELAY_BLOB_MAX_DAYS = exports.RELAY_CONTENT_MAX_BYTES = exports.RELAY_SHARE_DAYS = exports.RELAY_SHARE_CHUNK_BYTES = exports.RELAY_SHARE_MAX_BYTES = exports.RELAY_SHARE_PAGE = exports.RELAY_PAIR_PAGE = exports.RELAY_BLOB_PATH = exports.RELAY_VIEWER_HEADERS = exports.RELAY_FRAME_HEADER_CSP = exports.RELAY_FRAME_CSP = exports.RELAY_FRAME_PATH = exports.RELAY_CONTENT_PATH = exports.RELAY_SHARE_PATH = exports.RELAY_PAIR_PATH = exports.RELAY_CONNECT_PATH = exports.RELAY_HOST_PATH = exports.RELAY_DEFAULT_URL = void 0;
|
|
3
|
+
exports.RELAY_HUB_RATE = exports.RELAY_HUB_IDLE_DAYS = exports.RELAY_HUB_ASK_DAYS = exports.RELAY_HUB_MAX_ASKS = exports.RELAY_HUB_MAX_STATE = exports.RELAY_HUB_MAX_KEYS = exports.RELAY_HUB_MAX_VALUE = exports.RELAY_FRIENDS_MAX = exports.RELAY_ROOM_MAX_MEMBERS = exports.RELAY_HUB_MAX_MEMBERS = exports.RELAY_ROOM_PATH = exports.RELAY_HUB_PATH = exports.RELAY_PROOF = exports.RELAY_STALE_MS = exports.RELAY_PING_MS = exports.RELAY_PONG = exports.RELAY_PING = exports.RelayCloseCode = exports.RELAY_ID = exports.RELAY_BLOB_MAX_DAYS = exports.RELAY_CONTENT_MAX_BYTES = exports.RELAY_SHARE_DAYS = exports.RELAY_SHARE_CHUNK_BYTES = exports.RELAY_SHARE_MAX_BYTES = exports.RELAY_SHARE_PAGE = exports.RELAY_PAIR_PAGE = exports.RELAY_BLOB_PATH = exports.RELAY_VIEWER_HEADERS = exports.RELAY_FRAME_HEADER_CSP = exports.RELAY_FRAME_CSP = exports.RELAY_FRAME_PATH = exports.RELAY_CONTENT_PATH = exports.RELAY_SHARE_PATH = exports.RELAY_PAIR_PATH = exports.RELAY_CONNECT_PATH = exports.RELAY_HOST_PATH = exports.RELAY_DEFAULT_URL = void 0;
|
|
4
4
|
/** The relay of Ta, on Cloudflare Workers (apps/ta-relay), when the user names none. */
|
|
5
5
|
exports.RELAY_DEFAULT_URL = 'https://relay.cellbang.com';
|
|
6
6
|
/** What the relay serves: hosts connect to the first, devices to the second. */
|
|
@@ -94,11 +94,15 @@ exports.RELAY_PROOF = 'ta-relay ready';
|
|
|
94
94
|
exports.RELAY_HUB_PATH = '/v1/hub/';
|
|
95
95
|
/** Links that invite into a room (RelayHubLink): Ta opens them; a browser gets the page of guests (src/guest). */
|
|
96
96
|
exports.RELAY_ROOM_PATH = '/r';
|
|
97
|
-
/** Members of a
|
|
98
|
-
exports.RELAY_HUB_MAX_MEMBERS =
|
|
97
|
+
/** Members of a hub at most, its owner among them: a room of friends (its owner and RELAY_FRIENDS_MAX friends). */
|
|
98
|
+
exports.RELAY_HUB_MAX_MEMBERS = 101;
|
|
99
|
+
/** Members of a room the user made, its owner among them: the owner's Ta lets in no more (RelayHubs.answer). */
|
|
100
|
+
exports.RELAY_ROOM_MAX_MEMBERS = 16;
|
|
101
|
+
/** Friends of a Ta at most: the members of its room of friends (docs/design/ta-link.md 3.1). */
|
|
102
|
+
exports.RELAY_FRIENDS_MAX = 100;
|
|
99
103
|
/** Characters of a sealed message or value of the state. */
|
|
100
104
|
exports.RELAY_HUB_MAX_VALUE = 96 * 1024;
|
|
101
|
-
exports.RELAY_HUB_MAX_KEYS =
|
|
105
|
+
exports.RELAY_HUB_MAX_KEYS = 4096;
|
|
102
106
|
/** Characters of all of the state, sealed. */
|
|
103
107
|
exports.RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
|
|
104
108
|
/** Asks to join waiting for the owner, and for how long. */
|
|
@@ -38,6 +38,11 @@ export interface RelayChatLine {
|
|
|
38
38
|
to?: string[];
|
|
39
39
|
/** The id of the line it answers. */
|
|
40
40
|
re?: string;
|
|
41
|
+
/**
|
|
42
|
+
* A task handed to the doubles it asks (`to`), not a question (docs/design/ta-link.md 6): each one's Ta works on it on
|
|
43
|
+
* its own, says how it goes under `tasks:<member>` of the state, and answers with `re` when it ends.
|
|
44
|
+
*/
|
|
45
|
+
task?: boolean;
|
|
41
46
|
}
|
|
42
47
|
/** An agent of a member's Ta, in a room (RelayChatLine.agent). */
|
|
43
48
|
export interface RelayChatAgent {
|
|
@@ -45,7 +50,7 @@ export interface RelayChatAgent {
|
|
|
45
50
|
name: string;
|
|
46
51
|
}
|
|
47
52
|
/** What a line adds to its text: who said it and to whom (RelayRoomChat.say). */
|
|
48
|
-
export type RelayChatLineExtra = Pick<RelayChatLine, 'double' | 'agent' | 'to' | 're'>;
|
|
53
|
+
export type RelayChatLineExtra = Pick<RelayChatLine, 'double' | 'agent' | 'to' | 're' | 'task'>;
|
|
49
54
|
/** What is kept of a line: `from` is the key's. */
|
|
50
55
|
type StoredLine = Omit<RelayChatLine, 'from'>;
|
|
51
56
|
/** The keys of what is said, `chat:<member>:<n>`: each member writes only its own, so none can write as another. */
|