p2party 0.7.1 → 0.7.3

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.md CHANGED
@@ -17,7 +17,7 @@
17
17
  [code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
18
18
  [code-style-prettier-url]: https://github.com/prettier/prettier
19
19
 
20
- > Peer-to-peer WebRTC mesh communication with offensive cryptographic encoding.
20
+ > Peer-to-peer WebRTC mesh networking with a kind-of "offensive" cryptographic.
21
21
 
22
22
  **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, byte-level noise, isomorphic packet transmission (64kb), making message intent opaque. Of course it also adds a layer of ChaChaPoly1305 end-to-end encryption with ephemeral Ed25519 sender keys.
23
23
 
@@ -31,7 +31,7 @@ The API is not completely stable and the code has not undergone external securit
31
31
 
32
32
  - 📡 Auto-connect peers based on shared URLs
33
33
  - 🔀 WebRTC mesh topology (no central servers except for signaling and STUN/TURN)
34
- - 🔐 Offensive cryptography: every message can be split in multiple 64KB chunks so the attacker needs to store a lot of useless info
34
+ - 🔐 "Offensive" cryptography: every message can be split in multiple 64KB chunks so a stalker stores a lot of useless info
35
35
  - 🧩 Supports `File` and `string` messages via chunked encoding
36
36
  - 🧠 Built-in address book (whitelist), blacklist, and room memory, all stored in the browser's IndexedDB
37
37
  - 🛠 Easy API and integration with React via custom hooks
@@ -44,7 +44,9 @@ This library relies heavily on [libsodium](https://github.com/jedisct1/libsodium
44
44
 
45
45
  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, provided by libsodium, and instead of SHA256 we use SHA512 (native browser functionality).
46
46
 
47
- On the js side, the library depends on [Redux](https://github.com/redux) for state management,
47
+ A project that was previously developed and gave a lot of inspiration for this library was [libcrypto](https://github.com/deliberative/crypto).
48
+
49
+ On the js side, the library depends on [Redux](https://github.com/redux) for state management.
48
50
 
49
51
  ## Install
50
52
 
@@ -57,13 +59,13 @@ npm install p2party
57
59
  and include as ES module
58
60
 
59
61
  ```typescript
60
- import dcrypto from "@deliberative/crypto";
62
+ import p2party from "p2party";
61
63
  ```
62
64
 
63
- as CommonJS module
65
+ or as CommonJS module
64
66
 
65
67
  ```javascript
66
- const dcrypto = require("@deliberative/crypto");
68
+ const p2party = require("p2party");
67
69
  ```
68
70
 
69
71
  or as UMD in the browser
@@ -106,10 +108,10 @@ export const useRoom = () => {
106
108
  );
107
109
  };
108
110
 
109
- const sendMessage = (message: string | File, channel: string) => {
111
+ const sendMessage = async (message: string | File, channel: string) => {
110
112
  if (roomIndex === -1) throw new Error("No room was selected");
111
113
 
112
- p2party.sendMessage(
114
+ await p2party.sendMessage(
113
115
  message,
114
116
  channel,
115
117
  rooms[roomIndex].id,
@@ -176,32 +178,29 @@ export const useRoom = () => {
176
178
  The most important exported functions by p2party, with their types, are:
177
179
 
178
180
  ```typescript
179
-
180
181
  /**
181
182
  * Connects peer to a room.
182
183
  * A room URL is 64 chars long. We use the sha256 of the sha512 of random data.
183
184
  */
184
- const connect = (
185
+ const connect = async (
185
186
  roomUrl: string,
186
187
  signalingServerUrl = "wss://signaling.p2party.com/ws",
187
188
  rtcConfig: RTCConfiguration = {
188
189
  iceServers: [
189
190
  {
190
- urls: [
191
- "stun:stun.p2party.com:3478",
192
- ],
191
+ urls: ["stun:stun.p2party.com:3478"],
193
192
  },
194
193
  ],
195
194
  iceTransportPolicy: "all",
196
195
  },
197
- ) => void;
196
+ ) => Promise<void>;
198
197
 
199
- const connectToSignalingServer = (
198
+ const connectToSignalingServer = async (
200
199
  roomUrl: string,
201
200
  signalingServerUrl = "wss://signaling.p2party.com/ws",
202
- ) => void;
201
+ ) => Promise<void>;
203
202
 
204
- const sendMessage = (
203
+ const sendMessage = async (
205
204
  data: string | File,
206
205
  toChannel: string,
207
206
  roomId: string,
@@ -209,27 +208,24 @@ const sendMessage = (
209
208
  minChunks = 3,
210
209
  chunkSize = CHUNK_LEN,
211
210
  metadataSchemaVersion = 1,
212
- ) => void;
213
-
214
- const readMessage = async (
215
- merkleRootHex?: string,
216
- hashHex?: string,
217
- ) => Promise<{
218
- message: string | Blob;
219
- percentage: number;
220
- size: number;
221
- filename: string;
222
- mimeType: MimeType;
223
- extension: FileExtension;
224
- category: string;
225
- }>;
211
+ ) => Promise<void>;
212
+
213
+ const readMessage = async (merkleRootHex?: string, hashHex?: string) =>
214
+ Promise<{
215
+ message: string | Blob;
216
+ percentage: number;
217
+ size: number;
218
+ filename: string;
219
+ mimeType: MimeType;
220
+ extension: FileExtension;
221
+ category: string;
222
+ }>;
226
223
 
227
224
  const cancelMessage = async (
228
225
  channelLabel: string,
229
226
  merkleRoot?: string | Uint8Array,
230
227
  hash?: string | Uint8Array,
231
- ) => void;
232
-
228
+ ) => Promise<void>;
233
229
  ```
234
230
 
235
231
  For a complete reference of the API you can check the library output file [index.ts](src/index.ts).
@@ -1 +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"}
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,CAsGR,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +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"}
1
+ {"version":3,"file":"disconnectFromAllRoomsQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromAllRoomsQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,+BAA+B,EAChC,MAAM,cAAc,CAAC;AAItB,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,CAqFR,CAAC;AAEF,eAAe,6BAA6B,CAAC"}
@@ -1 +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"}
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,CAyBR,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"disconnectFromPeerChannelLabelQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromPeerChannelLabelQuery.ts"],"names":[],"mappings":"AAYA,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,CA+IR,CAAC;AAEF,eAAe,yCAAyC,CAAC"}
1
+ {"version":3,"file":"disconnectFromPeerChannelLabelQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectFromPeerChannelLabelQuery.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,uCAAuC,EACxC,MAAM,cAAc,CAAC;AAEtB,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,CAgFR,CAAC;AAEF,eAAe,yCAAyC,CAAC"}
@@ -1 +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"}
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,CAqDR,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1 +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"}
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;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,CA6DR,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1 +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"}
1
+ {"version":3,"file":"disconnectQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/disconnectQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAEtB,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,CAqBR,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"openChannelQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/openChannelQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IACzE,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,sBAAsB,EAAE,WAAW,CACvC,6BAA6B,EAC7B,IAAI,EACJ,OAAO,CAsER,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"openChannelQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/openChannelQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IACzE,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,sBAAsB,EAAE,WAAW,CACvC,6BAA6B,EAC7B,IAAI,EACJ,OAAO,CAkER,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sendMessageQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/sendMessageQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,gCAAiC,SAAQ,oBAAoB;IAC5E,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC;CACtC;AAED,QAAA,MAAM,kBAAkB,EAAE,WAAW,CACnC,gCAAgC,EAChC,IAAI,EACJ,OAAO,CAmDR,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"sendMessageQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/sendMessageQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,gCAAiC,SAAQ,oBAAoB;IAC5E,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC;CACtC;AAED,QAAA,MAAM,kBAAkB,EAAE,WAAW,CACnC,gCAAgC,EAChC,IAAI,EACJ,OAAO,CA+CR,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"setCandidateQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/setCandidateQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;IAC3E,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,aAAa,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAED,QAAA,MAAM,0BAA0B,EAAE,WAAW,CAC3C,8BAA8B,EAC9B,IAAI,EACJ,OAAO,CA6CR,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"setCandidateQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/setCandidateQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;IAC3E,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,aAAa,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAED,QAAA,MAAM,0BAA0B,EAAE,WAAW,CAC3C,8BAA8B,EAC9B,IAAI,EACJ,OAAO,CAsCR,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"setDescriptionQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/setDescriptionQuery.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,gCACf,SAAQ,uBAAuB;IAC/B,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC;CACtC;AAED,QAAA,MAAM,yBAAyB,EAAE,WAAW,CAC1C,gCAAgC,EAChC,IAAI,EACJ,OAAO,CAqLR,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"setDescriptionQuery.d.ts","sourceRoot":"","sources":["../../../src/api/webrtc/setDescriptionQuery.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,gCACf,SAAQ,uBAAuB;IAC/B,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC;IACzC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC;CACtC;AAED,QAAA,MAAM,yBAAyB,EAAE,WAAW,CAC1C,gCAAgC,EAChC,IAAI,EACJ,OAAO,CAiLR,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
package/lib/db.worker.js CHANGED
@@ -1,2 +1,2 @@
1
- const e=(e,t)=>t.some(t=>e instanceof t);let t,a;const n=new WeakMap,o=new WeakMap,r=new WeakMap;let s={get(e,t,a){if(e instanceof IDBTransaction){if("done"===t)return n.get(e);if("store"===t)return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return d(e[t])},set:(e,t,a)=>(e[t]=a,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function i(e){s=e(s)}function c(e){return(a||(a=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(l(this),t),d(this.request)}:function(...t){return d(e.apply(l(this),t))}}function u(a){return"function"==typeof a?c(a):(a instanceof IDBTransaction&&function(e){if(n.has(e))return;const t=new Promise((t,a)=>{const n=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",r),e.removeEventListener("abort",r)},o=()=>{t(),n()},r=()=>{a(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",o),e.addEventListener("error",r),e.addEventListener("abort",r)});n.set(e,t)}(a),e(a,t||(t=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(a,s):a)}function d(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,a)=>{const n=()=>{e.removeEventListener("success",o),e.removeEventListener("error",r)},o=()=>{t(d(e.result)),n()},r=()=>{a(e.error),n()};e.addEventListener("success",o),e.addEventListener("error",r)});return r.set(t,e),t}(e);if(o.has(e))return o.get(e);const t=u(e);return t!==e&&(o.set(e,t),r.set(t,e)),t}const l=e=>r.get(e);const w=["get","getKey","getAll","getAllKeys","count"],h=["put","add","delete","clear"],m=new Map;function g(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(m.get(t))return m.get(t);const a=t.replace(/FromIndex$/,""),n=t!==a,o=h.includes(a);if(!(a in(n?IDBIndex:IDBObjectStore).prototype)||!o&&!w.includes(a))return;const r=async function(e,...t){const r=this.transaction(e,o?"readwrite":"readonly");let s=r.store;return n&&(s=s.index(t.shift())),(await Promise.all([s[a](...t),o&&r.done]))[0]};return m.set(t,r),r}i(e=>({...e,get:(t,a,n)=>g(t,a)||e.get(t,a,n),has:(t,a)=>!!g(t,a)||e.has(t,a)}));const k=["continue","continuePrimaryKey","advance"],y={},b=new WeakMap,f=new WeakMap,I={get(e,t){if(!k.includes(t))return e[t];let a=y[t];return a||(a=y[t]=function(...e){b.set(this,f.get(this)[t](...e))}),a}};async function*x(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const a=new Proxy(t,I);for(f.set(a,t),r.set(a,l(t));t;)yield a,t=await(b.get(a)||t.continue()),b.delete(a)}function p(t,a){return a===Symbol.asyncIterator&&e(t,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===a&&e(t,[IDBIndex,IDBObjectStore])}i(e=>({...e,get:(t,a,n)=>p(t,a)?x:e.get(t,a,n),has:(t,a)=>p(t,a)||e.has(t,a)}));const D=64*Uint8Array.BYTES_PER_ELEMENT,B="p2party";async function S(){return function(e,t,{blocked:a,upgrade:n,blocking:o,terminated:r}={}){const s=indexedDB.open(e,t),i=d(s);return n&&s.addEventListener("upgradeneeded",e=>{n(d(s.result),e.oldVersion,e.newVersion,d(s.transaction),e)}),a&&s.addEventListener("blocked",e=>a(e.oldVersion,e.newVersion,e)),i.then(e=>{r&&e.addEventListener("close",()=>r()),o&&e.addEventListener("versionchange",e=>o(e.oldVersion,e.newVersion,e))}).catch(()=>{}),i}(B,16,{upgrade(e,t,a,n){if(e.objectStoreNames.contains("addressBook")){const e=n.objectStore("addressBook");e.indexNames.contains("username")||e.createIndex("username","username",{unique:!1}),e.indexNames.contains("peerId")||e.createIndex("peerId","peerId",{unique:!0}),e.indexNames.contains("peerPublicKey")||e.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}else{const t=e.createObjectStore("addressBook",{keyPath:["peerId"]});t.createIndex("username","username",{unique:!1}),t.createIndex("peerId","peerId",{unique:!0}),t.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}if(e.objectStoreNames.contains("blacklist")){const e=n.objectStore("blacklist");e.indexNames.contains("username")||e.createIndex("username","username",{unique:!1}),e.indexNames.contains("peerId")||e.createIndex("peerId","peerId",{unique:!0}),e.indexNames.contains("peerPublicKey")||e.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}else{const t=e.createObjectStore("blacklist",{keyPath:["peerId"]});t.createIndex("username","username",{unique:!1}),t.createIndex("peerId","peerId",{unique:!0}),t.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}if(e.objectStoreNames.contains("uniqueRoom")){const e=n.objectStore("uniqueRoom");e.indexNames.contains("roomUrl")||e.createIndex("roomUrl","roomUrl",{unique:!0}),e.indexNames.contains("roomId")||e.createIndex("roomId","roomId",{unique:!0})}else{const t=e.createObjectStore("uniqueRoom",{keyPath:["roomId"]});t.createIndex("roomUrl","roomUrl",{unique:!0}),t.createIndex("roomId","roomId",{unique:!0})}if(e.objectStoreNames.contains("messageData")){const e=n.objectStore("messageData");e.indexNames.contains("roomId")||e.createIndex("roomId","roomId",{unique:!1}),e.indexNames.contains("hash")||e.createIndex("hash","hash",{unique:!1}),e.indexNames.contains("merkleRoot")||e.createIndex("merkleRoot","merkleRoot",{unique:!0}),e.indexNames.contains("fromPeerId")||e.createIndex("fromPeerId","fromPeerId",{unique:!1})}else{const t=e.createObjectStore("messageData",{keyPath:["timestamp","roomId","merkleRoot"]});t.createIndex("roomId","roomId",{unique:!1}),t.createIndex("hash","hash",{unique:!1}),t.createIndex("merkleRoot","merkleRoot",{unique:!0}),t.createIndex("fromPeerId","fromPeerId",{unique:!1})}if(e.objectStoreNames.contains("chunks")){const e=n.objectStore("chunks");e.indexNames.contains("merkleRoot")||e.createIndex("merkleRoot","merkleRoot",{unique:!1}),e.indexNames.contains("hash")||e.createIndex("hash","hash",{unique:!1})}else{const t=e.createObjectStore("chunks",{keyPath:["merkleRoot","chunkIndex"]});t.createIndex("merkleRoot","merkleRoot",{unique:!1}),t.createIndex("hash","hash",{unique:!1})}if(e.objectStoreNames.contains("newChunks")){const e=n.objectStore("newChunks");e.indexNames.contains("hash")||e.createIndex("hash","hash",{unique:!1}),e.indexNames.contains("merkleRoot")||e.createIndex("merkleRoot","merkleRoot",{unique:!1}),e.indexNames.contains("realChunkHash")||e.createIndex("realChunkHash","realChunkHash",{unique:!0})}else{const t=e.createObjectStore("newChunks",{keyPath:["hash","chunkIndex"]});t.createIndex("hash","hash",{unique:!1}),t.createIndex("merkleRoot","merkleRoot",{unique:!1}),t.createIndex("realChunkHash","realChunkHash",{unique:!0})}if(e.objectStoreNames.contains("sendQueue")){const e=n.objectStore("sendQueue");e.indexNames.contains("labelPeer")||e.createIndex("labelPeer",["label","toPeerId"],{unique:!1})}else{e.createObjectStore("sendQueue",{keyPath:["position","label","toPeerId"]}).createIndex("labelPeer",["label","toPeerId"],{unique:!1})}}})}async function R(){await function(e,{blocked:t}={}){const a=indexedDB.deleteDatabase(e);return t&&a.addEventListener("blocked",e=>t(e.oldVersion,e)),d(a).then(()=>{})}(B,{blocked(){console.error("DB deletion BLOCKED")}})}onmessage=async e=>{const t=e.data,{id:a,method:n}=t;try{let e;switch(n){case"getDBAddressBookEntry":e=await async function(e,t){if(!e&&!t)return;if(e&&e.length<10&&!t)return;if(t&&64!==t.length&&!e)return;const a=await S();try{const n=a.transaction("addressBook","readonly"),o=e?n.objectStore("addressBook").index("peerId"):n.objectStore("addressBook").index("peerPublicKey"),r=e?await o.get(e):await o.get(t);return await n.done,a.close(),r?{username:r.username,peerId:r.peerId,peerPublicKey:r.peerPublicKey}:void 0}catch(e){return void a.close()}}(...t.args);break;case"getAllDBAddressBookEntries":e=await async function(){try{const e=await S(),t=await e.getAll("addressBook");return e.close(),t}catch(e){return[]}}(...t.args);break;case"setDBAddressBookEntry":e=await async function(e,t,a){try{const n=await S(),o=n.transaction(["addressBook"],"readwrite"),r=o.objectStore("addressBook"),s=r.index("peerId"),i=r.index("peerPublicKey"),c=await s.get(t),u=await i.get(a);(!c&&!u||c&&!u||!c&&u)&&await r.put({username:e,peerId:t,peerPublicKey:a,dateAdded:Date.now()}),await o.done,n.close()}catch(e){console.error(e)}}(...t.args);break;case"deleteDBAddressBookEntry":e=await async function(e,t,a){const n=!e||0===e.length,o=!t||t.length<10,r=!a||64!==a.length;if(n&&o&&r)throw new Error("Cannot delete address book with no data");let s=t??"";try{const n=await S(),i=n.transaction("addressBook","readwrite"),c=i.objectStore("addressBook");if(o)if(r){const t=c.index("username"),a=await t.getKey(e);if(a){const n=await t.get(e);s=n?.peerId??"",await c.delete(a)}}else{const e=c.index("peerPublicKey"),t=await e.getKey(a);if(t){const n=await e.get(a);s=n?.peerId??"",await c.delete(t)}}else{const e=c.index("peerId"),a=await e.getKey(t);a&&await c.delete(a)}await i.done,n.close()}catch{}return s}(...t.args);break;case"getDBPeerIsBlacklisted":e=await async function(e,t){if(!e&&!t)return!1;if(e&&e.length<10&&!t)return!1;if(t&&64!==t.length&&!e)return!1;try{const a=await S(),n=a.transaction("blacklist","readonly"),o=e?n.objectStore("blacklist").index("peerId"):n.objectStore("blacklist").index("peerPublicKey"),r=e?await o.get(e):await o.get(t);return await n.done,a.close(),!!r}catch(e){return!1}}(...t.args);break;case"getAllDBBlacklisted":e=await async function(){const e=await S();try{const t=await e.getAll("blacklist");return e.close(),t}catch(t){return e.close(),[]}}(...t.args);break;case"setDBPeerInBlacklist":e=await async function(e,t){try{const a=await S(),n=a.transaction(["blacklist"],"readwrite"),o=n.objectStore("blacklist"),r=o.index("peerId"),s=o.index("peerPublicKey"),i=await r.get(e),c=await s.get(t);(!i&&!c||i&&!c||!i&&c)&&await o.put({peerId:e,peerPublicKey:t,dateAdded:Date.now()}),await n.done,a.close()}catch(e){console.error(e)}}(...t.args);break;case"deleteDBPeerFromBlacklist":e=await async function(e,t){const a=!e||e.length<10,n=!t||64!==t.length;if(a&&n)throw new Error("Cannot delete blacklisted with no data");try{const n=await S(),o=n.transaction("blacklist","readwrite"),r=o.objectStore("blacklist");if(a){const e=r.index("peerPublicKey"),a=await e.getKey(t);a&&await r.delete(a)}else{const t=r.index("peerId"),a=await t.getKey(e);a&&await r.delete(a)}await o.done,n.close()}catch(e){console.error(e)}}(...t.args);break;case"getAllDBUniqueRooms":e=await async function(){const e=await S();try{const t=await e.getAll("uniqueRoom");return e.close(),t}catch(t){return e.close(),[]}}(...t.args);break;case"setDBUniqueRoom":e=await async function(e,t){try{const a=await S(),n=a.transaction(["uniqueRoom"],"readwrite"),o=n.objectStore("uniqueRoom"),r=o.index("roomUrl"),s=o.index("roomId"),i=await r.get(e),c=await s.get(t);if(!i&&!c){const a=Date.now();await o.put({roomId:t,roomUrl:e,messageCount:0,lastMessageMerkleRoot:"",createdAt:a,updatedAt:a})}await n.done,a.close()}catch(e){console.error(e)}}(...t.args);break;case"getDBMessageData":e=await async function(e,t){try{const a=await S(),n=a.transaction(["messageData"],"readonly"),o=n.objectStore("messageData"),r=o.index("merkleRoot"),s=o.index("hash");if(e&&e.length===2*D){const o=await r.get(e);if(o)return await n.done,a.close(),o;if(t&&t.length===2*D){const e=await s.get(t);return await n.done,a.close(),e}return await n.done,void a.close()}if(t&&t.length===2*D){const e=await s.get(t);return await n.done,a.close(),e}return await n.done,void a.close()}catch(e){return void console.error(e)}}(...t.args);break;case"getDBRoomMessageData":e=await async function(e){const t=await S(),a=await t.getAllFromIndex("messageData","roomId",e);t.close();const n=a.length,o=[];for(let t=0;t<n;t++)o.push({roomId:e,merkleRoot:a[t].merkleRoot,hash:a[t].hash,fromPeerId:a[t].fromPeerId,filename:a[t].filename,messageType:a[t].messageType,savedSize:a[t].savedSize,totalSize:a[t].totalSize,channelLabel:a[t].channelLabel,timestamp:a[t].timestamp});return o}(...t.args);break;case"setDBRoomMessageData":e=await async function(e,t,a,n,o,r,s,i,c,u){try{const d=await S(),l=d.transaction(["messageData","uniqueRoom"],"readwrite"),w=l.objectStore("messageData"),h=await w.index("merkleRoot").get(t),m=h?.savedSize??0;try{await w.put({roomId:e,timestamp:u,merkleRoot:t,hash:a,fromPeerId:n,filename:i,messageType:s,savedSize:m!==r?o+m:o,totalSize:r,channelLabel:c})}catch(e){throw await l.done,d.close(),e}const g=l.objectStore("uniqueRoom"),k=await g.index("roomId").get(e);if(k&&k.lastMessageMerkleRoot!==t)try{await g.put({...k,lastMessageMerkleRoot:t,messageCount:k.messageCount+1,updatedAt:Date.now()})}catch(e){throw await l.done,d.close(),e}await l.done,d.close()}catch(e){throw console.error(e),e}}(...t.args);break;case"getDBChunk":e=await async function(e,t){const a=await S(),n=await a.get("chunks",[e,t]);return a.close(),n?.data}(...t.args);break;case"existsDBChunk":e=await async function(e,t){const a=await S(),n=await a.count("chunks",[e,t]);return a.close(),n>0}(...t.args);break;case"getDBNewChunk":e=await async function(e,t){try{const a=await S(),n=t??-1;if(n>-1){const t=await a.get("newChunks",[e,n]);return a.close(),t}{const t=a.transaction("newChunks"),n=t.objectStore("newChunks").index("realChunkHash"),o=await n.get(e);return await t.done,a.close(),o}}catch(e){return void console.error(e)}}(...t.args);break;case"existsDBNewChunk":e=await async function(e,t){const a=await S(),n=await a.count("newChunks",[e,t]);return a.close(),n>0}(...t.args);break;case"getDBSendQueue":e=await async function(e,t,a){const n=await S();if(a){const o=await n.get("sendQueue",[a,e,t]);return n.close(),o?[o]:[]}const o=n.transaction("sendQueue","readonly").objectStore("sendQueue").index("labelPeer"),r=IDBKeyRange.only([e,t]),s=await o.getAll(r);return n.close(),s}(...t.args);break;case"getDBAllChunks":e=await async function(e,t){try{const a=await S(),n=a.transaction("chunks","readonly"),o=n.objectStore("chunks"),r=o.index("hash"),s=o.index("merkleRoot");if(e&&e.length===2*D){const t=await s.getAll(e);return 0===t.length?(await n.done,a.close(),[]):(await n.done,a.close(),t)}if(t&&t.length===2*D){const e=await r.getAll(t);return await n.done,a.close(),e}return await n.done,a.close(),[]}catch(e){return console.error(e),[]}}(...t.args);break;case"getDBAllChunksCount":e=await async function(e,t){try{const a=await S(),n=a.transaction(["chunks"],"readonly"),o=n.objectStore("chunks"),r=o.index("hash"),s=o.index("merkleRoot");if(t&&t.length===2*D){const o=await r.count(t);if(0===o){if(e&&e.length===2*D){const t=await s.count(e);return await n.done,a.close(),t}return await n.done,a.close(),0}return await n.done,a.close(),o}if(e&&e.length===2*D){const t=await s.count(e);return await n.done,a.close(),t}return await n.done,a.close(),0}catch(e){return 0}}(...t.args);break;case"setDBChunk":e=await async function(e){const t=await S();await t.add("chunks",e),t.close()}(...t.args);break;case"getDBAllNewChunks":e=await async function(e,t){if(!e&&!t)return[];if(e?.length!==2*D&&t?.length!==2*D)return[];const a=await S();if((e?await a.countFromIndex("newChunks","hash",e):await a.countFromIndex("newChunks","merkleRoot",t))>0){const n=e?await a.getAllFromIndex("newChunks","hash",e):await a.getAllFromIndex("newChunks","merkleRoot",t);return a.close(),n}{const n=a.transaction("newChunks","readonly").objectStore("newChunks"),o=e?n.index("hash"):n.index("merkleRoot"),r=e?IDBKeyRange.only(e):IDBKeyRange.only(t),s=await o.getAll(r);return a.close(),s}}(...t.args);break;case"getDBAllNewChunksCount":e=await async function(e){const t=await S(),a=await t.countFromIndex("newChunks","hash",e);return t.close(),a}(...t.args);break;case"setDBNewChunk":e=await async function(e){const t=await S();await t.put("newChunks",e),t.close()}(...t.args);break;case"setDBSendQueue":e=await async function(e){const t=await S();await t.put("sendQueue",e),t.close()}(...t.args);break;case"countDBSendQueue":e=await async function(e,t){const a=await S(),n=a.transaction("sendQueue","readonly").objectStore("sendQueue").index("labelPeer"),o=IDBKeyRange.only([e,t]),r=await n.count(o);return a.close(),r}(...t.args);break;case"deleteDBChunk":e=await async function(e,t){try{const a=await S(),n=a.transaction("chunks","readwrite"),o=n.objectStore("chunks");if(t){const a=IDBKeyRange.only([e,t]);await o.delete(a)}else{const t=o.index("hash"),a=await t.getAllKeys(e),n=a.length;if(0===n){const t=o.index("merkleRoot"),a=await t.getAllKeys(e),n=a.length;for(let e=0;e<n;e++)await o.delete(a[e])}else for(let e=0;e<n;e++)await o.delete(a[e])}await n.done,a.close()}catch(e){}}(...t.args);break;case"deleteDBNewChunk":e=await async function(e,t,a,n){try{const o=await S(),r=o.transaction("newChunks","readwrite"),s=r.objectStore("newChunks");if(e){const t=s.index("merkleRoot"),a=await t.getAllKeys(e),n=a.length;for(let e=0;e<n;e++)await s.delete(a[e])}else if(a&&n)await s.delete([a,n]);else if(a){const e=s.index("hash"),t=await e.getAllKeys(a),n=t.length;for(let e=0;e<n;e++)await s.delete(t[e])}else if(t){const e=s.index("realChunkHash"),a=await e.getKey(t);a&&await s.delete(a)}await r.done,o.close()}catch(e){console.error(e)}}(...t.args);break;case"deleteDBMessageData":e=await async function(e){try{const t=await S(),a=t.transaction(["messageData","uniqueRoom"],"readwrite"),n=a.objectStore("messageData"),o=a.objectStore("uniqueRoom"),r=n.index("merkleRoot"),s=await r.getAllKeys(e),i=s.length;let c="";for(let e=0;e<i;e++){if(0===e||0===c.length){const t=await n.get(s[e]);c=t?.roomId??""}await n.delete(s[e])}if(c.length>0){const e=o.index("roomId"),t=await e.get(c);if(t){const e=n.index("roomId"),a=await e.getAllKeys(c),r=a.length,s=r>0?await n.get(a[r-1]):void 0;await o.put({...t,messageCount:t.messageCount>0?t.messageCount-1:0,updatedAt:s?.timestamp??Date.now(),lastMessageMerkleRoot:s?.merkleRoot??""})}}await a.done,t.close()}catch(e){}}(...t.args);break;case"deleteDBUniqueRoom":e=await async function(e){try{const t=await S(),a=t.transaction("uniqueRoom","readwrite"),n=a.objectStore("uniqueRoom"),o=n.index("roomId"),r=await o.getKey(e);r&&await n.delete(r),await a.done,t.close()}catch(e){}}(...t.args);break;case"deleteDBSendQueue":e=await async function(e,t,a){try{const n=await S();if(a)await n.delete("sendQueue",[a,e,t]);else{const a=IDBKeyRange.only([e,t]);await n.delete("sendQueue",a)}n.close()}catch(e){}}(...t.args);break;case"deleteDB":e=await R();break;default:return void postMessage({id:a,error:"Method not found"})}postMessage({id:a,result:e})}catch(e){postMessage({id:a,error:String(e)})}};
1
+ const e=(e,t)=>t.some(t=>e instanceof t);let t,a;const n=new WeakMap,o=new WeakMap,r=new WeakMap;let s={get(e,t,a){if(e instanceof IDBTransaction){if("done"===t)return n.get(e);if("store"===t)return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return d(e[t])},set:(e,t,a)=>(e[t]=a,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function i(e){s=e(s)}function c(e){return(a||(a=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(l(this),t),d(this.request)}:function(...t){return d(e.apply(l(this),t))}}function u(a){return"function"==typeof a?c(a):(a instanceof IDBTransaction&&function(e){if(n.has(e))return;const t=new Promise((t,a)=>{const n=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",r),e.removeEventListener("abort",r)},o=()=>{t(),n()},r=()=>{a(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",o),e.addEventListener("error",r),e.addEventListener("abort",r)});n.set(e,t)}(a),e(a,t||(t=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(a,s):a)}function d(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,a)=>{const n=()=>{e.removeEventListener("success",o),e.removeEventListener("error",r)},o=()=>{t(d(e.result)),n()},r=()=>{a(e.error),n()};e.addEventListener("success",o),e.addEventListener("error",r)});return r.set(t,e),t}(e);if(o.has(e))return o.get(e);const t=u(e);return t!==e&&(o.set(e,t),r.set(t,e)),t}const l=e=>r.get(e);const w=["get","getKey","getAll","getAllKeys","count"],h=["put","add","delete","clear"],m=new Map;function g(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(m.get(t))return m.get(t);const a=t.replace(/FromIndex$/,""),n=t!==a,o=h.includes(a);if(!(a in(n?IDBIndex:IDBObjectStore).prototype)||!o&&!w.includes(a))return;const r=async function(e,...t){const r=this.transaction(e,o?"readwrite":"readonly");let s=r.store;return n&&(s=s.index(t.shift())),(await Promise.all([s[a](...t),o&&r.done]))[0]};return m.set(t,r),r}i(e=>({...e,get:(t,a,n)=>g(t,a)||e.get(t,a,n),has:(t,a)=>!!g(t,a)||e.has(t,a)}));const k=["continue","continuePrimaryKey","advance"],y={},b=new WeakMap,f=new WeakMap,I={get(e,t){if(!k.includes(t))return e[t];let a=y[t];return a||(a=y[t]=function(...e){b.set(this,f.get(this)[t](...e))}),a}};async function*x(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const a=new Proxy(t,I);for(f.set(a,t),r.set(a,l(t));t;)yield a,t=await(b.get(a)||t.continue()),b.delete(a)}function p(t,a){return a===Symbol.asyncIterator&&e(t,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===a&&e(t,[IDBIndex,IDBObjectStore])}i(e=>({...e,get:(t,a,n)=>p(t,a)?x:e.get(t,a,n),has:(t,a)=>p(t,a)||e.has(t,a)}));const D=64*Uint8Array.BYTES_PER_ELEMENT,B="p2party";async function S(){return function(e,t,{blocked:a,upgrade:n,blocking:o,terminated:r}={}){const s=indexedDB.open(e,t),i=d(s);return n&&s.addEventListener("upgradeneeded",e=>{n(d(s.result),e.oldVersion,e.newVersion,d(s.transaction),e)}),a&&s.addEventListener("blocked",e=>a(e.oldVersion,e.newVersion,e)),i.then(e=>{r&&e.addEventListener("close",()=>r()),o&&e.addEventListener("versionchange",e=>o(e.oldVersion,e.newVersion,e))}).catch(()=>{}),i}(B,16,{upgrade(e,t,a,n){if(e.objectStoreNames.contains("addressBook")){const e=n.objectStore("addressBook");e.indexNames.contains("username")||e.createIndex("username","username",{unique:!1}),e.indexNames.contains("peerId")||e.createIndex("peerId","peerId",{unique:!0}),e.indexNames.contains("peerPublicKey")||e.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}else{const t=e.createObjectStore("addressBook",{keyPath:["peerId"]});t.createIndex("username","username",{unique:!1}),t.createIndex("peerId","peerId",{unique:!0}),t.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}if(e.objectStoreNames.contains("blacklist")){const e=n.objectStore("blacklist");e.indexNames.contains("username")||e.createIndex("username","username",{unique:!1}),e.indexNames.contains("peerId")||e.createIndex("peerId","peerId",{unique:!0}),e.indexNames.contains("peerPublicKey")||e.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}else{const t=e.createObjectStore("blacklist",{keyPath:["peerId"]});t.createIndex("username","username",{unique:!1}),t.createIndex("peerId","peerId",{unique:!0}),t.createIndex("peerPublicKey","peerPublicKey",{unique:!0})}if(e.objectStoreNames.contains("uniqueRoom")){const e=n.objectStore("uniqueRoom");e.indexNames.contains("roomUrl")||e.createIndex("roomUrl","roomUrl",{unique:!0}),e.indexNames.contains("roomId")||e.createIndex("roomId","roomId",{unique:!0})}else{const t=e.createObjectStore("uniqueRoom",{keyPath:["roomId"]});t.createIndex("roomUrl","roomUrl",{unique:!0}),t.createIndex("roomId","roomId",{unique:!0})}if(e.objectStoreNames.contains("messageData")){const e=n.objectStore("messageData");e.indexNames.contains("roomId")||e.createIndex("roomId","roomId",{unique:!1}),e.indexNames.contains("hash")||e.createIndex("hash","hash",{unique:!1}),e.indexNames.contains("merkleRoot")||e.createIndex("merkleRoot","merkleRoot",{unique:!0}),e.indexNames.contains("fromPeerId")||e.createIndex("fromPeerId","fromPeerId",{unique:!1})}else{const t=e.createObjectStore("messageData",{keyPath:["timestamp","roomId","merkleRoot"]});t.createIndex("roomId","roomId",{unique:!1}),t.createIndex("hash","hash",{unique:!1}),t.createIndex("merkleRoot","merkleRoot",{unique:!0}),t.createIndex("fromPeerId","fromPeerId",{unique:!1})}if(e.objectStoreNames.contains("chunks")){const e=n.objectStore("chunks");e.indexNames.contains("merkleRoot")||e.createIndex("merkleRoot","merkleRoot",{unique:!1}),e.indexNames.contains("hash")||e.createIndex("hash","hash",{unique:!1})}else{const t=e.createObjectStore("chunks",{keyPath:["merkleRoot","chunkIndex"]});t.createIndex("merkleRoot","merkleRoot",{unique:!1}),t.createIndex("hash","hash",{unique:!1})}if(e.objectStoreNames.contains("newChunks")){const e=n.objectStore("newChunks");e.indexNames.contains("hash")||e.createIndex("hash","hash",{unique:!1}),e.indexNames.contains("merkleRoot")||e.createIndex("merkleRoot","merkleRoot",{unique:!1}),e.indexNames.contains("realChunkHash")||e.createIndex("realChunkHash","realChunkHash",{unique:!0})}else{const t=e.createObjectStore("newChunks",{keyPath:["hash","chunkIndex"]});t.createIndex("hash","hash",{unique:!1}),t.createIndex("merkleRoot","merkleRoot",{unique:!1}),t.createIndex("realChunkHash","realChunkHash",{unique:!0})}if(e.objectStoreNames.contains("sendQueue")){const e=n.objectStore("sendQueue");e.indexNames.contains("labelPeer")||e.createIndex("labelPeer",["label","toPeerId"],{unique:!1})}else{e.createObjectStore("sendQueue",{keyPath:["position","label","toPeerId"]}).createIndex("labelPeer",["label","toPeerId"],{unique:!1})}}})}async function R(){await function(e,{blocked:t}={}){const a=indexedDB.deleteDatabase(e);return t&&a.addEventListener("blocked",e=>t(e.oldVersion,e)),d(a).then(()=>{})}(B,{blocked(){console.error("DB deletion BLOCKED")}})}onmessage=async e=>{const t=e.data,{id:a,method:n}=t;try{let e;switch(n){case"getDBAddressBookEntry":e=await async function(e,t){if(!e&&!t)return;if(e&&e.length<10&&!t)return;if(t&&64!==t.length&&!e)return;const a=await S();try{const n=a.transaction("addressBook","readonly"),o=e?n.objectStore("addressBook").index("peerId"):n.objectStore("addressBook").index("peerPublicKey"),r=e?await o.get(e):await o.get(t);return await n.done,a.close(),r?{username:r.username,peerId:r.peerId,peerPublicKey:r.peerPublicKey}:void 0}catch(e){return void a.close()}}(...t.args);break;case"getAllDBAddressBookEntries":e=await async function(){try{const e=await S(),t=await e.getAll("addressBook");return e.close(),t}catch(e){return[]}}(...t.args);break;case"setDBAddressBookEntry":e=await async function(e,t,a){try{const n=await S(),o=n.transaction(["addressBook"],"readwrite"),r=o.objectStore("addressBook"),s=r.index("peerId"),i=r.index("peerPublicKey"),c=await s.get(t),u=await i.get(a);(!c&&!u||c&&!u||!c&&u)&&await r.put({username:e,peerId:t,peerPublicKey:a,dateAdded:Date.now()}),await o.done,n.close()}catch(e){console.error(e)}}(...t.args);break;case"deleteDBAddressBookEntry":e=await async function(e,t,a){const n=!e||0===e.length,o=!t||t.length<10,r=!a||64!==a.length;if(n&&o&&r)throw new Error("Cannot delete address book with no data");let s=t??"";try{const n=await S(),i=n.transaction("addressBook","readwrite"),c=i.objectStore("addressBook");if(o)if(r){const t=c.index("username"),a=await t.getKey(e);if(a){const n=await t.get(e);s=n?.peerId??"",await c.delete(a)}}else{const e=c.index("peerPublicKey"),t=await e.getKey(a);if(t){const n=await e.get(a);s=n?.peerId??"",await c.delete(t)}}else{const e=c.index("peerId"),a=await e.getKey(t);a&&await c.delete(a)}await i.done,n.close()}catch{}return s}(...t.args);break;case"getDBPeerIsBlacklisted":e=await async function(e,t){if(!e&&!t)return!1;if(e&&e.length<10&&!t)return!1;if(t&&64!==t.length&&!e)return!1;try{const a=await S(),n=a.transaction("blacklist","readonly"),o=e?n.objectStore("blacklist").index("peerId"):n.objectStore("blacklist").index("peerPublicKey"),r=e?await o.get(e):await o.get(t);return await n.done,a.close(),!!r}catch(e){return!1}}(...t.args);break;case"getAllDBBlacklisted":e=await async function(){const e=await S();try{const t=await e.getAll("blacklist");return e.close(),t}catch(t){return e.close(),[]}}(...t.args);break;case"setDBPeerInBlacklist":e=await async function(e,t){try{const a=await S(),n=a.transaction(["blacklist"],"readwrite"),o=n.objectStore("blacklist"),r=o.index("peerId"),s=o.index("peerPublicKey"),i=await r.get(e),c=await s.get(t);(!i&&!c||i&&!c||!i&&c)&&await o.put({peerId:e,peerPublicKey:t,dateAdded:Date.now()}),await n.done,a.close()}catch(e){console.error(e)}}(...t.args);break;case"deleteDBPeerFromBlacklist":e=await async function(e,t){const a=!e||e.length<10,n=!t||64!==t.length;if(a&&n)throw new Error("Cannot delete blacklisted with no data");try{const n=await S(),o=n.transaction("blacklist","readwrite"),r=o.objectStore("blacklist");if(a){const e=r.index("peerPublicKey"),a=await e.getKey(t);a&&await r.delete(a)}else{const t=r.index("peerId"),a=await t.getKey(e);a&&await r.delete(a)}await o.done,n.close()}catch(e){console.error(e)}}(...t.args);break;case"getAllDBUniqueRooms":e=await async function(){const e=await S();try{const t=await e.getAll("uniqueRoom");return e.close(),t}catch(t){return e.close(),[]}}(...t.args);break;case"setDBUniqueRoom":e=await async function(e,t){try{const a=await S(),n=a.transaction(["uniqueRoom"],"readwrite"),o=n.objectStore("uniqueRoom"),r=o.index("roomUrl"),s=o.index("roomId"),i=await r.get(e),c=await s.get(t);if(!i&&!c){const a=Date.now();await o.put({roomId:t,roomUrl:e,messageCount:0,lastMessageMerkleRoot:"",createdAt:a,updatedAt:a})}await n.done,a.close()}catch(e){console.error(e)}}(...t.args);break;case"getDBMessageData":e=await async function(e,t){try{const a=await S(),n=a.transaction(["messageData"],"readonly"),o=n.objectStore("messageData"),r=o.index("merkleRoot"),s=o.index("hash");if(e&&e.length===2*D){const o=await r.get(e);if(o)return await n.done,a.close(),o;if(t&&t.length===2*D){const e=await s.get(t);return await n.done,a.close(),e}return await n.done,void a.close()}if(t&&t.length===2*D){const e=await s.get(t);return await n.done,a.close(),e}return await n.done,void a.close()}catch(e){return void console.error(e)}}(...t.args);break;case"getDBRoomMessageData":e=await async function(e){const t=await S(),a=await t.getAllFromIndex("messageData","roomId",e);t.close();const n=a.length,o=[];for(let t=0;t<n;t++)o.push({roomId:e,merkleRoot:a[t].merkleRoot,hash:a[t].hash,fromPeerId:a[t].fromPeerId,filename:a[t].filename,messageType:a[t].messageType,savedSize:a[t].savedSize,totalSize:a[t].totalSize,channelLabel:a[t].channelLabel,timestamp:a[t].timestamp});return o}(...t.args);break;case"setDBRoomMessageData":e=await async function(e,t,a,n,o,r,s,i,c,u){try{const d=await S(),l=d.transaction(["messageData","uniqueRoom"],"readwrite"),w=l.objectStore("messageData"),h=await w.index("merkleRoot").get(t),m=h?.savedSize??0;try{await w.put({roomId:e,timestamp:u,merkleRoot:t,hash:a,fromPeerId:n,filename:i,messageType:s,savedSize:m!==r?o+m:o,totalSize:r,channelLabel:c})}catch(e){throw await l.done,d.close(),e}const g=l.objectStore("uniqueRoom"),k=await g.index("roomId").get(e);if(k&&k.lastMessageMerkleRoot!==t)try{await g.put({...k,lastMessageMerkleRoot:t,messageCount:k.messageCount+1,updatedAt:Date.now()})}catch(e){throw await l.done,d.close(),e}await l.done,d.close()}catch(e){throw console.error(e),e}}(...t.args);break;case"getDBChunk":e=await async function(e,t){const a=await S(),n=await a.get("chunks",[e,t]);return a.close(),n?.data}(...t.args);break;case"existsDBChunk":e=await async function(e,t){const a=await S(),n=await a.count("chunks",[e,t]);return a.close(),n>0}(...t.args);break;case"getDBNewChunk":e=await async function(e,t){try{const a=await S(),n=t??-1;if(n>-1){const t=await a.get("newChunks",[e,n]);return a.close(),t}{const t=a.transaction("newChunks"),n=t.objectStore("newChunks").index("realChunkHash"),o=await n.get(e);return await t.done,a.close(),o}}catch(e){return void console.error(e)}}(...t.args);break;case"existsDBNewChunk":e=await async function(e,t){const a=await S(),n=await a.count("newChunks",[e,t]);return a.close(),n>0}(...t.args);break;case"getDBSendQueue":e=await async function(e,t,a){const n=await S();if(a){const o=await n.get("sendQueue",[a,e,t]);return n.close(),o?[o]:[]}const o=n.transaction("sendQueue","readonly").objectStore("sendQueue").index("labelPeer"),r=IDBKeyRange.only([e,t]),s=await o.getAll(r);return n.close(),s}(...t.args);break;case"getDBAllChunks":e=await async function(e,t){try{const a=await S(),n=a.transaction("chunks","readonly"),o=n.objectStore("chunks"),r=o.index("hash"),s=o.index("merkleRoot");if(e&&e.length===2*D){const t=await s.getAll(e);return 0===t.length?(await n.done,a.close(),[]):(await n.done,a.close(),t)}if(t&&t.length===2*D){const e=await r.getAll(t);return await n.done,a.close(),e}return await n.done,a.close(),[]}catch(e){return console.error(e),[]}}(...t.args);break;case"getDBAllChunksCount":e=await async function(e,t){try{const a=await S(),n=a.transaction(["chunks"],"readonly"),o=n.objectStore("chunks"),r=o.index("hash"),s=o.index("merkleRoot");if(t&&t.length===2*D){const o=await r.count(t);if(0===o){if(e&&e.length===2*D){const t=await s.count(e);return await n.done,a.close(),t}return await n.done,a.close(),0}return await n.done,a.close(),o}if(e&&e.length===2*D){const t=await s.count(e);return await n.done,a.close(),t}return await n.done,a.close(),0}catch(e){return 0}}(...t.args);break;case"setDBChunk":e=await async function(e){const t=await S();try{await t.add("chunks",e)}catch(e){}t.close()}(...t.args);break;case"getDBAllNewChunks":e=await async function(e,t){if(!e&&!t)return[];if(e?.length!==2*D&&t?.length!==2*D)return[];const a=await S();if((e?await a.countFromIndex("newChunks","hash",e):await a.countFromIndex("newChunks","merkleRoot",t))>0){const n=e?await a.getAllFromIndex("newChunks","hash",e):await a.getAllFromIndex("newChunks","merkleRoot",t);return a.close(),n}{const n=a.transaction("newChunks","readonly").objectStore("newChunks"),o=e?n.index("hash"):n.index("merkleRoot"),r=e?IDBKeyRange.only(e):IDBKeyRange.only(t),s=await o.getAll(r);return a.close(),s}}(...t.args);break;case"getDBAllNewChunksCount":e=await async function(e){const t=await S(),a=await t.countFromIndex("newChunks","hash",e);return t.close(),a}(...t.args);break;case"setDBNewChunk":e=await async function(e){const t=await S();await t.put("newChunks",e),t.close()}(...t.args);break;case"setDBSendQueue":e=await async function(e){const t=await S();await t.put("sendQueue",e),t.close()}(...t.args);break;case"countDBSendQueue":e=await async function(e,t){const a=await S(),n=a.transaction("sendQueue","readonly").objectStore("sendQueue").index("labelPeer"),o=IDBKeyRange.only([e,t]),r=await n.count(o);return a.close(),r}(...t.args);break;case"deleteDBChunk":e=await async function(e,t){try{const a=await S(),n=a.transaction("chunks","readwrite"),o=n.objectStore("chunks");if(t){const a=IDBKeyRange.only([e,t]);await o.delete(a)}else{const t=o.index("hash"),a=await t.getAllKeys(e),n=a.length;if(0===n){const t=o.index("merkleRoot"),a=await t.getAllKeys(e),n=a.length;for(let e=0;e<n;e++)await o.delete(a[e])}else for(let e=0;e<n;e++)await o.delete(a[e])}await n.done,a.close()}catch(e){}}(...t.args);break;case"deleteDBNewChunk":e=await async function(e,t,a,n){try{const o=await S(),r=o.transaction("newChunks","readwrite"),s=r.objectStore("newChunks");if(e){const t=s.index("merkleRoot"),a=await t.getAllKeys(e),n=a.length;for(let e=0;e<n;e++)await s.delete(a[e])}else if(a&&n)await s.delete([a,n]);else if(a){const e=s.index("hash"),t=await e.getAllKeys(a),n=t.length;for(let e=0;e<n;e++)await s.delete(t[e])}else if(t){const e=s.index("realChunkHash"),a=await e.getKey(t);a&&await s.delete(a)}await r.done,o.close()}catch(e){console.error(e)}}(...t.args);break;case"deleteDBMessageData":e=await async function(e){try{const t=await S(),a=t.transaction(["messageData","uniqueRoom"],"readwrite"),n=a.objectStore("messageData"),o=a.objectStore("uniqueRoom"),r=n.index("merkleRoot"),s=await r.getAllKeys(e),i=s.length;let c="";for(let e=0;e<i;e++){if(0===e||0===c.length){const t=await n.get(s[e]);c=t?.roomId??""}await n.delete(s[e])}if(c.length>0){const e=o.index("roomId"),t=await e.get(c);if(t){const e=n.index("roomId"),a=await e.getAllKeys(c),r=a.length,s=r>0?await n.get(a[r-1]):void 0;await o.put({...t,messageCount:t.messageCount>0?t.messageCount-1:0,updatedAt:s?.timestamp??Date.now(),lastMessageMerkleRoot:s?.merkleRoot??""})}}await a.done,t.close()}catch(e){}}(...t.args);break;case"deleteDBUniqueRoom":e=await async function(e){try{const t=await S(),a=t.transaction("uniqueRoom","readwrite"),n=a.objectStore("uniqueRoom"),o=n.index("roomId"),r=await o.getKey(e);r&&await n.delete(r),await a.done,t.close()}catch(e){}}(...t.args);break;case"deleteDBSendQueue":e=await async function(e,t,a){try{const n=await S();if(a)await n.delete("sendQueue",[a,e,t]);else{const a=IDBKeyRange.only([e,t]);await n.delete("sendQueue",a)}n.close()}catch(e){}}(...t.args);break;case"deleteDB":e=await R();break;default:return void postMessage({id:a,error:"Method not found"})}postMessage({id:a,result:e})}catch(e){postMessage({id:a,error:String(e)})}};
2
2
  //# sourceMappingURL=db.worker.js.map
@@ -1,5 +1,5 @@
1
- import type { MiddlewareAPI, Dispatch, UnknownAction } from "@reduxjs/toolkit";
1
+ import type { MiddlewareAPI } from "@reduxjs/toolkit";
2
2
  import type { KeyPair } from "../reducers/keyPairSlice";
3
- declare const handleChallenge: (keyPair: KeyPair, peerId: string, challenge: string, store: MiddlewareAPI<Dispatch<UnknownAction>, any>) => Promise<void>;
3
+ declare const handleChallenge: (keyPair: KeyPair, peerId: string, challenge: string, store: MiddlewareAPI) => Promise<void>;
4
4
  export default handleChallenge;
5
5
  //# sourceMappingURL=handleChallenge.d.ts.map
@@ -11,5 +11,5 @@ export interface OpenChannelHelperParams {
11
11
  }
12
12
  export declare const KB64: number;
13
13
  export declare const MAX_BUFFERED_AMOUNT: number;
14
- export declare const handleOpenChannel: ({ channel, epc, roomId, dataChannels, decryptionModule, merkleModule, }: OpenChannelHelperParams, api: BaseQueryApi) => Promise<IRTCDataChannel>;
14
+ export declare const handleOpenChannel: ({ channel, epc, roomId, dataChannels, decryptionModule, merkleModule, }: OpenChannelHelperParams, api: BaseQueryApi) => IRTCDataChannel;
15
15
  //# sourceMappingURL=handleOpenChannel.d.ts.map
package/lib/index.d.ts CHANGED
@@ -62,12 +62,12 @@ export declare const p2party: {
62
62
  signalingServerSelector: (state: State) => SignalingState;
63
63
  roomSelector: (state: State) => Room[];
64
64
  keyPairSelector: (state: State) => KeyPair;
65
- connect: (roomUrl: string, signalingServerUrl?: string, rtcConfig?: RTCConfiguration) => void;
66
- connectToSignalingServer: (roomUrl: string, signalingServerUrl?: string) => void;
67
- disconnectFromSignalingServer: () => void;
68
- disconnectFromRoom: (roomId: string, deleteMessages?: boolean) => void;
69
- disconnectFromAllRooms: (deleteMessages?: boolean, exceptionRoomIds?: string[]) => void;
70
- disconnectFromPeer: (peerId: string) => void;
65
+ connect: (roomUrl: string, signalingServerUrl?: string, rtcConfig?: RTCConfiguration) => Promise<void>;
66
+ connectToSignalingServer: (roomUrl: string, signalingServerUrl?: string) => Promise<void>;
67
+ disconnectFromSignalingServer: () => Promise<void>;
68
+ disconnectFromRoom: (roomId: string, deleteMessages?: boolean) => Promise<void>;
69
+ disconnectFromAllRooms: (deleteMessages?: boolean, exceptionRoomIds?: string[]) => Promise<void>;
70
+ disconnectFromPeer: (peerId: string) => Promise<void>;
71
71
  allowConnectionRelay: (roomId: string, allowed?: boolean) => void;
72
72
  onlyAllowConnectionsFromAddressBook: (roomUrl: string, onlyAllow: boolean) => Promise<void>;
73
73
  addPeerToAddressBook: (username: string, peerId: string, peerPublicKey: string) => Promise<void>;
@@ -83,8 +83,8 @@ export declare const p2party: {
83
83
  peerId: string;
84
84
  peerPublicKey: string;
85
85
  }[]) => Promise<void>;
86
- sendMessage: (data: string | File, toChannel: string, roomId: string, percentageFilledChunk?: number, minChunks?: number, chunkSize?: number, metadataSchemaVersion?: number) => void;
87
- readMessage: (merkleRootHex?: string, hashHex?: string) => Promise<{
86
+ sendMessage: (data: string | File, toChannel: string, roomId: string, percentageFilledChunk?: number, minChunks?: number, chunkSize?: number, metadataSchemaVersion?: number) => Promise<void>;
87
+ readMessage: (merkleRootHex: string) => Promise<{
88
88
  message: string | Blob;
89
89
  percentage: number;
90
90
  size: number;
@@ -93,10 +93,10 @@ export declare const p2party: {
93
93
  extension: FileExtension;
94
94
  category: string;
95
95
  }>;
96
- cancelMessage: (channelLabel: string, merkleRoot?: string | Uint8Array, hash?: string | Uint8Array) => Promise<void>;
96
+ cancelMessage: (channelLabel: string, merkleRoot: string | Uint8Array) => Promise<void>;
97
97
  deleteMessage: (merkleRoot?: string | Uint8Array, hash?: string | Uint8Array) => Promise<void>;
98
- purgeIdentity: () => void;
99
- purgeRoom: (roomUrl: string) => void;
98
+ purgeIdentity: () => Promise<void>;
99
+ purgeRoom: (roomUrl: string) => Promise<void>;
100
100
  purge: () => Promise<void>;
101
101
  generateRandomRoomUrl: () => Promise<string>;
102
102
  encrypt: (message: Uint8Array, receiverPublicKey: Uint8Array, senderSecretKey: Uint8Array, additionalData: Uint8Array, module?: import("./cryptography/libcrypto").LibCrypto) => Promise<Uint8Array>;