@waku/sds 0.0.4-b0a2e39.0 → 0.0.4-b4748fd.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.
@@ -1,42 +1,31 @@
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 { 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";
4
+ import { DefaultBloomFilter } from "./bloom.js";
5
+ export var MessageChannelEvent;
6
+ (function (MessageChannelEvent) {
7
+ MessageChannelEvent["MessageDelivered"] = "messageDelivered";
8
+ })(MessageChannelEvent || (MessageChannelEvent = {}));
8
9
  export const DEFAULT_BLOOM_FILTER_OPTIONS = {
9
10
  capacity: 10000,
10
11
  errorRate: 0.001
11
12
  };
12
13
  const DEFAULT_CAUSAL_HISTORY_SIZE = 2;
13
14
  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;
17
16
  lamportTimestamp;
18
17
  filter;
19
18
  outgoingBuffer;
20
19
  acknowledgements;
21
20
  incomingBuffer;
22
21
  localHistory;
22
+ channelId;
23
23
  causalHistorySize;
24
24
  acknowledgementCount;
25
25
  timeReceived;
26
26
  receivedMessageTimeoutEnabled;
27
27
  receivedMessageTimeout;
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
- };
28
+ deliveredMessageCallback;
40
29
  constructor(channelId, options = {}) {
41
30
  super();
42
31
  this.channelId = channelId;
@@ -54,71 +43,54 @@ export class MessageChannel extends TypedEventEmitter {
54
43
  options.receivedMessageTimeoutEnabled ?? false;
55
44
  this.receivedMessageTimeout =
56
45
  options.receivedMessageTimeout ?? DEFAULT_RECEIVED_MESSAGE_TIMEOUT;
46
+ this.deliveredMessageCallback = options.deliveredMessageCallback;
57
47
  }
58
48
  static getMessageId(payload) {
59
49
  return bytesToHex(sha256(payload));
60
50
  }
61
51
  /**
62
- * Processes all queued tasks sequentially to ensure proper message ordering.
63
- *
64
- * This method should be called periodically by the library consumer to execute
65
- * queued send/receive operations in the correct sequence.
66
- *
67
- * @example
68
- * ```typescript
69
- * const channel = new MessageChannel("my-channel");
52
+ * Send a message to the SDS channel.
70
53
  *
71
- * // Queue some operations
72
- * await channel.sendMessage(payload, callback);
73
- * channel.receiveMessage(incomingMessage);
74
- *
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
80
- */
81
- async processTasks() {
82
- while (this.tasks.length > 0) {
83
- const item = this.tasks.shift();
84
- if (!item) {
85
- continue;
86
- }
87
- await this.executeTask(item);
88
- }
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)
54
+ * Increments the lamport timestamp, constructs a `Message` object
55
+ * with the given payload, and adds it to the outgoing buffer.
99
56
  *
100
- * @example
101
- * ```typescript
102
- * const channel = new MessageChannel("chat-room");
103
- * const message = new TextEncoder().encode("Hello, world!");
57
+ * If the callback is successful, the message is also added to
58
+ * the bloom filter and message history. In the context of
59
+ * Waku, this likely means the message was published via
60
+ * light push or relay.
104
61
  *
105
- * await channel.sendMessage(message, async (processedMessage) => {
106
- * console.log("Message processed:", processedMessage.messageId);
107
- * return { success: true };
108
- * });
62
+ * See https://rfc.vac.dev/vac/raw/sds/#send-message
109
63
  *
110
- * // Actually send the message
111
- * await channel.processTasks();
112
- * ```
64
+ * @param payload - The payload to send.
65
+ * @param callback - A callback function that returns a boolean indicating whether the message was sent successfully.
113
66
  */
114
67
  async sendMessage(payload, callback) {
115
- this.tasks.push({
116
- command: Command.Send,
117
- params: {
118
- payload,
119
- callback
68
+ this.lamportTimestamp++;
69
+ const messageId = MessageChannel.getMessageId(payload);
70
+ const message = {
71
+ messageId,
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
+ });
120
92
  }
121
- });
93
+ }
122
94
  }
123
95
  /**
124
96
  * Sends a short-lived message without synchronization or reliability requirements.
@@ -133,58 +105,64 @@ export class MessageChannel extends TypedEventEmitter {
133
105
  * @param payload - The payload to send.
134
106
  * @param callback - A callback function that returns a boolean indicating whether the message was sent successfully.
135
107
  */
