@waku/sds 0.0.4-f911bf8.0 → 0.0.5-2ed5ddc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/bundle/index.js +6416 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/{bloom.js → bloom_filter/bloom.js} +2 -2
- package/dist/bloom_filter/bloom.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/message_channel/command_queue.d.ts +29 -0
- package/dist/message_channel/command_queue.js +7 -0
- package/dist/message_channel/command_queue.js.map +1 -0
- package/dist/message_channel/events.d.ts +32 -0
- package/dist/message_channel/events.js +19 -0
- package/dist/message_channel/events.js.map +1 -0
- package/dist/message_channel/index.d.ts +3 -0
- package/dist/message_channel/index.js +4 -0
- package/dist/message_channel/index.js.map +1 -0
- package/dist/message_channel/message_channel.d.ts +142 -0
- package/dist/{sds.js → message_channel/message_channel.js} +265 -111
- package/dist/message_channel/message_channel.js.map +1 -0
- package/package.json +1 -1
- package/src/{bloom.ts → bloom_filter/bloom.ts} +2 -2
- package/src/index.ts +15 -1
- package/src/message_channel/command_queue.ts +33 -0
- package/src/message_channel/events.ts +41 -0
- package/src/message_channel/index.ts +3 -0
- package/src/{sds.ts → message_channel/message_channel.ts} +311 -134
- package/dist/bloom.js.map +0 -1
- package/dist/sds.d.ts +0 -108
- package/dist/sds.js.map +0 -1
- /package/dist/{bloom.d.ts → bloom_filter/bloom.d.ts} +0 -0
@@ -1,31 +1,42 @@
|
|
1
1
|
import { TypedEventEmitter } from "@libp2p/interface";
|
2
2
|
import { sha256 } from "@noble/hashes/sha256";
|
3
3
|
import { bytesToHex } from "@noble/hashes/utils";
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
})(MessageChannelEvent || (MessageChannelEvent = {}));
|
4
|
+
import { Logger } from "@waku/utils";
|
5
|
+
import { DefaultBloomFilter } from "../bloom_filter/bloom.js";
|
6
|
+
import { Command } from "./command_queue.js";
|
7
|
+
import { MessageChannelEvent } from "./events.js";
|
9
8
|
export const DEFAULT_BLOOM_FILTER_OPTIONS = {
|
10
9
|
capacity: 10000,
|
11
10
|
errorRate: 0.001
|
12
11
|
};
|
13
12
|
const DEFAULT_CAUSAL_HISTORY_SIZE = 2;
|
14
13
|
const DEFAULT_RECEIVED_MESSAGE_TIMEOUT = 1000 * 60 * 5; // 5 minutes
|
14
|
+
const log = new Logger("sds:message-channel");
|
15
15
|
export class MessageChannel extends TypedEventEmitter {
|
16
|
+
channelId;
|
16
17
|
lamportTimestamp;
|
17
18
|
filter;
|
18
19
|
outgoingBuffer;
|
19
20
|
acknowledgements;
|
20
21
|
incomingBuffer;
|
21
22
|
localHistory;
|
22
|
-
channelId;
|
23
23
|
causalHistorySize;
|
24
24
|
acknowledgementCount;
|
25
25
|
timeReceived;
|
26
26
|
receivedMessageTimeoutEnabled;
|
27
27
|
receivedMessageTimeout;
|
28
|
-
|
28
|
+
tasks = [];
|
29
|
+
handlers = {
|
30
|
+
[Command.Send]: async (params) => {
|
31
|
+
await this._sendMessage(params.payload, params.callback);
|
32
|
+
},
|
33
|
+
[Command.Receive]: async (params) => {
|
34
|
+
this._receiveMessage(params.message);
|
35
|
+
},
|
36
|
+
[Command.SendEphemeral]: async (params) => {
|
37
|
+
await this._sendEphemeralMessage(params.payload, params.callback);
|
38
|
+
}
|
39
|
+
};
|
29
40
|
constructor(channelId, options = {}) {
|
30
41
|
super();
|
31
42
|
this.channelId = channelId;
|
@@ -43,55 +54,72 @@ export class MessageChannel extends TypedEventEmitter {
|
|
43
54
|
options.receivedMessageTimeoutEnabled ?? false;
|
44
55
|
this.receivedMessageTimeout =
|
45
56
|
options.receivedMessageTimeout ?? DEFAULT_RECEIVED_MESSAGE_TIMEOUT;
|
46
|
-
this.deliveredMessageCallback = options.deliveredMessageCallback;
|
47
57
|
}
|
48
58
|
static getMessageId(payload) {
|
49
59
|
return bytesToHex(sha256(payload));
|
50
60
|
}
|
51
61
|
/**
|
52
|
-
*
|
62
|
+
* Processes all queued tasks sequentially to ensure proper message ordering.
|
53
63
|
*
|
54
|
-
*
|
55
|
-
*
|
64
|
+
* This method should be called periodically by the library consumer to execute
|
65
|
+
* queued send/receive operations in the correct sequence.
|
56
66
|
*
|
57
|
-
*
|
58
|
-
*
|
59
|
-
*
|
60
|
-
* light push or relay.
|
67
|
+
* @example
|
68
|
+
* ```typescript
|
69
|
+
* const channel = new MessageChannel("my-channel");
|
61
70
|
*
|
62
|
-
*
|
71
|
+
* // Queue some operations
|
72
|
+
* await channel.sendMessage(payload, callback);
|
73
|
+
* channel.receiveMessage(incomingMessage);
|
63
74
|
*
|
64
|
-
*
|
65
|
-
*
|
75
|
+
* // Process all queued operations
|
76
|
+
* await channel.processTasks();
|
77
|
+
* ```
|
78
|
+
*
|
79
|
+
* @throws Will emit a 'taskError' event if any task fails, but continues processing remaining tasks
|
66
80
|
*/
|
67
|
-
async
|
68
|
-
this.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
channelId: this.channelId,
|
73
|
-
lamportTimestamp: this.lamportTimestamp,
|
74
|
-
causalHistory: this.localHistory
|
75
|
-
.slice(-this.causalHistorySize)
|
76
|
-
.map(({ historyEntry }) => historyEntry),
|
77
|
-
bloomFilter: this.filter.toBytes(),
|
78
|
-
content: payload
|
79
|
-
};
|
80
|
-
this.outgoingBuffer.push(message);
|
81
|
-
if (callback) {
|
82
|
-
const { success, retrievalHint } = await callback(message);
|
83
|
-
if (success) {
|
84
|
-
this.filter.insert(messageId);
|
85
|
-
this.localHistory.push({
|
86
|
-
timestamp: this.lamportTimestamp,
|
87
|
-
historyEntry: {
|
88
|
-
messageId,
|
89
|
-
retrievalHint
|
90
|
-
}
|
91
|
-
});
|
81
|
+
async processTasks() {
|
82
|
+
while (this.tasks.length > 0) {
|
83
|
+
const item = this.tasks.shift();
|
84
|
+
if (!item) {
|
85
|
+
continue;
|
92
86
|
}
|
87
|
+
await this.executeTask(item);
|
93
88
|
}
|
94
89
|
}
|
90
|
+
/**
|
91
|
+
* Queues a message to be sent on this channel.
|
92
|
+
*
|
93
|
+
* The message will be processed sequentially when processTasks() is called.
|
94
|
+
* This ensures proper lamport timestamp ordering and causal history tracking.
|
95
|
+
*
|
96
|
+
* @param payload - The message content as a byte array
|
97
|
+
* @param callback - Optional callback function called after the message is processed
|
98
|
+
* @returns Promise that resolves when the message is queued (not sent)
|
99
|
+
*
|
100
|
+
* @example
|
101
|
+
* ```typescript
|
102
|
+
* const channel = new MessageChannel("chat-room");
|
103
|
+
* const message = new TextEncoder().encode("Hello, world!");
|
104
|
+
*
|
105
|
+
* await channel.sendMessage(message, async (processedMessage) => {
|
106
|
+
* console.log("Message processed:", processedMessage.messageId);
|
107
|
+
* return { success: true };
|
108
|
+
* });
|
109
|
+
*
|
110
|
+
* // Actually send the message
|
111
|
+
* await channel.processTasks();
|
112
|
+
* ```
|
113
|
+
*/
|
114
|
+
async sendMessage(payload, callback) {
|
115
|
+
this.tasks.push({
|
116
|
+
command: Command.Send,
|
117
|
+
params: {
|
118
|
+
payload,
|
119
|
+
callback
|
120
|
+
}
|
121
|
+
});
|
122
|
+
}
|
95
123
|
/**
|
96
124
|
* Sends a short-lived message without synchronization or reliability requirements.
|
97
125
|
*
|
@@ -105,64 +133,58 @@ export class MessageChannel extends TypedEventEmitter {
|
|
105
133
|
* @param payload - The payload to send.
|
106
134
|
* @param callback - A callback function that returns a boolean indicating whether the message was sent successfully.
|
107
135
|
*/
|
108
|
-
sendEphemeralMessage(payload, callback) {
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
};
|
117
|
-
if (callback) {
|
118
|
-
callback(message);
|
119
|
-
}
|
136
|
+
async sendEphemeralMessage(payload, callback) {
|
137
|
+
this.tasks.push({
|
138
|
+
command: Command.SendEphemeral,
|
139
|
+
params: {
|
140
|
+
payload,
|
141
|
+
callback
|
142
|
+
}
|
143
|
+
});
|
120
144
|
}
|
121
145
|
/**
|
122
|
-
*
|
146
|
+
* Queues a received message for processing.
|
147
|
+
*
|
148
|
+
* The message will be processed when processTasks() is called, ensuring
|
149
|
+
* proper dependency resolution and causal ordering.
|
123
150
|
*
|
124
|
-
*
|
125
|
-
* by inspecting the received message's bloom filter and causal history.
|
126
|
-
* Add the received message to the bloom filter.
|
127
|
-
* If the local history contains every message in the received message's
|
128
|
-
* causal history, deliver the message. Otherwise, add the message to the
|
129
|
-
* incoming buffer.
|
151
|
+
* @param message - The message to receive and process
|
130
152
|
*
|
131
|
-
*
|
153
|
+
* @example
|
154
|
+
* ```typescript
|
155
|
+
* const channel = new MessageChannel("chat-room");
|
132
156
|
*
|
133
|
-
*
|
157
|
+
* // Receive a message from the network
|
158
|
+
* channel.receiveMessage(incomingMessage);
|
159
|
+
*
|
160
|
+
* // Process the received message
|
161
|
+
* await channel.processTasks();
|
162
|
+
* ```
|
134
163
|
*/
|
135
164
|
receiveMessage(message) {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
this.reviewAckStatus(message);
|
143
|
-
// add to bloom filter (skip for messages with empty content)
|
144
|
-
if (message.content?.length && message.content.length > 0) {
|
145
|
-
this.filter.insert(message.messageId);
|
146
|
-
}
|
147
|
-
// verify causal history
|
148
|
-
const dependenciesMet = message.causalHistory.every((historyEntry) => this.localHistory.some(({ historyEntry: { messageId } }) => messageId === historyEntry.messageId));
|
149
|
-
if (!dependenciesMet) {
|
150
|
-
this.incomingBuffer.push(message);
|
151
|
-
this.timeReceived.set(message.messageId, Date.now());
|
152
|
-
}
|
153
|
-
else {
|
154
|
-
this.deliverMessage(message);
|
155
|
-
}
|
165
|
+
this.tasks.push({
|
166
|
+
command: Command.Receive,
|
167
|
+
params: {
|
168
|
+
message
|
169
|
+
}
|
170
|
+
});
|
156
171
|
}
|
157
|
-
|
172
|
+
/**
|
173
|
+
* Processes messages in the incoming buffer, delivering those with satisfied dependencies.
|
174
|
+
*
|
175
|
+
* @returns Array of history entries for messages still missing dependencies
|
176
|
+
*/
|
158
177
|
sweepIncomingBuffer() {
|
159
178
|
const { buffer, missing } = this.incomingBuffer.reduce(({ buffer, missing }, message) => {
|
160
|
-
// Check each message for missing dependencies
|
161
179
|
const missingDependencies = message.causalHistory.filter((messageHistoryEntry) => !this.localHistory.some(({ historyEntry: { messageId } }) => messageId === messageHistoryEntry.messageId));
|
162
180
|
if (missingDependencies.length === 0) {
|
163
|
-
// Any message with no missing dependencies is delivered
|
164
|
-
// and removed from the buffer (implicitly by not adding it to the new incoming buffer)
|
165
181
|
this.deliverMessage(message);
|
182
|
+
this.safeSendEvent(MessageChannelEvent.MessageDelivered, {
|
183
|
+
detail: {
|
184
|
+
messageId: message.messageId,
|
185
|
+
sentOrReceived: "received"
|
186
|
+
}
|
187
|
+
});
|
166
188
|
return { buffer, missing };
|
167
189
|
}
|
168
190
|
// Optionally, if a message has not been received after a predetermined amount of time,
|
@@ -174,20 +196,22 @@ export class MessageChannel extends TypedEventEmitter {
|
|
174
196
|
return { buffer, missing };
|
175
197
|
}
|
176
198
|
}
|
177
|
-
|
178
|
-
|
199
|
+
missingDependencies.forEach((dependency) => {
|
200
|
+
missing.add(dependency);
|
201
|
+
});
|
179
202
|
return {
|
180
203
|
buffer: buffer.concat(message),
|
181
|
-
missing
|
204
|
+
missing
|
182
205
|
};
|
183
|
-
}, { buffer: new Array(), missing: new
|
184
|
-
// Update the incoming buffer to only include messages with no missing dependencies
|
206
|
+
}, { buffer: new Array(), missing: new Set() });
|
185
207
|
this.incomingBuffer = buffer;
|
186
|
-
|
208
|
+
this.safeSendEvent(MessageChannelEvent.MissedMessages, {
|
209
|
+
detail: Array.from(missing)
|
210
|
+
});
|
211
|
+
return Array.from(missing);
|
187
212
|
}
|
188
213
|
// https://rfc.vac.dev/vac/raw/sds/#periodic-outgoing-buffer-sweep
|
189
214
|
sweepOutgoingBuffer() {
|
190
|
-
// Partition all messages in the outgoing buffer into unacknowledged and possibly acknowledged messages
|
191
215
|
return this.outgoingBuffer.reduce(({ unacknowledged, possiblyAcknowledged }, message) => {
|
192
216
|
if (this.acknowledgements.has(message.messageId)) {
|
193
217
|
return {
|
@@ -214,7 +238,7 @@ export class MessageChannel extends TypedEventEmitter {
|
|
214
238
|
*
|
215
239
|
* @param callback - A callback function that returns a boolean indicating whether the message was sent successfully.
|
216
240
|
*/
|
217
|
-
sendSyncMessage(callback) {
|
241
|
+
async sendSyncMessage(callback) {
|
218
242
|
this.lamportTimestamp++;
|
219
243
|
const emptyMessage = new Uint8Array();
|
220
244
|
const message = {
|
@@ -228,13 +252,139 @@ export class MessageChannel extends TypedEventEmitter {
|
|
228
252
|
content: emptyMessage
|
229
253
|
};
|
230
254
|
if (callback) {
|
231
|
-
|
255
|
+
try {
|
256
|
+
await callback(message);
|
257
|
+
this.safeSendEvent(MessageChannelEvent.SyncSent, {
|
258
|
+
detail: message
|
259
|
+
});
|
260
|
+
return true;
|
261
|
+
}
|
262
|
+
catch (error) {
|
263
|
+
log.error("Callback execution failed in sendSyncMessage:", error);
|
264
|
+
throw error;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
_receiveMessage(message) {
|
270
|
+
const isDuplicate = message.content &&
|
271
|
+
message.content.length > 0 &&
|
272
|
+
this.timeReceived.has(message.messageId);
|
273
|
+
if (isDuplicate) {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
if (!message.lamportTimestamp) {
|
277
|
+
this.deliverMessage(message);
|
278
|
+
return;
|
279
|
+
}
|
280
|
+
if (message.content?.length === 0) {
|
281
|
+
this.safeSendEvent(MessageChannelEvent.SyncReceived, {
|
282
|
+
detail: message
|
283
|
+
});
|
284
|
+
}
|
285
|
+
else {
|
286
|
+
this.safeSendEvent(MessageChannelEvent.MessageReceived, {
|
287
|
+
detail: message
|
288
|
+
});
|
289
|
+
}
|
290
|
+
this.reviewAckStatus(message);
|
291
|
+
if (message.content?.length && message.content.length > 0) {
|
292
|
+
this.filter.insert(message.messageId);
|
293
|
+
}
|
294
|
+
const dependenciesMet = message.causalHistory.every((historyEntry) => this.localHistory.some(({ historyEntry: { messageId } }) => messageId === historyEntry.messageId));
|
295
|
+
if (!dependenciesMet) {
|
296
|
+
this.incomingBuffer.push(message);
|
297
|
+
this.timeReceived.set(message.messageId, Date.now());
|
298
|
+
}
|
299
|
+
else {
|
300
|
+
this.deliverMessage(message);
|
301
|
+
this.safeSendEvent(MessageChannelEvent.MessageDelivered, {
|
302
|
+
detail: {
|
303
|
+
messageId: message.messageId,
|
304
|
+
sentOrReceived: "received"
|
305
|
+
}
|
306
|
+
});
|
307
|
+
}
|
308
|
+
}
|
309
|
+
async executeTask(item) {
|
310
|
+
try {
|
311
|
+
const handler = this.handlers[item.command];
|
312
|
+
await handler(item.params);
|
313
|
+
}
|
314
|
+
catch (error) {
|
315
|
+
log.error(`Task execution failed for command ${item.command}:`, error);
|
316
|
+
this.dispatchEvent(new CustomEvent("taskError", {
|
317
|
+
detail: { command: item.command, error, params: item.params }
|
318
|
+
}));
|
319
|
+
}
|
320
|
+
}
|
321
|
+
safeSendEvent(event, eventInit) {
|
322
|
+
try {
|
323
|
+
this.dispatchEvent(new CustomEvent(event, eventInit));
|
324
|
+
}
|
325
|
+
catch (error) {
|
326
|
+
log.error(`Failed to dispatch event ${event}:`, error);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
async _sendMessage(payload, callback) {
|
330
|
+
this.lamportTimestamp++;
|
331
|
+
const messageId = MessageChannel.getMessageId(payload);
|
332
|
+
const message = {
|
333
|
+
messageId,
|
334
|
+
channelId: this.channelId,
|
335
|
+
lamportTimestamp: this.lamportTimestamp,
|
336
|
+
causalHistory: this.localHistory
|
337
|
+
.slice(-this.causalHistorySize)
|
338
|
+
.map(({ historyEntry }) => historyEntry),
|
339
|
+
bloomFilter: this.filter.toBytes(),
|
340
|
+
content: payload
|
341
|
+
};
|
342
|
+
this.outgoingBuffer.push(message);
|
343
|
+
if (callback) {
|
344
|
+
try {
|
345
|
+
const { success, retrievalHint } = await callback(message);
|
346
|
+
if (success) {
|
347
|
+
this.filter.insert(messageId);
|
348
|
+
this.localHistory.push({
|
349
|
+
timestamp: this.lamportTimestamp,
|
350
|
+
historyEntry: {
|
351
|
+
messageId,
|
352
|
+
retrievalHint
|
353
|
+
}
|
354
|
+
});
|
355
|
+
this.timeReceived.set(messageId, Date.now());
|
356
|
+
this.safeSendEvent(MessageChannelEvent.MessageSent, {
|
357
|
+
detail: message
|
358
|
+
});
|
359
|
+
}
|
360
|
+
}
|
361
|
+
catch (error) {
|
362
|
+
log.error("Callback execution failed in _sendMessage:", error);
|
363
|
+
throw error;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
async _sendEphemeralMessage(payload, callback) {
|
368
|
+
const message = {
|
369
|
+
messageId: MessageChannel.getMessageId(payload),
|
370
|
+
channelId: this.channelId,
|
371
|
+
content: payload,
|
372
|
+
lamportTimestamp: undefined,
|
373
|
+
causalHistory: [],
|
374
|
+
bloomFilter: undefined
|
375
|
+
};
|
376
|
+
if (callback) {
|
377
|
+
try {
|
378
|
+
await callback(message);
|
379
|
+
}
|
380
|
+
catch (error) {
|
381
|
+
log.error("Callback execution failed in _sendEphemeralMessage:", error);
|
382
|
+
throw error;
|
383
|
+
}
|
232
384
|
}
|
233
|
-
return Promise.resolve(false);
|
234
385
|
}
|
235
386
|
// See https://rfc.vac.dev/vac/raw/sds/#deliver-message
|
236
387
|
deliverMessage(message, retrievalHint) {
|
237
|
-
this.notifyDeliveredMessage(message.messageId);
|
238
388
|
const messageLamportTimestamp = message.lamportTimestamp ?? 0;
|
239
389
|
if (messageLamportTimestamp > this.lamportTimestamp) {
|
240
390
|
this.lamportTimestamp = messageLamportTimestamp;
|
@@ -269,15 +419,21 @@ export class MessageChannel extends TypedEventEmitter {
|
|
269
419
|
// to determine the acknowledgement status of messages in the outgoing buffer.
|
270
420
|
// See https://rfc.vac.dev/vac/raw/sds/#review-ack-status
|
271
421
|
reviewAckStatus(receivedMessage) {
|
272
|
-
// the participant MUST mark all messages in the received causal_history as acknowledged.
|
273
422
|
receivedMessage.causalHistory.forEach(({ messageId }) => {
|
274
|
-
this.outgoingBuffer = this.outgoingBuffer.filter(({ messageId: outgoingMessageId }) =>
|
423
|
+
this.outgoingBuffer = this.outgoingBuffer.filter(({ messageId: outgoingMessageId }) => {
|
424
|
+
if (outgoingMessageId !== messageId) {
|
425
|
+
return true;
|
426
|
+
}
|
427
|
+
this.safeSendEvent(MessageChannelEvent.MessageAcknowledged, {
|
428
|
+
detail: messageId
|
429
|
+
});
|
430
|
+
return false;
|
431
|
+
});
|
275
432
|
this.acknowledgements.delete(messageId);
|
276
433
|
if (!this.filter.lookup(messageId)) {
|
277
434
|
this.filter.insert(messageId);
|
278
435
|
}
|
279
436
|
});
|
280
|
-
// the participant MUST mark all messages included in the bloom_filter as possibly acknowledged
|
281
437
|
if (!receivedMessage.bloomFilter) {
|
282
438
|
return;
|
283
439
|
}
|
@@ -292,6 +448,12 @@ export class MessageChannel extends TypedEventEmitter {
|
|
292
448
|
const count = (this.acknowledgements.get(message.messageId) ?? 0) + 1;
|
293
449
|
if (count < this.acknowledgementCount) {
|
294
450
|
this.acknowledgements.set(message.messageId, count);
|
451
|
+
this.safeSendEvent(MessageChannelEvent.PartialAcknowledgement, {
|
452
|
+
detail: {
|
453
|
+
messageId: message.messageId,
|
454
|
+
count
|
455
|
+
}
|
456
|
+
});
|
295
457
|
return true;
|
296
458
|
}
|
297
459
|
this.acknowledgements.delete(message.messageId);
|
@@ -302,13 +464,5 @@ export class MessageChannel extends TypedEventEmitter {
|
|
302
464
|
getAcknowledgementCount() {
|
303
465
|
return 2;
|
304
466
|
}
|
305
|
-
notifyDeliveredMessage(messageId) {
|
306
|
-
if (this.deliveredMessageCallback) {
|
307
|
-
this.deliveredMessageCallback(messageId);
|
308
|
-
}
|
309
|
-
this.dispatchEvent(new CustomEvent(MessageChannelEvent.MessageDelivered, {
|
310
|
-
detail: messageId
|
311
|
-
}));
|
312
|
-
}
|
313
467
|
}
|
314
|
-
//# sourceMappingURL=
|
468
|
+
//# sourceMappingURL=message_channel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"message_channel.js","sourceRoot":"","sources":["../../src/message_channel/message_channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAkC,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAIL,mBAAmB,EAEpB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,CAAC;AACtC,MAAM,gCAAgC,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY;AAEpE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAQ9C,MAAM,OAAO,cAAe,SAAQ,iBAAuC;IACzD,SAAS,CAAY;IAC7B,gBAAgB,CAAS;IACzB,MAAM,CAAqB;IAC3B,cAAc,CAAY;IAC1B,gBAAgB,CAAsB;IACtC,cAAc,CAAY;IAC1B,YAAY,CAAsD;IAClE,iBAAiB,CAAS;IAC1B,oBAAoB,CAAS;IAC7B,YAAY,CAAsB;IAClC,6BAA6B,CAAU;IACvC,sBAAsB,CAAS;IAE/B,KAAK,GAAW,EAAE,CAAC;IACnB,QAAQ,GAAa;QA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sBAAsB,EAAE;oBAC7D,MAAM,EAAE;wBACN,SAAS,EAAE,OAAO,CAAC,SAAS;wBAC5B,KAAK;qBACN;iBACF,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,4FAA4F;IACpF,uBAAuB;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@waku/sds","version":"0.0.
|
1
|
+
{"name":"@waku/sds","version":"0.0.5-2ed5ddc.0","description":"Scalable Data Sync implementation for the browser. Based on https://github.com/vacp2p/rfc-index/blob/main/vac/raw/sds.md","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"typesVersions":{"*":{"*":["*","dist/*","dist/*/index"]}},"type":"module","author":"Waku Team","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/scalable-data-sync#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralized","secure","communication","web3","ethereum","dapps","privacy"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","check:tsc":"tsc -p tsconfig.dev.json","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build","test":"NODE_ENV=test run-s test:*","test:node":"NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha"},"engines":{"node":">=22"},"dependencies":{"@libp2p/interface":"2.10.4","@noble/hashes":"^1.7.1","@waku/proto":"0.0.12-2ed5ddc.0","@waku/utils":"0.0.25-2ed5ddc.0","chai":"^5.1.2"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@waku/build-utils":"*","allure-commandline":"^2.27.0","allure-mocha":"^2.9.2","cspell":"^8.6.1","fast-check":"^3.19.0","mocha-multi-reporters":"^1.5.1","npm-run-all":"^4.1.5","rollup":"^4.12.0"},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { hashN } from "
|
2
|
-
import { getMOverNBitsForK } from "
|
1
|
+
import { hashN } from "../nim_hashn/nim_hashn.mjs";
|
2
|
+
import { getMOverNBitsForK } from "../probabilities.js";
|
3
3
|
|
4
4
|
export interface BloomFilterOptions {
|
5
5
|
// The expected maximum number of elements for which this BloomFilter is sized.
|
package/src/index.ts
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
-
import { BloomFilter } from "./bloom.js";
|
1
|
+
import { BloomFilter } from "./bloom_filter/bloom.js";
|
2
|
+
|
3
|
+
export {
|
4
|
+
MessageChannel,
|
5
|
+
MessageChannelEvent,
|
6
|
+
encodeMessage,
|
7
|
+
decodeMessage
|
8
|
+
} from "./message_channel/index.js";
|
9
|
+
|
10
|
+
export type {
|
11
|
+
Message,
|
12
|
+
HistoryEntry,
|
13
|
+
ChannelId,
|
14
|
+
MessageChannelEvents
|
15
|
+
} from "./message_channel/index.js";
|
2
16
|
|
3
17
|
export { BloomFilter };
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import type { Message } from "./events.js";
|
2
|
+
|
3
|
+
export enum Command {
|
4
|
+
Send = "send",
|
5
|
+
Receive = "receive",
|
6
|
+
SendEphemeral = "sendEphemeral"
|
7
|
+
}
|
8
|
+
|
9
|
+
export interface ParamsByAction {
|
10
|
+
[Command.Send]: {
|
11
|
+
payload: Uint8Array;
|
12
|
+
callback?: (message: Message) => Promise<{
|
13
|
+
success: boolean;
|
14
|
+
retrievalHint?: Uint8Array;
|
15
|
+
}>;
|
16
|
+
};
|
17
|
+
[Command.Receive]: {
|
18
|
+
message: Message;
|
19
|
+
};
|
20
|
+
[Command.SendEphemeral]: {
|
21
|
+
payload: Uint8Array;
|
22
|
+
callback?: (message: Message) => Promise<boolean>;
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
export type Task<A extends Command = Command> = {
|
27
|
+
command: A;
|
28
|
+
params: ParamsByAction[A];
|
29
|
+
};
|
30
|
+
|
31
|
+
export type Handlers = {
|
32
|
+
[A in Command]: (params: ParamsByAction[A]) => Promise<void>;
|
33
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { proto_sds_message } from "@waku/proto";
|
2
|
+
|
3
|
+
export enum MessageChannelEvent {
|
4
|
+
MessageSent = "messageSent",
|
5
|
+
MessageDelivered = "messageDelivered",
|
6
|
+
MessageReceived = "messageReceived",
|
7
|
+
MessageAcknowledged = "messageAcknowledged",
|
8
|
+
PartialAcknowledgement = "partialAcknowledgement",
|
9
|
+
MissedMessages = "missedMessages",
|
10
|
+
SyncSent = "syncSent",
|
11
|
+
SyncReceived = "syncReceived"
|
12
|
+
}
|
13
|
+
|
14
|
+
export type Message = proto_sds_message.SdsMessage;
|
15
|
+
export type HistoryEntry = proto_sds_message.HistoryEntry;
|
16
|
+
export type ChannelId = string;
|
17
|
+
|
18
|
+
export function encodeMessage(message: Message): Uint8Array {
|
19
|
+
return proto_sds_message.SdsMessage.encode(message);
|
20
|
+
}
|
21
|
+
|
22
|
+
export function decodeMessage(data: Uint8Array): Message {
|
23
|
+
return proto_sds_message.SdsMessage.decode(data);
|
24
|
+
}
|
25
|
+
|
26
|
+
export type MessageChannelEvents = {
|
27
|
+
[MessageChannelEvent.MessageSent]: CustomEvent<Message>;
|
28
|
+
[MessageChannelEvent.MessageDelivered]: CustomEvent<{
|
29
|
+
messageId: string;
|
30
|
+
sentOrReceived: "sent" | "received";
|
31
|
+
}>;
|
32
|
+
[MessageChannelEvent.MessageReceived]: CustomEvent<Message>;
|
33
|
+
[MessageChannelEvent.MessageAcknowledged]: CustomEvent<string>;
|
34
|
+
[MessageChannelEvent.PartialAcknowledgement]: CustomEvent<{
|
35
|
+
messageId: string;
|
36
|
+
count: number;
|
37
|
+
}>;
|
38
|
+
[MessageChannelEvent.MissedMessages]: CustomEvent<HistoryEntry[]>;
|
39
|
+
[MessageChannelEvent.SyncSent]: CustomEvent<Message>;
|
40
|
+
[MessageChannelEvent.SyncReceived]: CustomEvent<Message>;
|
41
|
+
};
|