@celljs/ta-relay 4.16.0 → 4.17.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/esm/common/index.d.ts +1 -0
- package/esm/common/index.js +1 -0
- package/esm/common/relay-content.d.ts +13 -0
- package/esm/common/relay-content.js +42 -0
- package/esm/common/relay-conversation.d.ts +14 -0
- package/esm/common/relay-hub.js +2 -2
- package/esm/common/relay-hubs-identity.d.ts +36 -0
- package/esm/common/relay-hubs-identity.js +156 -0
- package/esm/common/relay-hubs-protocol.d.ts +4 -0
- package/esm/common/relay-hubs-util.d.ts +11 -0
- package/esm/common/relay-hubs-util.js +74 -0
- package/esm/common/relay-hubs.d.ts +17 -44
- package/esm/common/relay-hubs.js +37 -235
- package/esm/common/relay-protocol.d.ts +9 -0
- package/esm/common/relay-protocol.js +13 -0
- package/esm/common/relay-spot.d.ts +15 -3
- package/esm/common/relay-spot.js +17 -5
- package/esm/node/index.d.ts +1 -0
- package/esm/node/index.js +1 -0
- package/esm/node/relay-memory-storage.d.ts +26 -0
- package/esm/node/relay-memory-storage.js +60 -0
- package/esm/node/relay-server.d.ts +14 -26
- package/esm/node/relay-server.js +33 -60
- package/esm/node/relay-store.js +4 -4
- package/esm/node/relays-file.d.ts +27 -0
- package/esm/node/relays-file.js +59 -4
- package/esm/viewer/viewer.js +33 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/relay-content.d.ts +13 -0
- package/lib/common/relay-content.js +43 -1
- package/lib/common/relay-conversation.d.ts +14 -0
- package/lib/common/relay-hub.js +1 -1
- package/lib/common/relay-hubs-identity.d.ts +37 -0
- package/lib/common/relay-hubs-identity.js +160 -0
- package/lib/common/relay-hubs-protocol.d.ts +4 -0
- package/lib/common/relay-hubs-util.d.ts +12 -0
- package/lib/common/relay-hubs-util.js +77 -0
- package/lib/common/relay-hubs.d.ts +17 -44
- package/lib/common/relay-hubs.js +36 -234
- package/lib/common/relay-protocol.d.ts +9 -0
- package/lib/common/relay-protocol.js +15 -1
- package/lib/common/relay-spot.d.ts +15 -3
- package/lib/common/relay-spot.js +17 -5
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/relay-memory-storage.d.ts +27 -0
- package/lib/node/relay-memory-storage.js +65 -0
- package/lib/node/relay-server.d.ts +14 -26
- package/lib/node/relay-server.js +34 -61
- package/lib/node/relay-store.js +3 -3
- package/lib/node/relays-file.d.ts +27 -0
- package/lib/node/relays-file.js +58 -3
- package/lib/viewer/viewer.js +32 -0
- package/package.json +3 -2
- package/viewer/join.html +3 -3
- package/viewer/page.html +9 -9
- package/viewer/room.html +10 -10
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelayHubsIdentity = void 0;
|
|
4
|
+
const relay_hubs_connection_1 = require("./relay-hubs-connection");
|
|
5
|
+
const relay_hubs_util_1 = require("./relay-hubs-util");
|
|
6
|
+
const relay_identity_1 = require("./relay-identity");
|
|
7
|
+
class RelayHubsIdentity extends relay_hubs_connection_1.RelayHubsConnection {
|
|
8
|
+
/** The name others see; the owners of rooms this Ta is in hear it. */
|
|
9
|
+
async setName(name) {
|
|
10
|
+
const trimmed = String(name).trim().slice(0, 40);
|
|
11
|
+
if (!trimmed) {
|
|
12
|
+
throw new Error('A name is needed.');
|
|
13
|
+
}
|
|
14
|
+
return this.changeSelf({ ...(await this.identity()), name: trimmed });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The kind of dinosaur the double of this Ta is (RelayPublicIdentity.look), which others draw it by; none for a
|
|
18
|
+
* look that is none. The owners of rooms this Ta is in hear it, as a name.
|
|
19
|
+
*/
|
|
20
|
+
async setLook(look) {
|
|
21
|
+
const identity = await this.identity();
|
|
22
|
+
const next = relay_identity_1.RelayIdentityUtil.withLook(identity, look);
|
|
23
|
+
return next.look === identity.look ? relay_identity_1.RelayIdentityUtil.publicOf(identity) : this.changeSelf(next);
|
|
24
|
+
}
|
|
25
|
+
/** Keeps the identity with a new name or look, and tells the rooms this Ta is in. */
|
|
26
|
+
async changeSelf(identity) {
|
|
27
|
+
var _a;
|
|
28
|
+
this.options.store.write('identity', identity);
|
|
29
|
+
this.own = identity;
|
|
30
|
+
for (const live of this.live.values()) {
|
|
31
|
+
// A room joined with another identity keeps that one's name.
|
|
32
|
+
if (live.record.status !== 'member' || live.record.identity) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (live.record.own) {
|
|
36
|
+
await this.writeRoster(live, members => members.map(member => (member.id === identity.id ? relay_identity_1.RelayIdentityUtil.withLook({ ...member, name: identity.name }, identity.look) : member))).catch(() => undefined);
|
|
37
|
+
}
|
|
38
|
+
else if (live.roster) {
|
|
39
|
+
const owner = live.roster.members.find(member => member.owner);
|
|
40
|
+
if (owner) {
|
|
41
|
+
const look = (_a = identity.look) !== null && _a !== void 0 ? _a : '';
|
|
42
|
+
await this.sendBody(live, { name: identity.name, look }, owner.member).then(() => {
|
|
43
|
+
live.toldLook = look;
|
|
44
|
+
}, () => undefined);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return relay_identity_1.RelayIdentityUtil.publicOf(identity);
|
|
49
|
+
}
|
|
50
|
+
/** What makes this Ta who it is in rooms, private keys and all (RelayIdentityBundle): for the user's own computers alone. */
|
|
51
|
+
async exportIdentity() {
|
|
52
|
+
return { identity: await this.identity(), rooms: [...this.live.values()].map(live => live.record), friends: this.book.chosen() };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Takes on the identity of the user's other computer, with its rooms and friends (a move, or the identity shared by
|
|
56
|
+
* sync). Another identity than this Ta's: each room this Ta is in keeps the identity it joined with
|
|
57
|
+
* (RelayRoomRecord.identity), new rooms are the other's. A room this Ta is in as another member is left as it is.
|
|
58
|
+
*/
|
|
59
|
+
async importIdentity(bundle, options = {}) {
|
|
60
|
+
const incoming = bundle === null || bundle === void 0 ? void 0 : bundle.identity;
|
|
61
|
+
if (!relay_hubs_util_1.RelayHubsUtil.isPrivate(incoming) || !(await relay_identity_1.RelayIdentityUtil.check(incoming))) {
|
|
62
|
+
throw new Error('Not an identity of Ta.');
|
|
63
|
+
}
|
|
64
|
+
const own = await this.identity();
|
|
65
|
+
const switched = incoming.id !== own.id;
|
|
66
|
+
if (switched) {
|
|
67
|
+
for (const live of this.live.values()) {
|
|
68
|
+
if (!live.record.identity) {
|
|
69
|
+
live.record = { ...live.record, identity: own };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const shared = options.shared || own.shared;
|
|
74
|
+
const next = { ...(switched ? incoming : own), ...(shared ? { shared: true } : {}) };
|
|
75
|
+
if (!shared) {
|
|
76
|
+
delete next.shared;
|
|
77
|
+
}
|
|
78
|
+
this.own = next;
|
|
79
|
+
this.options.store.write('identity', next);
|
|
80
|
+
let rooms = 0;
|
|
81
|
+
for (const record of Array.isArray(bundle.rooms) ? bundle.rooms : []) {
|
|
82
|
+
if (this.upsert(record)) {
|
|
83
|
+
rooms++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const friends = this.book.merge(Array.isArray(bundle.friends) ? bundle.friends : []);
|
|
87
|
+
this.save();
|
|
88
|
+
this.emit({ type: 'rooms' });
|
|
89
|
+
return { switched, rooms, friends };
|
|
90
|
+
}
|
|
91
|
+
/** Whether the user's other computers are this Ta too (RelayIdentity.shared). */
|
|
92
|
+
async setShared(shared) {
|
|
93
|
+
const identity = { ...(await this.identity()) };
|
|
94
|
+
if (!!identity.shared === shared) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (shared) {
|
|
98
|
+
identity.shared = true;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
delete identity.shared;
|
|
102
|
+
}
|
|
103
|
+
this.own = identity;
|
|
104
|
+
this.options.store.write('identity', identity);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A room as the user's other computer has it: added, or merged with this Ta's record of the same membership
|
|
108
|
+
* (RelayHubsUtil.merge), connected or not as its status says. False when nothing changed, or this Ta is in the room
|
|
109
|
+
* as another member.
|
|
110
|
+
*/
|
|
111
|
+
upsert(record) {
|
|
112
|
+
if (!relay_hubs_util_1.RelayHubsUtil.isRecord(record)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const live = this.live.get(record.id);
|
|
116
|
+
if (!live) {
|
|
117
|
+
const added = new relay_hubs_connection_1.Live({ ...record });
|
|
118
|
+
this.live.set(record.id, added);
|
|
119
|
+
if (record.status === 'member' || record.status === 'waiting') {
|
|
120
|
+
this.connect(added);
|
|
121
|
+
}
|
|
122
|
+
this.save();
|
|
123
|
+
this.emit({ type: 'rooms' });
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
if (live.record.member !== record.member) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const merged = relay_hubs_util_1.RelayHubsUtil.merge(live.record, record);
|
|
130
|
+
if (JSON.stringify(merged) === JSON.stringify(live.record)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const was = live.record.status;
|
|
134
|
+
live.record = merged;
|
|
135
|
+
if (merged.status !== 'member' && merged.status !== 'waiting') {
|
|
136
|
+
this.disconnect(live);
|
|
137
|
+
}
|
|
138
|
+
else if (was !== merged.status || !live.socket) {
|
|
139
|
+
this.disconnect(live);
|
|
140
|
+
this.connect(live);
|
|
141
|
+
}
|
|
142
|
+
this.save();
|
|
143
|
+
this.emit({ type: 'rooms' });
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
/** A room the user's other computer left or forgot: forgotten here, without a word to the relay (that computer said it). */
|
|
147
|
+
forget(roomId, member) {
|
|
148
|
+
const live = this.live.get(roomId);
|
|
149
|
+
if (!live || live.record.member !== member) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
this.disconnect(live);
|
|
153
|
+
this.live.delete(roomId);
|
|
154
|
+
this.save();
|
|
155
|
+
this.emit({ type: 'rooms' });
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.RelayHubsIdentity = RelayHubsIdentity;
|
|
160
|
+
//# sourceMappingURL=relay-hubs-identity.js.map
|
|
@@ -28,6 +28,8 @@ export interface RelayRoomRecord {
|
|
|
28
28
|
}[];
|
|
29
29
|
/** Of the owner: the relay has the room. */
|
|
30
30
|
made?: boolean;
|
|
31
|
+
/** Of the owner: the members it lets in at most, when not RELAY_ROOM_MAX_MEMBERS (RelayHubs.configure). */
|
|
32
|
+
capacity?: number;
|
|
31
33
|
/** Of one asking: the invitation, till the relay has the ask. */
|
|
32
34
|
invite?: string;
|
|
33
35
|
asked?: boolean;
|
|
@@ -73,6 +75,8 @@ export interface RelayRoomInfo {
|
|
|
73
75
|
/** The relay it is on. */
|
|
74
76
|
relay: string;
|
|
75
77
|
owner: boolean;
|
|
78
|
+
/** Of a room this Ta made: the members it lets in at most. */
|
|
79
|
+
capacity?: number;
|
|
76
80
|
ownerName: string;
|
|
77
81
|
status: RelayRoomStatus;
|
|
78
82
|
reason?: RelayRoomRecord['reason'];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RelayRoomRecord } from './relay-hubs-protocol';
|
|
2
|
+
import type { RelayIdentity } from './relay-identity';
|
|
3
|
+
export declare namespace RelayHubsUtil {
|
|
4
|
+
function isPrivate(identity: unknown): identity is RelayIdentity;
|
|
5
|
+
function isRecord(record: unknown): record is RelayRoomRecord;
|
|
6
|
+
/**
|
|
7
|
+
* Two records of one membership, as two computers of the user hold it: the further status (one heard it end), the
|
|
8
|
+
* key and the owner's keys once either has them, the invitations of both, made once either made it.
|
|
9
|
+
*/
|
|
10
|
+
function merge(local: RelayRoomRecord, other: RelayRoomRecord): RelayRoomRecord;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=relay-hubs-util.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelayHubsUtil = void 0;
|
|
4
|
+
/** How far a membership has come: one computer heard it end, it ended for both. */
|
|
5
|
+
const STATUS_RANK = { waiting: 0, member: 1, refused: 2, gone: 3 };
|
|
6
|
+
var RelayHubsUtil;
|
|
7
|
+
(function (RelayHubsUtil) {
|
|
8
|
+
function isPrivate(identity) {
|
|
9
|
+
const value = identity;
|
|
10
|
+
return (!!value &&
|
|
11
|
+
typeof value.id === 'string' &&
|
|
12
|
+
typeof value.name === 'string' &&
|
|
13
|
+
typeof value.sign === 'string' &&
|
|
14
|
+
typeof value.box === 'string' &&
|
|
15
|
+
!!value.signKey &&
|
|
16
|
+
typeof value.signKey === 'object' &&
|
|
17
|
+
!!value.boxKey &&
|
|
18
|
+
typeof value.boxKey === 'object');
|
|
19
|
+
}
|
|
20
|
+
RelayHubsUtil.isPrivate = isPrivate;
|
|
21
|
+
function isRecord(record) {
|
|
22
|
+
const value = record;
|
|
23
|
+
return (!!value &&
|
|
24
|
+
typeof value.id === 'string' &&
|
|
25
|
+
typeof value.relay === 'string' &&
|
|
26
|
+
typeof value.member === 'string' &&
|
|
27
|
+
typeof value.token === 'string' &&
|
|
28
|
+
typeof value.status === 'string' &&
|
|
29
|
+
value.status in STATUS_RANK &&
|
|
30
|
+
!!value.owner &&
|
|
31
|
+
typeof value.owner.id === 'string' &&
|
|
32
|
+
(value.identity === undefined || isPrivate(value.identity)));
|
|
33
|
+
}
|
|
34
|
+
RelayHubsUtil.isRecord = isRecord;
|
|
35
|
+
/**
|
|
36
|
+
* Two records of one membership, as two computers of the user hold it: the further status (one heard it end), the
|
|
37
|
+
* key and the owner's keys once either has them, the invitations of both, made once either made it.
|
|
38
|
+
*/
|
|
39
|
+
function merge(local, other) {
|
|
40
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41
|
+
const ahead = STATUS_RANK[other.status] > STATUS_RANK[local.status] ? other : local;
|
|
42
|
+
const behind = ahead === local ? other : local;
|
|
43
|
+
const invites = [...((_a = local.invites) !== null && _a !== void 0 ? _a : []), ...((_b = other.invites) !== null && _b !== void 0 ? _b : [])]
|
|
44
|
+
.filter((invite, index, all) => all.findIndex(each => each.secret === invite.secret) === index)
|
|
45
|
+
.sort((a, b) => a.expiresAt - b.expiresAt)
|
|
46
|
+
.slice(-3);
|
|
47
|
+
const merged = {
|
|
48
|
+
...behind,
|
|
49
|
+
...ahead,
|
|
50
|
+
kind: ahead.kind || behind.kind,
|
|
51
|
+
owner: ahead.owner.sign ? ahead.owner : behind.owner.sign ? behind.owner : ahead.owner,
|
|
52
|
+
createdAt: Math.min(local.createdAt, other.createdAt),
|
|
53
|
+
};
|
|
54
|
+
const key = (_c = ahead.key) !== null && _c !== void 0 ? _c : behind.key;
|
|
55
|
+
const joinedAt = Math.max((_d = local.joinedAt) !== null && _d !== void 0 ? _d : 0, (_e = other.joinedAt) !== null && _e !== void 0 ? _e : 0);
|
|
56
|
+
const identity = (_f = local.identity) !== null && _f !== void 0 ? _f : other.identity;
|
|
57
|
+
delete merged.key;
|
|
58
|
+
delete merged.invites;
|
|
59
|
+
delete merged.joinedAt;
|
|
60
|
+
delete merged.identity;
|
|
61
|
+
delete merged.made;
|
|
62
|
+
if (merged.status !== 'waiting') {
|
|
63
|
+
delete merged.invite;
|
|
64
|
+
delete merged.asked;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...merged,
|
|
68
|
+
...(key && (merged.status === 'member' || merged.status === 'waiting') ? { key } : {}),
|
|
69
|
+
...(invites.length ? { invites } : {}),
|
|
70
|
+
...(local.made || other.made ? { made: true } : {}),
|
|
71
|
+
...(joinedAt ? { joinedAt } : {}),
|
|
72
|
+
...(identity ? { identity } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
RelayHubsUtil.merge = merge;
|
|
76
|
+
})(RelayHubsUtil || (exports.RelayHubsUtil = RelayHubsUtil = {}));
|
|
77
|
+
//# sourceMappingURL=relay-hubs-util.js.map
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import { RelayFriends } from './relay-friends';
|
|
2
2
|
import { type RelayHubAskBody } from './relay-hub-util';
|
|
3
|
-
import { Live
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { Live } from './relay-hubs-connection';
|
|
4
|
+
import { RelayHubsIdentity } from './relay-hubs-identity';
|
|
5
|
+
import type { RelayFriend, RelayFriendInfo, RelayFriendRequest, RelayRoomEvent, RelayRoomInfo, RelayRoomRequest, RelayRoomValue } from './relay-hubs-protocol';
|
|
6
|
+
import { type RelayPublicIdentity } from './relay-identity';
|
|
6
7
|
/**
|
|
7
8
|
* The rooms of this Ta (docs/design/ta-link.md 3): its identity and friends, the rooms it made or asked to join,
|
|
8
9
|
* and a connection to the hub of each while it runs, through which it sends, sets the shared state and hears
|
|
9
10
|
* the others; every message signed by its member and sealed with the key of the room. The friends are a room of
|
|
10
11
|
* their own (RelayFriends).
|
|
11
12
|
*/
|
|
12
|
-
export declare class RelayHubs extends
|
|
13
|
+
export declare class RelayHubs extends RelayHubsIdentity {
|
|
13
14
|
protected readonly book: RelayFriends;
|
|
14
15
|
/** Connects to the rooms of rooms.json, and keeps connected. */
|
|
15
16
|
start(): void;
|
|
16
17
|
stop(): void;
|
|
17
18
|
onEvent(listener: (event: RelayRoomEvent) => void): () => void;
|
|
18
|
-
/** The name others see; the owners of rooms this Ta is in hear it. */
|
|
19
|
-
setName(name: string): Promise<RelayPublicIdentity>;
|
|
20
|
-
/**
|
|
21
|
-
* The kind of dinosaur the double of this Ta is (RelayPublicIdentity.look), which others draw it by; none for a
|
|
22
|
-
* look that is none. The owners of rooms this Ta is in hear it, as a name.
|
|
23
|
-
*/
|
|
24
|
-
setLook(look: string | undefined): Promise<RelayPublicIdentity>;
|
|
25
|
-
/** Keeps the identity with a new name or look, and tells the rooms this Ta is in. */
|
|
26
|
-
protected changeSelf(identity: RelayIdentity): Promise<RelayPublicIdentity>;
|
|
27
19
|
list(): RelayRoomInfo[];
|
|
28
20
|
room(id: string): RelayRoomInfo | undefined;
|
|
29
21
|
create(input: {
|
|
@@ -35,7 +27,7 @@ export declare class RelayHubs extends RelayHubsConnection {
|
|
|
35
27
|
}): Promise<RelayRoomInfo>;
|
|
36
28
|
/**
|
|
37
29
|
* The link that lets others ask to join: the one of before while it has a day left, else (or with `renew`) a new
|
|
38
|
-
* one for `days` (7 by default,
|
|
30
|
+
* one for `days` (7 by default, RELAY_INVITE_MAX_DAYS at most), the links of before no longer working.
|
|
39
31
|
*/
|
|
40
32
|
invite(roomId: string, options?: {
|
|
41
33
|
days?: number;
|
|
@@ -44,12 +36,22 @@ export declare class RelayHubs extends RelayHubsConnection {
|
|
|
44
36
|
link: string;
|
|
45
37
|
expiresAt: number;
|
|
46
38
|
}>;
|
|
47
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Asks to join the room of a link: the owner answers (`waiting` till then). The room of before, if this Ta has it.
|
|
41
|
+
* A room the identity owns on the user's other computer (an identity shared or moved) is joined as any other.
|
|
42
|
+
*/
|
|
48
43
|
join(text: string): Promise<RelayRoomInfo>;
|
|
49
44
|
/** Those asking to join the rooms of this Ta, the earliest first. */
|
|
50
45
|
requests(): Promise<RelayRoomRequest[]>;
|
|
51
46
|
/** The user's answer to one asking to join: admitted, it gets the key of the room and is in the roster. */
|
|
52
47
|
answer(roomId: string, askId: string, accept: boolean): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* The owner's choices for a room: how many members it lets in at most (RELAY_ROOM_MAX_MEMBERS by default, 2 to
|
|
50
|
+
* RELAY_ROOM_CAPACITY_MAX), for one many come to (feedback from a browser). Those in already stay.
|
|
51
|
+
*/
|
|
52
|
+
configure(roomId: string, options: {
|
|
53
|
+
members?: number;
|
|
54
|
+
}): RelayRoomInfo;
|
|
53
55
|
/** The owner takes a member out: the relay closes it at once. */
|
|
54
56
|
remove(roomId: string, member: string): Promise<void>;
|
|
55
57
|
/** Leaves the room; the owner closes it, for everyone. A room asked to join is forgotten. */
|
|
@@ -66,26 +68,6 @@ export declare class RelayHubs extends RelayHubsConnection {
|
|
|
66
68
|
ok: boolean;
|
|
67
69
|
version: number;
|
|
68
70
|
}>;
|
|
69
|
-
/** What makes this Ta who it is in rooms, private keys and all (RelayIdentityBundle): for the user's own computers alone. */
|
|
70
|
-
exportIdentity(): Promise<RelayIdentityBundle>;
|
|
71
|
-
/**
|
|
72
|
-
* Takes on the identity of the user's other computer, with its rooms and friends (a move, or the identity shared by
|
|
73
|
-
* sync). Another identity than this Ta's: each room this Ta is in keeps the identity it joined with
|
|
74
|
-
* (RelayRoomRecord.identity), new rooms are the other's. A room this Ta is in as another member is left as it is.
|
|
75
|
-
*/
|
|
76
|
-
importIdentity(bundle: RelayIdentityBundle, options?: {
|
|
77
|
-
shared?: boolean;
|
|
78
|
-
}): Promise<RelayIdentityImport>;
|
|
79
|
-
/** Whether the user's other computers are this Ta too (RelayIdentity.shared). */
|
|
80
|
-
setShared(shared: boolean): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* A room as the user's other computer has it: added, or merged with this Ta's record of the same membership
|
|
83
|
-
* (RelayHubsUtil.merge), connected or not as its status says. False when nothing changed, or this Ta is in the room
|
|
84
|
-
* as another member.
|
|
85
|
-
*/
|
|
86
|
-
upsert(record: RelayRoomRecord): boolean;
|
|
87
|
-
/** A room the user's other computer left or forgot: forgotten here, without a word to the relay (that computer said it). */
|
|
88
|
-
forget(roomId: string, member: string): boolean;
|
|
89
71
|
/** Friends of the user's other computer, with those of this Ta. */
|
|
90
72
|
mergeFriends(friends: RelayFriend[]): number;
|
|
91
73
|
/** The friends, with their keys: each in the room of the other (shares to friends are sealed for them). */
|
|
@@ -119,13 +101,4 @@ export declare class RelayHubs extends RelayHubsConnection {
|
|
|
119
101
|
protected member(roomId: string): Live;
|
|
120
102
|
protected info(live: Live): RelayRoomInfo;
|
|
121
103
|
}
|
|
122
|
-
export declare namespace RelayHubsUtil {
|
|
123
|
-
function isPrivate(identity: unknown): identity is RelayIdentity;
|
|
124
|
-
function isRecord(record: unknown): record is RelayRoomRecord;
|
|
125
|
-
/**
|
|
126
|
-
* Two records of one membership, as two computers of the user hold it: the further status (one heard it end), the
|
|
127
|
-
* key and the owner's keys once either has them, the invitations of both, made once either made it.
|
|
128
|
-
*/
|
|
129
|
-
function merge(local: RelayRoomRecord, other: RelayRoomRecord): RelayRoomRecord;
|
|
130
|
-
}
|
|
131
104
|
//# sourceMappingURL=relay-hubs.d.ts.map
|