136
- async sendEphemeralMessage(payload, callback) {
137
- this.tasks.push({
138
- command: Command.SendEphemeral,
139
- params: {
140
- payload,
141
- callback
142
- }
143
- });
108
+ sendEphemeralMessage(payload, callback) {
109
+ const message = {
110
+ messageId: MessageChannel.getMessageId(payload),
111
+ channelId: this.channelId,
112
+ content: payload,
113
+ lamportTimestamp: undefined,
114
+ causalHistory: [],
115
+ bloomFilter: undefined
116
+ };
117
+ if (callback) {
118
+ callback(message);
119
+ }
144
120
  }
145
121
  /**
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.
122
+ * Process a received SDS message for this channel.
150
123
  *
151
- * @param message - The message to receive and process
124
+ * Review the acknowledgement status of messages in the outgoing buffer
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.
152
130
  *
153
- * @example
154
- * ```typescript
155
- * const channel = new MessageChannel("chat-room");
131
+ * See https://rfc.vac.dev/vac/raw/sds/#receive-message
156
132
  *
157
- * // Receive a message from the network
158
- * channel.receiveMessage(incomingMessage);
159
- *
160
- * // Process the received message
161
- * await channel.processTasks();
162
- * ```
133
+ * @param message - The received SDS message.
163
134
  */
164
135
  receiveMessage(message) {
165
- this.tasks.push({
166
- command: Command.Receive,
167
- params: {
168
- message
169
- }
170
- });
136
+ if (!message.lamportTimestamp) {
137
+ // Messages with no timestamp are ephemeral messages and should be delivered immediately
138
+ this.deliverMessage(message);
139
+ return;
140
+ }
141
+ // review ack status
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
+ }
171
156
  }
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
- */
157
+ // https://rfc.vac.dev/vac/raw/sds/#periodic-incoming-buffer-sweep
177
158
  sweepIncomingBuffer() {
178
159
  const { buffer, missing } = this.incomingBuffer.reduce(({ buffer, missing }, message) => {
160
+ // Check each message for missing dependencies
179
161
  const missingDependencies = message.causalHistory.filter((messageHistoryEntry) => !this.localHistory.some(({ historyEntry: { messageId } }) => messageId === messageHistoryEntry.messageId));
180
162
  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)
181
165
  this.deliverMessage(message);
182
- this.safeSendEvent(MessageChannelEvent.MessageDelivered, {
183
- detail: {
184
- messageId: message.messageId,
185
- sentOrReceived: "received"
186
- }
187
- });
188
166
  return { buffer, missing };
189
167
  }
190
168
  // Optionally, if a message has not been received after a predetermined amount of time,
@@ -196,22 +174,20 @@ export class MessageChannel extends TypedEventEmitter {
196
174
  return { buffer, missing };
197
175
  }
198
176
  }
199
- missingDependencies.forEach((dependency) => {
200
- missing.add(dependency);
201
- });
177
+ // Any message with missing dependencies stays in the buffer
178
+ // and the missing message IDs are returned for processing.
202
179
  return {
203
180
  buffer: buffer.concat(message),
204
- missing
181
+ missing: missing.concat(missingDependencies)
205
182
  };
206
- }, { buffer: new Array(), missing: new Set() });
183
+ }, { buffer: new Array(), missing: new Array() });
184
+ // Update the incoming buffer to only include messages with no missing dependencies
207
185
  this.incomingBuffer = buffer;
208
- this.safeSendEvent(MessageChannelEvent.MissedMessages, {
209
- detail: Array.from(missing)
210
- });
211
- return Array.from(missing);
186
+ return missing;
212
187
  }
213
188
  // https://rfc.vac.dev/vac/raw/sds/#periodic-outgoing-buffer-sweep
