@celljs/ta-relay 4.12.0 → 4.13.0
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/README.en.md
CHANGED
|
@@ -48,7 +48,28 @@ A Ta service can also hand an extension of its computer to another through the r
|
|
|
48
48
|
## Deploying Relay
|
|
49
49
|
|
|
50
50
|
- Cloudflare Workers: [apps/ta-relay](../../apps/ta-relay/README.md) (Durable Objects, sleep when idle).
|
|
51
|
-
- Your own machine: `ta relay [--host 0.0.0.0] [--port 8080]`, behind an HTTPS reverse proxy.
|
|
51
|
+
- Your own machine: `ta relay [--host 0.0.0.0] [--port 8080] [--data <dir>]`, behind an HTTPS reverse proxy. With `--data`, rooms, offline copies and which host holds which ID are kept on disk across restarts; without it they live in memory, and after a restart the first host to connect reclaims its ID.
|
|
52
|
+
|
|
53
|
+
## A relay of your own (relays.json)
|
|
54
|
+
|
|
55
|
+
Which relay each feature uses is set by `relays.json` in the agent directory (design: [docs/design/ta-relays.md](../../docs/design/ta-relays.md)). Without it, as before: everything goes through the relay of `relay.json`, else the official one. Settings → Relays in the web client adds relays and chooses one for each feature.
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"relays": {
|
|
60
|
+
"home": { "type": "ta-relay", "url": "https://relay.example.com", "name": "Home" }
|
|
61
|
+
},
|
|
62
|
+
"use": { "devices": "home", "share": "home", "rooms": "cellbang", "sync": "home" },
|
|
63
|
+
"default": "cellbang"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- `cellbang` is the official relay `https://relay.cellbang.com`, there without being written.
|
|
68
|
+
- A service may also be a folder of a cloud drive: `{ "type": "folder", "path": "~/Library/Mobile Documents/com~apple~CloudDocs/Ta" }`, for `sync` alone (sync goes through the folder, no relay; see the README of @celljs/ta-sync).
|
|
69
|
+
- Features of `use`: `devices` (devices paired from now on; also `ta pair` without an address), `share` (links of extensions and content, their offline copies, the pages links open in), `rooms` (new rooms; the rooms of extensions too), `sync` (the room of sync; as `rooms` when not named). Those not named take `default`.
|
|
70
|
+
- Only what is made from now on: each device, share and room keeps the relay it is on (`devices[].relay`, `shares[].relay`, `contents[].relay` of `relay.json`, `relay` of `rooms.json`) whatever the configuration says later. `ta serve` connects to every relay that still has a device or a share, one connection each; a device is known only through the relay it was paired on.
|
|
71
|
+
- Capabilities: a relay answers `GET /v1/info` (`{ v, capabilities, limits, persistent }`, readable from any origin). A relay of before, without it, is taken as one with every capability and the limits of then.
|
|
72
|
+
- Running your own: `ta relay --data <dir>` keeps rooms, offline copies and which host holds which id on disk, across restarts; without `--data` they live in memory.
|
|
52
73
|
|
|
53
74
|
## Known Limitations
|
|
54
75
|
|
|
@@ -66,3 +87,7 @@ A Ta service can also hand an extension of its computer to another through the r
|
|
|
66
87
|
## Rooms (`/v1/hub/<room>`)
|
|
67
88
|
|
|
68
89
|
Rooms several Ta share ([docs/design/ta-link.md](../../docs/design/ta-link.md), section 3): `RelayHub` keeps on the relay the hashes of the members' tokens, the asks to join till the owner answers, the roster signed by the owner and the shared state, all sealed; it passes messages between members and sets the state on its version. On the Worker each room is a Durable Object (`RelayHubObject`); in `ta relay`, memory. On the side of Ta, `RelayHubs` (its identity in `identity.json`, rooms in `rooms.json`, friends in `friends.json`): making a room, links that invite (`/r#…`, `RelayHubUtil`), asks and the owner's answers (the key of the room sealed by ECDH and signed), and the signatures and sealing of messages and the state. `RelayHubs` is in `common/`, its store its own: `RelayHubFiles` for Ta, localStorage in a browser. A link that invites opens the page of web guests in a browser (`src/guest` → `viewer/room.html`, its script allowed by its hash, connecting to this relay alone): one without Ta asks there and, let in, only chats (`RelayRoomChat`); the Ta of the others take no other state it sets and none of its messages.
|
|
90
|
+
|
|
91
|
+
## Codes of a spot (`/v1/spot/<id>`)
|
|
92
|
+
|
|
93
|
+
Where the network keeps devices apart (an office Wi-Fi that isolates them), Nearby of Ta meets by a code of six digits ([docs/design/ta-nearby.md](../../docs/design/ta-nearby.md) 2.2): `id` is a hash of the code, which the relay never knows. `RelaySpot` only keeps who is connected: the first to send `open` opens it, others `join` within 10 minutes, 50 at most; it passes each one's beacon (without port nor address) to the others, and sealed messages to one by its temporary id, which the relay cannot read; nothing is stored, and it is gone with the last one. On the Worker a `RelaySpotObject` for each code, in memory in `ta relay`. Against guessing: an address (an IPv6 one by its /64) that tried 10 codes nobody opened in 10 minutes is refused even a right one (close code 4428); only failures count (`RelaySpotTries`; on the Worker a `RelayTriesObject` for each address by `CF-Connecting-IP`, in `ta relay` the address of the connection).
|
package/README.md
CHANGED
|
@@ -48,7 +48,28 @@ Ta 服务也能经中继把本机的一个扩展交给另一台电脑(`RelaySt
|
|
|
48
48
|
## 部署 Relay
|
|
49
49
|
|
|
50
50
|
- Cloudflare Workers:[apps/ta-relay](../../apps/ta-relay/README.md)(Durable Objects,空闲时休眠)。
|
|
51
|
-
- 自己的机器:`ta relay [--host 0.0.0.0] [--port 8080]`,放在 HTTPS
|
|
51
|
+
- 自己的机器:`ta relay [--host 0.0.0.0] [--port 8080] [--data <目录>]`,放在 HTTPS 反向代理后面。带 `--data` 时房间、离线副本和主机 id 的归属存到磁盘,重启不丢;不带时只在内存里,重启后由先连上来的主机重新认领。
|
|
52
|
+
|
|
53
|
+
## 换用自己的中继(relays.json)
|
|
54
|
+
|
|
55
|
+
每个功能用哪个中继由 agent 目录里的 `relays.json` 决定(设计见 [docs/design/ta-relays.md](../../docs/design/ta-relays.md))。没有这个文件时与以前一样:全部用 `relay.json` 记的中继,没有就用官方中继。在 Web 客户端的 设置 → 中继服务 里也能添加中继、为每个功能选择。
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"relays": {
|
|
60
|
+
"home": { "type": "ta-relay", "url": "https://relay.example.com", "name": "家里的中继" }
|
|
61
|
+
},
|
|
62
|
+
"use": { "devices": "home", "share": "home", "rooms": "cellbang", "sync": "home" },
|
|
63
|
+
"default": "cellbang"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- `cellbang` 是官方中继 `https://relay.cellbang.com`,不写也在。
|
|
68
|
+
- 服务也可以是网盘里的文件夹:`{ "type": "folder", "path": "~/Library/Mobile Documents/com~apple~CloudDocs/Ta" }`,只能用于 `sync`(设备同步经文件夹进行,不经过中继,见 @celljs/ta-sync 的 README)。
|
|
69
|
+
- `use` 的功能:`devices`(新配对的设备,`ta pair` 不带地址时也用它)、`share`(分享扩展与内容的链接、离线副本、链接打开的网页)、`rooms`(新建房间;扩展自己的房间也按它)、`sync`(设备同步的房间,不写时跟 `rooms`)。没写的用 `default`。
|
|
70
|
+
- 只影响新建的东西:每台设备、每个分享、每个房间都记着自己所在的中继(`relay.json` 的 `devices[].relay`、`shares[].relay`、`contents[].relay`,`rooms.json` 的 `relay`),换了配置也留在原来的中继上。`ta serve` 连到所有还有设备或分享的中继,每个中继一条连接;设备只认它配对时的那个中继。
|
|
71
|
+
- 能力探测:中继回答 `GET /v1/info`(`{ v, capabilities, limits, persistent }`,允许跨域)。没有这个接口的旧中继按全部能力、当时的上限处理。
|
|
72
|
+
- 自己运行:`ta relay --data <目录>` 把房间、离线副本和主机 id 的归属存到磁盘,重启后不丢;不带 `--data` 时只在内存里。
|
|
52
73
|
|
|
53
74
|
## 已知限制
|
|
54
75
|
|
|
@@ -66,3 +87,7 @@ Ta 服务也能经中继把本机的一个扩展交给另一台电脑(`RelaySt
|
|
|
66
87
|
## 房间(`/v1/hub/<房间>`)
|
|
67
88
|
|
|
68
89
|
几台 Ta 共用的房间([docs/design/ta-link.md](../../docs/design/ta-link.md) 第 3 节):`RelayHub` 在中继上保存成员令牌的哈希、未处理的加入申请、房主签名的成员名单和共享状态(都是密文),转发成员之间的消息,按版本号写入状态;Worker 上每个房间一个 Durable Object(`RelayHubObject`),`ta relay` 里在内存。Ta 一侧是 `RelayHubs`(身份 `identity.json`、房间 `rooms.json`、好友 `friends.json`):建房、邀请链接(`/r#…`,`RelayHubUtil`)、申请与房主答复(ECDH 加密房间密钥并签名)、消息与状态的签名和加密。`RelayHubs` 在 `common/`,存储可换:Ta 用 `RelayHubFiles`,浏览器用 localStorage。邀请链接在浏览器里打开的是网页访客页(`src/guest` → `viewer/room.html`,脚本按哈希放行,只连本中继):没装 Ta 的人在网页里申请,房主同意后只能聊天(`RelayRoomChat`),其他成员的 Ta 不采用访客写的其他状态和发的消息。
|
|
90
|
+
|
|
91
|
+
## 在场码(`/v1/spot/<id>`)
|
|
92
|
+
|
|
93
|
+
同一网络里看不到彼此时(公司 Wi-Fi 隔离设备),Ta 的"附近"用 6 位在场码碰头([docs/design/ta-nearby.md](../../docs/design/ta-nearby.md) 2.2):`id` 是在场码的哈希,中继不知道数字本身。`RelaySpot` 只记谁连着:第一个发 `open` 的人打开它,10 分钟内别人 `join` 进来,最多 50 人;它把每个人的信标(不带端口和地址)转给其他人,把加密消息按临时 id 转给对方,内容中继读不到;什么都不存,最后一人离开就没了。Worker 上每个在场码一个 `RelaySpotObject`,`ta relay` 里在内存。防穷举:一个地址(IPv6 按 /64)10 分钟内试了 10 个没人打开的码,之后连正确的码也拒绝(关闭码 4428),只数失败(`RelaySpotTries`;Worker 上按 `CF-Connecting-IP` 每个地址一个 `RelayTriesObject`,`ta relay` 用连接的对端地址)。
|
package/esm/common/index.d.ts
CHANGED
|
@@ -7,14 +7,17 @@ export * from './relay-content.js';
|
|
|
7
7
|
export * from './relay-conversation.js';
|
|
8
8
|
export * from './relay-faces.js';
|
|
9
9
|
export * from './relay-files.js';
|
|
10
|
+
export * from './relay-friends.js';
|
|
10
11
|
export * from './relay-hub.js';
|
|
11
12
|
export * from './relay-hub-util.js';
|
|
12
13
|
export * from './relay-hubs.js';
|
|
13
14
|
export * from './relay-hubs-protocol.js';
|
|
14
15
|
export * from './relay-identity.js';
|
|
16
|
+
export * from './relay-info.js';
|
|
15
17
|
export * from './relay-pairing.js';
|
|
16
18
|
export * from './relay-protocol.js';
|
|
17
19
|
export * from './relay-room.js';
|
|
18
20
|
export * from './relay-room-chat.js';
|
|
19
21
|
export * from './relay-share.js';
|
|
20
22
|
export * from './relay-socket.js';
|
|
23
|
+
export * from './relay-spot.js';
|
package/esm/common/index.js
CHANGED
|
@@ -7,15 +7,18 @@ export * from './relay-content.js';
|
|
|
7
7
|
export * from './relay-conversation.js';
|
|
8
8
|
export * from './relay-faces.js';
|
|
9
9
|
export * from './relay-files.js';
|
|
10
|
+
export * from './relay-friends.js';
|
|
10
11
|
export * from './relay-hub.js';
|
|
11
12
|
export * from './relay-hub-util.js';
|
|
12
13
|
export * from './relay-hubs.js';
|
|
13
14
|
export * from './relay-hubs-protocol.js';
|
|
14
15
|
export * from './relay-identity.js';
|
|
16
|
+
export * from './relay-info.js';
|
|
15
17
|
export * from './relay-pairing.js';
|
|
16
18
|
export * from './relay-protocol.js';
|
|
17
19
|
export * from './relay-room.js';
|
|
18
20
|
export * from './relay-room-chat.js';
|
|
19
21
|
export * from './relay-share.js';
|
|
20
22
|
export * from './relay-socket.js';
|
|
23
|
+
export * from './relay-spot.js';
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { RelayFriend, RelayFriendInfo, RelayFriendRequest, RelayHubsStore, RelayRoomEvent, RelayRoomInfo, RelayRoomRecord, RelayRoomValue } from './relay-hubs-protocol.js';
|
|
2
|
+
import { type RelayIdentity, type RelayPublicIdentity } from './relay-identity.js';
|
|
3
|
+
/** The kind of the room of a Ta's friends (docs/design/ta-link.md 3.1): unlisted, one a Ta, its friends its members. */
|
|
4
|
+
export declare const RELAY_FRIENDS_KIND = "ta-friends";
|
|
5
|
+
/** What the friends of a Ta need of its rooms (RelayHubs). */
|
|
6
|
+
export interface RelayFriendRooms {
|
|
7
|
+
identity(): Promise<RelayIdentity>;
|
|
8
|
+
list(): RelayRoomInfo[];
|
|
9
|
+
/** The identity id of a room's owner, known from the link while waiting. */
|
|
10
|
+
ownerOf(room: string): string | undefined;
|
|
11
|
+
/** The public identity of a member of a room, as its roster has it. */
|
|
12
|
+
memberOf(room: string, member: string): RelayPublicIdentity | undefined;
|
|
13
|
+
/** Those asking to join a room of this Ta, as they ask. */
|
|
14
|
+
asksOf(room: string): (RelayPublicIdentity & {
|
|
15
|
+
member: string;
|
|
16
|
+
at: number;
|
|
17
|
+
guest?: boolean;
|
|
18
|
+
})[];
|
|
19
|
+
create(input: {
|
|
20
|
+
kind: string;
|
|
21
|
+
title: string;
|
|
22
|
+
unlisted: boolean;
|
|
23
|
+
}): Promise<RelayRoomInfo>;
|
|
24
|
+
invite(room: string, options: {
|
|
25
|
+
days?: number;
|
|
26
|
+
renew?: boolean;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
link: string;
|
|
29
|
+
expiresAt: number;
|
|
30
|
+
}>;
|
|
31
|
+
join(link: string): Promise<RelayRoomInfo>;
|
|
32
|
+
answer(room: string, ask: string, accept: boolean): Promise<void>;
|
|
33
|
+
remove(room: string, member: string): Promise<void>;
|
|
34
|
+
leave(room: string): Promise<void>;
|
|
35
|
+
getState(room: string, prefix?: string): Promise<Record<string, RelayRoomValue>>;
|
|
36
|
+
setState(room: string, key: string, value: unknown): Promise<{
|
|
37
|
+
ok: boolean;
|
|
38
|
+
version: number;
|
|
39
|
+
}>;
|
|
40
|
+
/** Asks a member of a shared room to be friends: the link of this Ta's room of friends, to it alone. */
|
|
41
|
+
offer(room: string, member: string, link: string): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/** Asked to be friends in a room the two share: the link of the other's room of friends. */
|
|
44
|
+
interface Offer extends RelayPublicIdentity {
|
|
45
|
+
link: string;
|
|
46
|
+
/** The title of the room it was asked in. */
|
|
47
|
+
room: string;
|
|
48
|
+
at: number;
|
|
49
|
+
}
|
|
50
|
+
/** `friends.json`: those the user chose as friends, and who asked the user in a shared room. */
|
|
51
|
+
interface Book {
|
|
52
|
+
v: 2;
|
|
53
|
+
friends: RelayFriend[];
|
|
54
|
+
offers: Offer[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The friends of a Ta (docs/design/ta-link.md 3.1): one kind of friend, each on the word of both. A Ta has one
|
|
58
|
+
* unlisted room of friends; two are friends when each is a member of the other's. One asks by the link of the other's
|
|
59
|
+
* room (a code, a link sent), or in a room the two share (the other is sent the link of this one's room); the other
|
|
60
|
+
* answers. Then each Ta joins the other's room on its own: the user chose the other (`friends`), and the other wrote
|
|
61
|
+
* the link of its room in this one's (`back:`). Removing a friend ends it on both sides. Other features of Ta keep
|
|
62
|
+
* what they give friends in the room of friends (Moments its posts), and share with friends by their keys.
|
|
63
|
+
*/
|
|
64
|
+
export declare class RelayFriends {
|
|
65
|
+
protected readonly rooms: RelayFriendRooms;
|
|
66
|
+
protected readonly store: RelayHubsStore;
|
|
67
|
+
protected readonly emit: (event: RelayRoomEvent) => void;
|
|
68
|
+
protected settle?: ReturnType<typeof setTimeout>;
|
|
69
|
+
protected queue: Promise<unknown>;
|
|
70
|
+
/** Links of `back:` joined while this runs: one that failed is not tried again till it changes. */
|
|
71
|
+
protected readonly tried: Set<string>;
|
|
72
|
+
/** Asks the user was told of while this runs. */
|
|
73
|
+
protected readonly told: Set<string>;
|
|
74
|
+
protected stopped: boolean;
|
|
75
|
+
constructor(rooms: RelayFriendRooms, store: RelayHubsStore, emit: (event: RelayRoomEvent) => void);
|
|
76
|
+
start(): void;
|
|
77
|
+
stop(): void;
|
|
78
|
+
/** The user's room of friends, made the first time. */
|
|
79
|
+
room(): Promise<RelayRoomInfo>;
|
|
80
|
+
/** The link (and code) that asks to be the user's friend. */
|
|
81
|
+
link(renew?: boolean): Promise<{
|
|
82
|
+
link: string;
|
|
83
|
+
expiresAt: number;
|
|
84
|
+
}>;
|
|
85
|
+
/** Asks the one of a link to be friends, on the user's word. */
|
|
86
|
+
add(link: string): Promise<void>;
|
|
87
|
+
/** Asks a member of a room the user is in to be friends: it is told, and answers in its Ta. */
|
|
88
|
+
offer(room: string, member: string): Promise<void>;
|
|
89
|
+
/** A member of a shared room asked the user to be friends: joined back at once if the user asked it, else asked. */
|
|
90
|
+
offered(from: RelayPublicIdentity, link: string, title: string): void;
|
|
91
|
+
/** Those asking the user to be friends: by the link of the user's room, or in a room the two share. */
|
|
92
|
+
requests(): RelayFriendRequest[];
|
|
93
|
+
/** One asking to join the room of friends, heard: told the user, unless the user chose it (let in as it settles). */
|
|
94
|
+
asked(ask: RelayPublicIdentity & {
|
|
95
|
+
member: string;
|
|
96
|
+
at: number;
|
|
97
|
+
guest?: boolean;
|
|
98
|
+
}): void;
|
|
99
|
+
/** The user's answer to one asking to be friends. Only ever on the user's word, never on an agent's. */
|
|
100
|
+
answer(id: string, accept: boolean): Promise<void>;
|
|
101
|
+
/** No longer friends, on both sides: out of the user's room, and the user out of theirs. */
|
|
102
|
+
remove(id: string): Promise<boolean>;
|
|
103
|
+
/** The user's friends, and those being added: whether each is a friend yet, and online. */
|
|
104
|
+
list(): RelayFriendInfo[];
|
|
105
|
+
/** The friends, with their keys: those both chose, and in each other's room (shares to friends use their keys). */
|
|
106
|
+
friends(): (RelayFriend & RelayPublicIdentity)[];
|
|
107
|
+
/** Ids of those the user chose. */
|
|
108
|
+
ids(): Set<string>;
|
|
109
|
+
/** Those of a roster: the names and keys of friends kept up to date. */
|
|
110
|
+
heard(members: RelayPublicIdentity[]): void;
|
|
111
|
+
/** Friends of the user's other computer, with those of this Ta (a move, sync). */
|
|
112
|
+
merge(friends: RelayFriend[]): number;
|
|
113
|
+
/** Those the user chose, for the user's other computers. */
|
|
114
|
+
chosen(): RelayFriend[];
|
|
115
|
+
/** Something changed in the rooms: friends are made both ways, let in and let go of, once it settles. */
|
|
116
|
+
changed(): void;
|
|
117
|
+
/** The user changed the friends: pages read them again, and the rooms follow. */
|
|
118
|
+
protected updated(): void;
|
|
119
|
+
protected reconcile(): Promise<void>;
|
|
120
|
+
/** No longer friends with `id`: out of the user's room, and the user out of theirs (forgotten when gone). */
|
|
121
|
+
protected unfollow(id: string): Promise<void>;
|
|
122
|
+
protected mine(): RelayRoomInfo | undefined;
|
|
123
|
+
protected theirs(rooms: RelayRoomInfo[], id: string): RelayRoomInfo | undefined;
|
|
124
|
+
/** The user chose this one: kept, with its keys when known. */
|
|
125
|
+
protected choose(person: Pick<RelayPublicIdentity, 'id' | 'name'> & Partial<RelayPublicIdentity>): void;
|
|
126
|
+
protected read(): Book;
|
|
127
|
+
protected write(book: Book): void;
|
|
128
|
+
/** One after another: each reads what the one before wrote. */
|
|
129
|
+
protected serial<T>(run: () => Promise<T>): Promise<T>;
|
|
130
|
+
}
|
|
131
|
+
export declare namespace RelayFriendsUtil {
|
|
132
|
+
/** The kind of a room or link of friends, as it is now or was. */
|
|
133
|
+
function isKind(kind: string | undefined): boolean;
|
|
134
|
+
/** The kind a room of friends goes by, whatever it was made as. */
|
|
135
|
+
function kindOf(kind: string): string;
|
|
136
|
+
function isFriend(friend: unknown): friend is RelayFriend;
|
|
137
|
+
/** What is kept of a friend: its identity and when, nothing else a bundle of before held. */
|
|
138
|
+
function clean(friend: RelayFriend): RelayFriend;
|
|
139
|
+
function mergeFriend(local: RelayFriend, other: RelayFriend): RelayFriend;
|
|
140
|
+
function requestOf(offer: Offer): RelayFriendRequest;
|
|
141
|
+
/** `friends.json` as it is now: those of before kept only if they were Moments friends (see migrate). */
|
|
142
|
+
function book(value: unknown): Book;
|
|
143
|
+
/**
|
|
144
|
+
* Friends as they were before (2026-11-16): everyone met in a room was a "Ta friend", and Moments kept friends of
|
|
145
|
+
* its own in rooms of kind `ta-moments`. Now the rooms of Moments are the rooms of friends, and the friends are
|
|
146
|
+
* those whose room the user is in (both chose each other); the others met in rooms are no longer friends. Undefined
|
|
147
|
+
* when there is nothing to do.
|
|
148
|
+
*/
|
|
149
|
+
function migrate(records: RelayRoomRecord[], stored: unknown): {
|
|
150
|
+
records: RelayRoomRecord[];
|
|
151
|
+
book: Book;
|
|
152
|
+
} | undefined;
|
|
153
|
+
}
|
|
154
|
+
export {};
|