p2party 0.6.15
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/LICENSE.md +661 -0
- package/README.md +417 -0
- package/lib/api/signalingServerApi.d.ts +19 -0
- package/lib/api/webrtc/baseQuery.d.ts +11 -0
- package/lib/api/webrtc/baseQuery.d.ts.map +1 -0
- package/lib/api/webrtc/disconnectFromAllRoomsQuery.d.ts +9 -0
- package/lib/api/webrtc/disconnectFromAllRoomsQuery.d.ts.map +1 -0
- package/lib/api/webrtc/disconnectFromChannelLabelQuery.d.ts +8 -0
- package/lib/api/webrtc/disconnectFromChannelLabelQuery.d.ts.map +1 -0
- package/lib/api/webrtc/disconnectFromPeerChannelLabelQuery.d.ts +9 -0
- package/lib/api/webrtc/disconnectFromPeerChannelLabelQuery.d.ts.map +1 -0
- package/lib/api/webrtc/disconnectFromPeerQuery.d.ts +9 -0
- package/lib/api/webrtc/disconnectFromPeerQuery.d.ts.map +1 -0
- package/lib/api/webrtc/disconnectFromRoomQuery.d.ts +9 -0
- package/lib/api/webrtc/disconnectFromRoomQuery.d.ts.map +1 -0
- package/lib/api/webrtc/disconnectQuery.d.ts +9 -0
- package/lib/api/webrtc/disconnectQuery.d.ts.map +1 -0
- package/lib/api/webrtc/index.d.ts +19 -0
- package/lib/api/webrtc/index.d.ts.map +1 -0
- package/lib/api/webrtc/interfaces.d.ts +101 -0
- package/lib/api/webrtc/interfaces.d.ts.map +1 -0
- package/lib/api/webrtc/openChannelQuery.d.ts +11 -0
- package/lib/api/webrtc/openChannelQuery.d.ts.map +1 -0
- package/lib/api/webrtc/sendMessageQuery.d.ts +12 -0
- package/lib/api/webrtc/sendMessageQuery.d.ts.map +1 -0
- package/lib/api/webrtc/setCandidateQuery.d.ts +9 -0
- package/lib/api/webrtc/setCandidateQuery.d.ts.map +1 -0
- package/lib/api/webrtc/setDescriptionQuery.d.ts +12 -0
- package/lib/api/webrtc/setDescriptionQuery.d.ts.map +1 -0
- package/lib/cryptography/chacha20poly1305.d.ts +116 -0
- package/lib/cryptography/ed25519.d.ts +12 -0
- package/lib/cryptography/hasher.d.ts +11 -0
- package/lib/cryptography/interfaces.d.ts +40 -0
- package/lib/cryptography/memory.d.ts +15 -0
- package/lib/cryptography/merkle.d.ts +43 -0
- package/lib/cryptography/mnemonic.d.ts +30 -0
- package/lib/cryptography/utils.d.ts +13 -0
- package/lib/db/api.d.ts +35 -0
- package/lib/db/db.worker.d.ts +2 -0
- package/lib/db/src/getDB.d.ts +68 -0
- package/lib/db/src/getDB.d.ts.map +1 -0
- package/lib/db/types.d.ts +234 -0
- package/lib/db.worker.js +2 -0
- package/lib/handlers/handleChallenge.d.ts +5 -0
- package/lib/handlers/handleConnectToPeer.d.ts +4 -0
- package/lib/handlers/handleOpenChannel.d.ts +15 -0
- package/lib/handlers/handleQueuedIceCandidates.d.ts +3 -0
- package/lib/handlers/handleReadReceipt.d.ts +5 -0
- package/lib/handlers/handleReceiveMessage.d.ts +16 -0
- package/lib/handlers/handleSendMessage.d.ts +6 -0
- package/lib/handlers/handleSendMessageWebsocket.d.ts +4 -0
- package/lib/handlers/handleWebSocketMessage.d.ts +7 -0
- package/lib/index.d.ts +202 -0
- package/lib/index.js +2 -0
- package/lib/index.min.js +2 -0
- package/lib/index.mjs +2 -0
- package/lib/middleware/keyPairListenerMiddleware.d.ts +3 -0
- package/lib/middleware/roomListenerMiddleware.d.ts +3 -0
- package/lib/reducers/commonSlice.d.ts +9 -0
- package/lib/reducers/keyPairSlice.d.ts +33 -0
- package/lib/reducers/roomSlice.d.ts +113 -0
- package/lib/reducers/signalingServerSlice.d.ts +16 -0
- package/lib/store.d.ts +55 -0
- package/lib/utils/channelLabel.d.ts +12 -0
- package/lib/utils/interfaces.d.ts +138 -0
- package/lib/utils/mediasource.d.ts +2 -0
- package/lib/utils/messageTypes.d.ts +88 -0
- package/lib/utils/metadata.d.ts +17 -0
- package/lib/utils/splitToChunks.d.ts +29 -0
- package/lib/utils/uint8array.d.ts +21 -0
- package/package.json +115 -0
package/README.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# p2party-js
|
|
2
|
+
|
|
3
|
+
<!-- [![codecov][codecov-image]][codecov-url] -->
|
|
4
|
+
|
|
5
|
+
[](https://snyk.io/test/github/p2party/p2party-js?targetFile=package.json)
|
|
6
|
+
<br>
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
|
|
10
|
+
<br>
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
<!-- [](https://www.jsdelivr.com/package/npm/@deliberative/crypto) -->
|
|
14
|
+
|
|
15
|
+
<!-- [codecov-image]: https://codecov.io/gh/deliberative/crypto/branch/master/graph/badge.svg -->
|
|
16
|
+
<!-- [codecov-url]: https://codecov.io/gh/deliberative/crypto -->
|
|
17
|
+
|
|
18
|
+
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
|
|
19
|
+
[code-style-prettier-url]: https://github.com/prettier/prettier
|
|
20
|
+
|
|
21
|
+
> Peer-to-peer WebRTC mesh communication with offensive cryptographic encoding.
|
|
22
|
+
|
|
23
|
+
**p2party** connects peers visiting the same URL into a WebRTC mesh network and enables secure, chunked message exchange over ephemeral data channels. Unlike traditional privacy libraries, `p2party` actively obfuscates traffic using randomized padding and byte-level noise, making message signatures indistinguishable and message intent opaque. Of course it also adds a layer of ChaChaPoly1305 end-to-end encryption.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Disclaimer
|
|
28
|
+
|
|
29
|
+
The API is not completely stable and the code has not undergone external security audits. Use at your own risk.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- 📡 Auto-connect peers based on shared URLs
|
|
34
|
+
- 🔀 WebRTC mesh topology (no central servers except for signaling and STUN/TURN)
|
|
35
|
+
- 🔐 Offensive cryptography: every message can be split in multiple 64KB chunks so the attacker needs to store a lot of useless info
|
|
36
|
+
- 🧩 Supports `File` and `string` messages via chunked encoding
|
|
37
|
+
- 🧠 Built-in address book, blacklist, and room memory, all stored in the browser's IndexedDB
|
|
38
|
+
- 🛠 Easy API and integration with React via custom hooks
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Dependencies
|
|
43
|
+
|
|
44
|
+
This library relies heavily on [libsodium](https://github.com/jedisct1/libsodium) for cryptographic operations, which is a battle-tested project, compiled to WebAssembly for speed.
|
|
45
|
+
|
|
46
|
+
The library offers mnemonic generation, validation and Ed25519 key pair from mnemonic functionality that was inspired by [bip39](https://github.com/bitcoinjs/bip39) but instead of Blake2b we use Argon2 and instead of SHA256 we use SHA512, both of which can be found in libsodium.
|
|
47
|
+
|
|
48
|
+
On the js side, the library depends on [Redux](https://githun.com/redux) for state management,
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install p2party
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
The official website [p2party.com](https://p2party.com), which is an SPA written in React, consumes the library with a hook in the following way:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import p2party from "p2party";
|
|
62
|
+
|
|
63
|
+
import { useState } from "react";
|
|
64
|
+
import { useNavigate } from "react-router";
|
|
65
|
+
import { useSelector } from "react-redux";
|
|
66
|
+
|
|
67
|
+
import type { Message } from "p2party";
|
|
68
|
+
|
|
69
|
+
export interface MessageWithData extends Message {
|
|
70
|
+
data: string | File;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const useRoom = () => {
|
|
74
|
+
const navigate = useNavigate();
|
|
75
|
+
|
|
76
|
+
const [roomIndex, setRoomIndex] = useState(-1);
|
|
77
|
+
const keyPair = useSelector(p2party.keyPairSelector);
|
|
78
|
+
const rooms = useSelector(p2party.roomSelector);
|
|
79
|
+
const signalingServerConnection = useSelector(
|
|
80
|
+
p2party.signalingServerSelector,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const goToRandomRoom = async (replace = false) => {
|
|
84
|
+
const random = await p2party.generateRandomRoomUrl();
|
|
85
|
+
navigate("/rooms/" + random, { replace });
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const openChannel = async (name: string) => {
|
|
89
|
+
if (roomIndex === -1) throw new Error("No room was selected");
|
|
90
|
+
|
|
91
|
+
await p2party.openChannel(
|
|
92
|
+
rooms[roomIndex].id,
|
|
93
|
+
name,
|
|
94
|
+
rooms[roomIndex].peers,
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const sendMessage = (message: string | File, channel: string) => {
|
|
99
|
+
if (roomIndex === -1) throw new Error("No room was selected");
|
|
100
|
+
|
|
101
|
+
p2party.sendMessage(
|
|
102
|
+
message,
|
|
103
|
+
channel,
|
|
104
|
+
rooms[roomIndex].id,
|
|
105
|
+
percentageFilledChunk / 100,
|
|
106
|
+
chunks,
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
keyPair,
|
|
112
|
+
peerId: keyPair.peerId,
|
|
113
|
+
signalingServerURL: signalingServerConnection.serverUrl,
|
|
114
|
+
signalingServerConnectionState: signalingServerConnection,
|
|
115
|
+
peers: roomIndex > -1 ? rooms[roomIndex].peers : [],
|
|
116
|
+
channels: roomIndex > -1 ? rooms[roomIndex].channels : [],
|
|
117
|
+
messages: roomIndex > -1 ? rooms[roomIndex].messages : [],
|
|
118
|
+
goToRandomRoom,
|
|
119
|
+
connect: p2party.connect,
|
|
120
|
+
connectToSignalingServer: p2party.connectToSignalingServer,
|
|
121
|
+
disconnect: p2party.disconnectFromRoom,
|
|
122
|
+
disconnectFromSignalingServer: p2party.disconnectFromSignalingServer,
|
|
123
|
+
disconnectFromRoom: p2party.disconnectFromRoom,
|
|
124
|
+
disconnectFromAllRooms: p2party.disconnectFromAllRooms,
|
|
125
|
+
disconnectFromPeer: p2party.disconnectFromPeer,
|
|
126
|
+
openChannel,
|
|
127
|
+
selectChannel: setSelectedChannel,
|
|
128
|
+
sendMessage,
|
|
129
|
+
readMessage: p2party.readMessage,
|
|
130
|
+
cancelMessage: p2party.cancelMessage,
|
|
131
|
+
deleteMessage: p2party.deleteMessage,
|
|
132
|
+
purge: p2party.purge,
|
|
133
|
+
purgeRoom: p2party.purgeRoom,
|
|
134
|
+
purgeIdentity: p2party.purgeIdentity,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For a complete reference of the API you can check the library output file [index.ts](src/index.ts).
|
|
140
|
+
|
|
141
|
+
The most important functions with their types, which can be called as p2party.fn are:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Connects peer to a room.
|
|
147
|
+
* A room URL is 64 chars long. We use the sha256 of the sha512 of random data.
|
|
148
|
+
*/
|
|
149
|
+
const connect = (
|
|
150
|
+
roomUrl: string,
|
|
151
|
+
signalingServerUrl = "wss://signaling.p2party.com/ws",
|
|
152
|
+
rtcConfig: RTCConfiguration = {
|
|
153
|
+
iceServers: [
|
|
154
|
+
{
|
|
155
|
+
urls: [
|
|
156
|
+
"stun:stun.p2party.com:3478",
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
iceTransportPolicy: "all",
|
|
161
|
+
},
|
|
162
|
+
) => void;
|
|
163
|
+
|
|
164
|
+
const connectToSignalingServer = (
|
|
165
|
+
roomUrl: string,
|
|
166
|
+
signalingServerUrl = "wss://signaling.p2party.com/ws",
|
|
167
|
+
) => void;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* If no toChannel then broadcast the message everywhere to everyone.
|
|
171
|
+
* If toChannel then broadcast to all peers with that channel.
|
|
172
|
+
*/
|
|
173
|
+
const sendMessage = (
|
|
174
|
+
data: string | File,
|
|
175
|
+
toChannel: string,
|
|
176
|
+
roomId: string,
|
|
177
|
+
percentageFilledChunk = 0.9,
|
|
178
|
+
minChunks = 3,
|
|
179
|
+
chunkSize = CHUNK_LEN,
|
|
180
|
+
metadataSchemaVersion = 1,
|
|
181
|
+
) => void;
|
|
182
|
+
|
|
183
|
+
const readMessage = async (
|
|
184
|
+
merkleRootHex?: string,
|
|
185
|
+
hashHex?: string,
|
|
186
|
+
) => Promise<{
|
|
187
|
+
message: string | Blob;
|
|
188
|
+
percentage: number;
|
|
189
|
+
size: number;
|
|
190
|
+
filename: string;
|
|
191
|
+
mimeType: MimeType;
|
|
192
|
+
extension: FileExtension;
|
|
193
|
+
category: string;
|
|
194
|
+
}>;
|
|
195
|
+
|
|
196
|
+
const cancelMessage = async (
|
|
197
|
+
channelLabel: string,
|
|
198
|
+
merkleRoot?: string | Uint8Array,
|
|
199
|
+
hash?: string | Uint8Array,
|
|
200
|
+
) => void;
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
To load all the past room data you call
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const rooms = await p2party.getAllExistingRooms();
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
To load the contents of a private message you can do the following from the react hook:
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
// {{ message }} comes from const { messages } = useRoom();
|
|
214
|
+
const MessageItem: FC<MessageItemProps> = ({ message }) => {
|
|
215
|
+
const [state, setState] = useState<{
|
|
216
|
+
msg: string;
|
|
217
|
+
msgSize: number;
|
|
218
|
+
msgFilename: string;
|
|
219
|
+
msgCategory: string;
|
|
220
|
+
msgPercentage: number;
|
|
221
|
+
msgLoadingText: string;
|
|
222
|
+
msgExtension: FileExtension;
|
|
223
|
+
}>({
|
|
224
|
+
msg: "",
|
|
225
|
+
msgSize: 0,
|
|
226
|
+
msgFilename: "",
|
|
227
|
+
msgCategory: p2party.MessageCategory.Text,
|
|
228
|
+
msgLoadingText: "",
|
|
229
|
+
msgPercentage: 0,
|
|
230
|
+
msgExtension: "",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
const controller = new AbortController();
|
|
235
|
+
|
|
236
|
+
const setMessage = async () => {
|
|
237
|
+
const m = await readMessage(message.merkleRootHex, message.sha512Hex);
|
|
238
|
+
|
|
239
|
+
if (
|
|
240
|
+
message.fromPeerId === peerId &&
|
|
241
|
+
message.totalChunks > 0 &&
|
|
242
|
+
message.chunksCreated < message.totalChunks
|
|
243
|
+
) {
|
|
244
|
+
setState((prevState) => ({
|
|
245
|
+
...prevState,
|
|
246
|
+
msg:
|
|
247
|
+
typeof m.message === "string"
|
|
248
|
+
? m.message
|
|
249
|
+
: m.message
|
|
250
|
+
? URL.createObjectURL(m.message)
|
|
251
|
+
: "",
|
|
252
|
+
msgLoadingText:
|
|
253
|
+
"Split " +
|
|
254
|
+
message.chunksCreated +
|
|
255
|
+
" chunks of " +
|
|
256
|
+
message.totalChunks,
|
|
257
|
+
msgFilename: m.filename,
|
|
258
|
+
msgCategory: m.category,
|
|
259
|
+
msgExtension: m.extension,
|
|
260
|
+
msgPercentage: Math.floor(
|
|
261
|
+
(message.chunksCreated / message.totalChunks) * 100,
|
|
262
|
+
),
|
|
263
|
+
}));
|
|
264
|
+
} else {
|
|
265
|
+
if (m.percentage === 100) {
|
|
266
|
+
setState((prevState) => ({
|
|
267
|
+
...prevState,
|
|
268
|
+
msg:
|
|
269
|
+
typeof m.message === "string"
|
|
270
|
+
? m.message
|
|
271
|
+
: m.message
|
|
272
|
+
? URL.createObjectURL(m.message)
|
|
273
|
+
: "",
|
|
274
|
+
msgSize: m.size,
|
|
275
|
+
msgLoadingText: "",
|
|
276
|
+
msgFilename: m.filename,
|
|
277
|
+
msgCategory: m.category,
|
|
278
|
+
msgExtension: m.extension,
|
|
279
|
+
msgPercentage: m.percentage, // 100,
|
|
280
|
+
}));
|
|
281
|
+
} else {
|
|
282
|
+
setState((prevState) => ({
|
|
283
|
+
...prevState,
|
|
284
|
+
msgSize: m.size,
|
|
285
|
+
msgLoadingText:
|
|
286
|
+
"Received " +
|
|
287
|
+
formatBytes(message.savedSize) +
|
|
288
|
+
" of " +
|
|
289
|
+
formatBytes(message.totalSize),
|
|
290
|
+
msgFilename: m.filename,
|
|
291
|
+
msgCategory: m.category,
|
|
292
|
+
msgExtension: m.extension,
|
|
293
|
+
msgPercentage: m.percentage,
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
setMessage();
|
|
300
|
+
|
|
301
|
+
return () => {
|
|
302
|
+
controller.abort();
|
|
303
|
+
|
|
304
|
+
if (msg.length > 0 && msgCategory !== p2party.MessageCategory.Text)
|
|
305
|
+
URL.revokeObjectURL(msg);
|
|
306
|
+
};
|
|
307
|
+
}, [
|
|
308
|
+
message.merkleRootHex,
|
|
309
|
+
message.sha512Hex,
|
|
310
|
+
message.savedSize,
|
|
311
|
+
message.chunksCreated,
|
|
312
|
+
]);
|
|
313
|
+
|
|
314
|
+
const {
|
|
315
|
+
msg,
|
|
316
|
+
msgSize,
|
|
317
|
+
msgCategory,
|
|
318
|
+
msgPercentage,
|
|
319
|
+
msgExtension,
|
|
320
|
+
msgLoadingText,
|
|
321
|
+
msgFilename,
|
|
322
|
+
} = state;
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<div>
|
|
326
|
+
{msgCategory === p2party.MessageCategory.Text && url.length === 0 && (
|
|
327
|
+
<Text
|
|
328
|
+
className={`text-left tracking-wide break-words whitespace-pre-line ${message.fromPeerId === peerId ? "font-medium text-black dark:font-semibold dark:text-black" : "font-normal text-white dark:text-white"} text-pretty break-words text-clip hyphens-auto antialiased select-text`}
|
|
329
|
+
>
|
|
330
|
+
{msg as string}
|
|
331
|
+
</Text>
|
|
332
|
+
)}
|
|
333
|
+
|
|
334
|
+
{msgCategory === p2party.MessageCategory.Text && url.length > 0 && (
|
|
335
|
+
<Text
|
|
336
|
+
className={`text-left font-semibold tracking-wide text-pretty break-words break-all text-clip hyphens-auto whitespace-normal text-sky-700 underline decoration-sky-400 antialiased select-text dark:font-normal dark:text-sky-400`}
|
|
337
|
+
>
|
|
338
|
+
{msg as string}
|
|
339
|
+
</Text>
|
|
340
|
+
)}
|
|
341
|
+
|
|
342
|
+
{msgCategory !== p2party.MessageCategory.Text && (
|
|
343
|
+
<Text
|
|
344
|
+
className={`text-left tracking-wide break-words whitespace-pre-wrap ${message.fromPeerId === peerId ? "font-medium text-black dark:font-semibold dark:text-black" : "font-normal text-white dark:text-white"} antialiased`}
|
|
345
|
+
>
|
|
346
|
+
{msgFilename}
|
|
347
|
+
</Text>
|
|
348
|
+
)}
|
|
349
|
+
</div>
|
|
350
|
+
);
|
|
351
|
+
};
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
For privacy features like whitelist, blacklist and room purging we have the following APIs:
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
|
|
358
|
+
const purgeIdentity = () => void;
|
|
359
|
+
const purgeRoom = (roomUrl: string) => void;
|
|
360
|
+
const purge = async () => void;
|
|
361
|
+
|
|
362
|
+
const deleteMessage = async (
|
|
363
|
+
merkleRoot?: string | Uint8Array,
|
|
364
|
+
hash?: string | Uint8Array,
|
|
365
|
+
) => void;
|
|
366
|
+
|
|
367
|
+
const addPeerToAddressBook = async (
|
|
368
|
+
username: string,
|
|
369
|
+
peerId: string,
|
|
370
|
+
peerPublicKey: string,
|
|
371
|
+
) => void;
|
|
372
|
+
const onlyAllowConnectionsFromAddressBook = async (
|
|
373
|
+
roomUrl: string,
|
|
374
|
+
onlyAllow: boolean,
|
|
375
|
+
) => void;
|
|
376
|
+
const deletePeerFromAddressBook = async (
|
|
377
|
+
username?: string,
|
|
378
|
+
peerId?: string,
|
|
379
|
+
peerPublicKey?: string,
|
|
380
|
+
) => void;
|
|
381
|
+
const blacklistPeer = async (peerId: string, peerPublicKey: string) => void;
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Development
|
|
386
|
+
|
|
387
|
+
If you want to bundle the library yourselves, you need to have [Emscripten](https://github.com/emscripten-core/emscripten)
|
|
388
|
+
installed on your machine in order to compile the C code into WebAssembly.
|
|
389
|
+
We have the `-s SINGLE_FILE=1` option for the `emcc` compiler, which converts the `wasm` file to a `base64` string
|
|
390
|
+
that will be compiled by the glue js code into a WebAssembly module. This was done for the purpose of interoperability
|
|
391
|
+
and modularity.
|
|
392
|
+
|
|
393
|
+
Clone the repo, download the libsodium submodule and install packages:
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
git clone https://github.com/p2party/p2party-js.git
|
|
397
|
+
cd p2party-js
|
|
398
|
+
git submodule init
|
|
399
|
+
git submodule update
|
|
400
|
+
npm i
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Once you have all the dependencies installed, you can run
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
npm run dist
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
and [Rollup](https://github.com/rollup/rollup) will generate the UMD, ESM and CJS bundles.
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
The source code is licensed under the terms of the Affero General Public License version 3.0 (see [LICENSE](LICENSE)).
|
|
414
|
+
|
|
415
|
+
## Copyright
|
|
416
|
+
|
|
417
|
+
Copyright (C) 2025 Deliberative Technologies P.C.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { WebSocketMessageCandidateSend, WebSocketMessageDescriptionSend, WebSocketMessageChallengeResponse, WebSocketMessageRoomIdRequest, WebSocketMessagePeersRequest, WebSocketMessageConnectionResponse, WebSocketMessagePongResponse, WebSocketMessageMessageSendRequest, WebSocketPeerConnectionParams } from "../utils/interfaces";
|
|
3
|
+
export interface WebSocketParams {
|
|
4
|
+
signalingServerUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export interface WebSocketMessage {
|
|
7
|
+
content: WebSocketMessagePongResponse | WebSocketMessageCandidateSend | WebSocketMessageDescriptionSend | WebSocketMessageChallengeResponse | WebSocketMessageRoomIdRequest | WebSocketMessagePeersRequest | WebSocketMessageConnectionResponse | WebSocketMessageMessageSendRequest;
|
|
8
|
+
}
|
|
9
|
+
export declare const rtcDataChannelMessageLimit: number;
|
|
10
|
+
export declare const messageLen: number;
|
|
11
|
+
export declare const encryptedLen: number;
|
|
12
|
+
declare const signalingServerApi: import("@reduxjs/toolkit/query").Api<BaseQueryFn<WebSocketParams, undefined>, {
|
|
13
|
+
connectWebSocket: import("@reduxjs/toolkit/query").MutationDefinition<string, BaseQueryFn<WebSocketParams, undefined>, never, void, "signalingServerApi", undefined>;
|
|
14
|
+
disconnectWebSocket: import("@reduxjs/toolkit/query").MutationDefinition<void, BaseQueryFn<WebSocketParams, undefined>, never, void, "signalingServerApi", undefined>;
|
|
15
|
+
sendMessage: import("@reduxjs/toolkit/query").MutationDefinition<WebSocketMessage, BaseQueryFn<WebSocketParams, undefined>, never, void, "signalingServerApi", undefined>;
|
|
16
|
+
connectWithPeer: import("@reduxjs/toolkit/query").MutationDefinition<WebSocketPeerConnectionParams, BaseQueryFn<WebSocketParams, undefined>, never, void, "signalingServerApi", undefined>;
|
|
17
|
+
}, "signalingServerApi", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
18
|
+
export default signalingServerApi;
|
|
19
|
+
//# sourceMappingURL=signalingServerApi.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { RTCPeerConnectionParams, IRTCPeerConnection, IRTCDataChannel } from "./interfaces";
|
|
3
|
+
export interface RTCPeerConnectionParamsExtend extends RTCPeerConnectionParams {
|
|
4
|
+
peerConnections: IRTCPeerConnection[];
|
|
5
|
+
dataChannels: IRTCDataChannel[];
|
|
6
|
+
decryptionWasmMemory: WebAssembly.Memory;
|
|
7
|
+
merkleWasmMemory: WebAssembly.Memory;
|
|
8
|
+
}
|
|
9
|
+
declare const webrtcBaseQuery: BaseQueryFn<RTCPeerConnectionParamsExtend, void, unknown>;
|
|
10
|
+
export default webrtcBaseQuery;
|
|
11
|
+
//# sourceMappingURL=baseQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/baseQuery.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,6BAA8B,SAAQ,uBAAuB;IAC5E,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC;CACtC;AAED,QAAA,MAAM,eAAe,EAAE,WAAW,CAChC,6BAA6B,EAC7B,IAAI,EACJ,OAAO,CA0GR,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { IRTCDataChannel, IRTCPeerConnection, RTCDisconnectFromAllRoomsParams } from "./interfaces";
|
|
3
|
+
export interface RTCDisconnectFromAllRoomsParamsExtension extends RTCDisconnectFromAllRoomsParams {
|
|
4
|
+
peerConnections: IRTCPeerConnection[];
|
|
5
|
+
dataChannels: IRTCDataChannel[];
|
|
6
|
+
}
|
|
7
|
+
declare const webrtcDisconnectAllRoomsQuery: BaseQueryFn<RTCDisconnectFromAllRoomsParamsExtension, void, unknown>;
|
|
8
|
+
export default webrtcDisconnectAllRoomsQuery;
|
|
9
|
+
//# sourceMappingURL=disconnectFromAllRoomsQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnectFromAllRoomsQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromAllRoomsQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,+BAA+B,EAChC,MAAM,cAAc,CAAC;AAKtB,MAAM,WAAW,wCACf,SAAQ,+BAA+B;IACvC,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,6BAA6B,EAAE,WAAW,CAC9C,wCAAwC,EACxC,IAAI,EACJ,OAAO,CAiHR,CAAC;AAEF,eAAe,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { IRTCDataChannel, RTCDisconnectFromChannelLabelParams } from "./interfaces";
|
|
3
|
+
export interface RTCDisconnectFromChannelLabelParamsExtension extends RTCDisconnectFromChannelLabelParams {
|
|
4
|
+
dataChannels: IRTCDataChannel[];
|
|
5
|
+
}
|
|
6
|
+
declare const webrtcDisconnectFromChannelLabelQuery: BaseQueryFn<RTCDisconnectFromChannelLabelParamsExtension, void, unknown>;
|
|
7
|
+
export default webrtcDisconnectFromChannelLabelQuery;
|
|
8
|
+
//# sourceMappingURL=disconnectFromChannelLabelQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnectFromChannelLabelQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromChannelLabelQuery.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,mCAAmC,EACpC,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,4CACf,SAAQ,mCAAmC;IAC3C,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,qCAAqC,EAAE,WAAW,CACtD,4CAA4C,EAC5C,IAAI,EACJ,OAAO,CA6BR,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { IRTCDataChannel, IRTCPeerConnection, RTCDisconnectFromPeerChannelLabelParams } from "./interfaces";
|
|
3
|
+
export interface RTCDisconnectFromPeerChannelLabelParamsExtension extends RTCDisconnectFromPeerChannelLabelParams {
|
|
4
|
+
peerConnections: IRTCPeerConnection[];
|
|
5
|
+
dataChannels: IRTCDataChannel[];
|
|
6
|
+
}
|
|
7
|
+
declare const webrtcDisconnectFromPeerChannelLabelQuery: BaseQueryFn<RTCDisconnectFromPeerChannelLabelParamsExtension, void, unknown>;
|
|
8
|
+
export default webrtcDisconnectFromPeerChannelLabelQuery;
|
|
9
|
+
//# sourceMappingURL=disconnectFromPeerChannelLabelQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnectFromPeerChannelLabelQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromPeerChannelLabelQuery.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,uCAAuC,EACxC,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,gDACf,SAAQ,uCAAuC;IAC/C,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,yCAAyC,EAAE,WAAW,CAC1D,gDAAgD,EAChD,IAAI,EACJ,OAAO,CAqIR,CAAC;AAEF,eAAe,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { IRTCDataChannel, IRTCPeerConnection, RTCDisconnectFromPeerParams } from "./interfaces";
|
|
3
|
+
export interface RTCDisconnectFromPeerParamsExtension extends RTCDisconnectFromPeerParams {
|
|
4
|
+
peerConnections: IRTCPeerConnection[];
|
|
5
|
+
dataChannels: IRTCDataChannel[];
|
|
6
|
+
}
|
|
7
|
+
declare const webrtcDisconnectPeerQuery: BaseQueryFn<RTCDisconnectFromPeerParamsExtension, void, unknown>;
|
|
8
|
+
export default webrtcDisconnectPeerQuery;
|
|
9
|
+
//# sourceMappingURL=disconnectFromPeerQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnectFromPeerQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromPeerQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,oCACf,SAAQ,2BAA2B;IACnC,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,yBAAyB,EAAE,WAAW,CAC1C,oCAAoC,EACpC,IAAI,EACJ,OAAO,CAwDR,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { IRTCDataChannel, IRTCPeerConnection, RTCDisconnectFromRoomParams } from "./interfaces";
|
|
3
|
+
export interface RTCDisconnectFromRoomParamsExtension extends RTCDisconnectFromRoomParams {
|
|
4
|
+
peerConnections: IRTCPeerConnection[];
|
|
5
|
+
dataChannels: IRTCDataChannel[];
|
|
6
|
+
}
|
|
7
|
+
declare const webrtcDisconnectRoomQuery: BaseQueryFn<RTCDisconnectFromRoomParamsExtension, void, unknown>;
|
|
8
|
+
export default webrtcDisconnectRoomQuery;
|
|
9
|
+
//# sourceMappingURL=disconnectFromRoomQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnectFromRoomQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromRoomQuery.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,oCACf,SAAQ,2BAA2B;IACnC,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,yBAAyB,EAAE,WAAW,CAC1C,oCAAoC,EACpC,IAAI,EACJ,OAAO,CA6ER,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseQueryFn } from "@reduxjs/toolkit/query";
|
|
2
|
+
import type { IRTCDataChannel, IRTCPeerConnection, RTCDisconnectParams } from "./interfaces";
|
|
3
|
+
export interface RTCDisconnectParamsExtension extends RTCDisconnectParams {
|
|
4
|
+
peerConnections: IRTCPeerConnection[];
|
|
5
|
+
dataChannels: IRTCDataChannel[];
|
|
6
|
+
}
|
|
7
|
+
declare const webrtcDisconnectQuery: BaseQueryFn<RTCDisconnectParamsExtension, void, unknown>;
|
|
8
|
+
export default webrtcDisconnectQuery;
|
|
9
|
+
//# sourceMappingURL=disconnectQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disconnectQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,qBAAqB,EAAE,WAAW,CACtC,4BAA4B,EAC5B,IAAI,EACJ,OAAO,CA+CR,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RTCPeerConnectionParams, RTCSendMessageParams, RTCSetDescriptionParams, RTCSetCandidateParams, RTCOpenChannelParams, RTCDisconnectFromRoomParams, RTCDisconnectFromAllRoomsParams, RTCDisconnectFromPeerParams, RTCDisconnectFromChannelLabelParams, RTCDisconnectFromPeerChannelLabelParams, RTCDisconnectParams } from "./interfaces";
|
|
2
|
+
export declare const rtcDataChannelMessageLimit: number;
|
|
3
|
+
export declare const messageLen: number;
|
|
4
|
+
export declare const encryptedLen: number;
|
|
5
|
+
declare const webrtcApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, {
|
|
6
|
+
connectWithPeer: import("@reduxjs/toolkit/query").MutationDefinition<RTCPeerConnectionParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
7
|
+
setDescription: import("@reduxjs/toolkit/query").MutationDefinition<RTCSetDescriptionParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
8
|
+
setCandidate: import("@reduxjs/toolkit/query").MutationDefinition<RTCSetCandidateParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
9
|
+
openChannel: import("@reduxjs/toolkit/query").MutationDefinition<RTCOpenChannelParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
10
|
+
sendMessage: import("@reduxjs/toolkit/query").MutationDefinition<RTCSendMessageParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
11
|
+
disconnect: import("@reduxjs/toolkit/query").MutationDefinition<RTCDisconnectParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
12
|
+
disconnectFromRoom: import("@reduxjs/toolkit/query").MutationDefinition<RTCDisconnectFromRoomParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
13
|
+
disconnectFromAllRooms: import("@reduxjs/toolkit/query").MutationDefinition<RTCDisconnectFromAllRoomsParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
14
|
+
disconnectFromPeer: import("@reduxjs/toolkit/query").MutationDefinition<RTCDisconnectFromPeerParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
15
|
+
disconnectFromChannelLabel: import("@reduxjs/toolkit/query").MutationDefinition<RTCDisconnectFromChannelLabelParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
16
|
+
disconnectFromPeerChannelLabel: import("@reduxjs/toolkit/query").MutationDefinition<RTCDisconnectFromPeerChannelLabelParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("./baseQuery").RTCPeerConnectionParamsExtend, void, unknown>, never, void, "webrtcApi", void>;
|
|
17
|
+
}, "webrtcApi", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
18
|
+
export default webrtcApi;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAIV,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,+BAA+B,EAC/B,2BAA2B,EAC3B,mCAAmC,EACnC,uCAAuC,EACvC,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAMtB,eAAO,MAAM,0BAA0B,QAAY,CAAC;AACpD,eAAO,MAAM,UAAU,QAIW,CAAC;AACnC,eAAO,MAAM,YAAY,QAC8B,CAAC;AAexD,QAAA,MAAM,SAAS;;;;;;;;;;;;8EA0Jb,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export interface IRTCPeerConnection extends RTCPeerConnection {
|
|
2
|
+
withPeerId: string;
|
|
3
|
+
withPeerPublicKey: string;
|
|
4
|
+
roomIds: string[];
|
|
5
|
+
iceCandidates: RTCIceCandidate[];
|
|
6
|
+
}
|
|
7
|
+
export interface IRTCDataChannel extends RTCDataChannel {
|
|
8
|
+
withPeerId: string;
|
|
9
|
+
roomIds: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface IRTCMessage {
|
|
12
|
+
id: string;
|
|
13
|
+
message: string;
|
|
14
|
+
fromPeerId: string;
|
|
15
|
+
toPeerId: string;
|
|
16
|
+
channelLabel: string;
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
}
|
|
19
|
+
export interface IRTCIceCandidate extends RTCIceCandidate {
|
|
20
|
+
withPeerId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RTCPeerConnectionParams {
|
|
23
|
+
peerId: string;
|
|
24
|
+
peerPublicKey: string;
|
|
25
|
+
roomId: string;
|
|
26
|
+
initiator?: boolean;
|
|
27
|
+
rtcConfig?: RTCConfiguration;
|
|
28
|
+
}
|
|
29
|
+
export interface RTCSetDescriptionParams {
|
|
30
|
+
peerId: string;
|
|
31
|
+
peerPublicKey: string;
|
|
32
|
+
roomId: string;
|
|
33
|
+
description: RTCSessionDescription;
|
|
34
|
+
rtcConfig?: RTCConfiguration;
|
|
35
|
+
}
|
|
36
|
+
export interface RTCSetCandidateParams {
|
|
37
|
+
peerId: string;
|
|
38
|
+
candidate: RTCIceCandidate;
|
|
39
|
+
}
|
|
40
|
+
export interface RTCOpenChannelParams {
|
|
41
|
+
roomId: string;
|
|
42
|
+
channel: string | RTCDataChannel;
|
|
43
|
+
withPeers?: {
|
|
44
|
+
peerId: string;
|
|
45
|
+
peerPublicKey: string;
|
|
46
|
+
}[];
|
|
47
|
+
}
|
|
48
|
+
export interface RTCSendMessageParams {
|
|
49
|
+
data: string | File;
|
|
50
|
+
label: string;
|
|
51
|
+
roomId: string;
|
|
52
|
+
minChunks?: number;
|
|
53
|
+
chunkSize?: number;
|
|
54
|
+
percentageFilledChunk?: number;
|
|
55
|
+
metadataSchemaVersion?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface RTCRoomInfoParams {
|
|
58
|
+
roomId: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ChannelData {
|
|
61
|
+
label: string;
|
|
62
|
+
peerId: string;
|
|
63
|
+
}
|
|
64
|
+
export interface PeerData {
|
|
65
|
+
peerId: string;
|
|
66
|
+
peerPublicKey: string;
|
|
67
|
+
}
|
|
68
|
+
export interface MessageData extends IRTCMessage {
|
|
69
|
+
channel: string;
|
|
70
|
+
}
|
|
71
|
+
export interface RoomData {
|
|
72
|
+
roomId: string;
|
|
73
|
+
peers: PeerData[];
|
|
74
|
+
channels: ChannelData[];
|
|
75
|
+
messages: MessageData[];
|
|
76
|
+
}
|
|
77
|
+
export interface RTCDisconnectParams {
|
|
78
|
+
alsoDeleteDB: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface RTCDisconnectFromRoomParams {
|
|
81
|
+
roomId: string;
|
|
82
|
+
deleteMessages?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface RTCDisconnectFromAllRoomsParams {
|
|
85
|
+
deleteMessages?: boolean;
|
|
86
|
+
exceptionRoomIds?: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface RTCDisconnectFromPeerParams {
|
|
89
|
+
peerId: string;
|
|
90
|
+
alsoDeleteData?: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface RTCDisconnectFromChannelLabelParams {
|
|
93
|
+
label: string;
|
|
94
|
+
alsoDeleteData?: boolean;
|
|
95
|
+
alsoSendFinishedMessage?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface RTCDisconnectFromPeerChannelLabelParams {
|
|
98
|
+
peerId: string;
|
|
99
|
+
label: string;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=interfaces.d.ts.map
|