214
189
  sweepOutgoingBuffer() {
190
+ // Partition all messages in the outgoing buffer into unacknowledged and possibly acknowledged messages
215
191
  return this.outgoingBuffer.reduce(({ unacknowledged, possiblyAcknowledged }, message) => {
216
192
  if (this.acknowledgements.has(message.messageId)) {
217
193
  return {
@@ -238,7 +214,7 @@ export class MessageChannel extends TypedEventEmitter {
238
214
  *
239
215
  * @param callback - A callback function that returns a boolean indicating whether the message was sent successfully.
240
216
  */
241
- async sendSyncMessage(callback) {
217
+ sendSyncMessage(callback) {
242
218
  this.lamportTimestamp++;
243
219
  const emptyMessage = new Uint8Array();
244
220
  const message = {
@@ -252,139 +228,13 @@ export class MessageChannel extends TypedEventEmitter {
252
228
  content: emptyMessage
253
229
  };
254
230
  if (callback) {
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
- }
231
+ return callback(message);
384
232
  }
233
+ return Promise.resolve(false);
385
234
  }
386
235
  // See https://rfc.vac.dev/vac/raw/sds/#deliver-message
387
236
  deliverMessage(message, retrievalHint) {
237
+ this.notifyDeliveredMessage(message.messageId);
388
238
  const messageLamportTimestamp = message.lamportTimestamp ?? 0;
389
239
  if (messageLamportTimestamp > this.lamportTimestamp) {
390
240
  this.lamportTimestamp = messageLamportTimestamp;
@@ -419,21 +269,15 @@ export class MessageChannel extends TypedEventEmitter {
419
269
  // to determine the acknowledgement status of messages in the outgoing buffer.
420
270
  // See https://rfc.vac.dev/vac/raw/sds/#review-ack-status
421
271
  reviewAckStatus(receivedMessage) {
272
+ // the participant MUST mark all messages in the received causal_history as acknowledged.
422
273
  receivedMessage.causalHistory.forEach(({ messageId }) => {
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
- });
274
+ this.outgoingBuffer = this.outgoingBuffer.filter(({ messageId: outgoingMessageId }) => outgoingMessageId !== messageId);
432
275
  this.acknowledgements.delete(messageId);
433
276
  if (!this.filter.lookup(messageId)) {
434
277
  this.filter.insert(messageId);
435
278
  }
436
279
  });
280
+ // the participant MUST mark all messages included in the bloom_filter as possibly acknowledged
437
281
  if (!receivedMessage.bloomFilter) {
438
282
  return;
439
283
  }
@@ -448,12 +292,6 @@ export class MessageChannel extends TypedEventEmitter {
448
292
  const count = (this.acknowledgements.get(message.messageId) ?? 0) + 1;
449
293
  if (count < this.acknowledgementCount) {
450
294
  this.acknowledgements.set(message.messageId, count);
451
- this.safeSendEvent(MessageChannelEvent.PartialAcknowledgement, {
452
- detail: {
453
- messageId: message.messageId,
454
- count
455
- }
456
- });
457
295
  return true;
458
296
  }
459
297
  this.acknowledgements.delete(message.messageId);
@@ -464,5 +302,13 @@ export class MessageChannel extends TypedEventEmitter {
464
302
  getAcknowledgementCount() {
465
303
  return 2;
466
304
  }
305
+ notifyDeliveredMessage(messageId) {
306
+ if (this.deliveredMessageCallback) {
307
+ this.deliveredMessageCallback(messageId);
308
+ }
309
+ this.dispatchEvent(new CustomEvent(MessageChannelEvent.MessageDelivered, {
310
+ detail: messageId
311
+ }));
312
+ }
467
313
  }
468
- //# sourceMappingURL=message_channel.js.map
314
+ //# sourceMappingURL=sds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sds.js","sourceRoot":"","sources":["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I,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3D,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,oFAAoF;YACpF,8EAA8E;YAC9E,6DAA6D;YAC7D,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACtE,IAAI,KAAK,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBACtC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBACpD,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;IAEO,sBAAsB,CAAC,SAAiB;QAC9C,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAClC,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,mBAAmB,CAAC,gBAAgB,EAAE;YACpD,MAAM,EAAE,SAAS;SAClB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@waku/sds","version":"0.0.4-b0a2e39.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":">=20"},"dependencies":{"@libp2p/interface":"2.7.0","@noble/hashes":"^1.7.1","@waku/proto":"0.0.11-b0a2e39.0","@waku/utils":"0.0.24-b0a2e39.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
+ {"name":"@waku/sds","version":"0.0.4-b4748fd.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":">=20"},"dependencies":{"@libp2p/interface":"2.7.0","@noble/hashes":"^1.7.1","@waku/proto":"0.0.11-b4748fd.0","@waku/utils":"0.0.24-b4748fd.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 "../nim_hashn/nim_hashn.mjs";
2
- import { getMOverNBitsForK } from "../probabilities.js";
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,17 +1,3 @@
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";
1
+ import { BloomFilter } from "./bloom.js";
16
2
 
17
3
  export { BloomFilter };