diff --git a/packages/libp2p-daemon-client/package.json b/packages/libp2p-daemon-client/package.json index bc8adf8d..23564b4e 100644 --- a/packages/libp2p-daemon-client/package.json +++ b/packages/libp2p-daemon-client/package.json @@ -130,10 +130,10 @@ }, "dependencies": { "@libp2p/daemon-protocol": "^1.0.0", - "@libp2p/interfaces": "^1.3.17", - "@libp2p/logger": "^1.1.2", - "@libp2p/peer-id": "^1.1.8", - "@libp2p/tcp": "^1.0.6", + "@libp2p/interfaces": "^1.3.22", + "@libp2p/logger": "^1.1.4", + "@libp2p/peer-id": "^1.1.10", + "@libp2p/tcp": "^1.0.8", "@multiformats/multiaddr": "^10.1.8", "err-code": "^3.0.1", "it-stream-types": "^1.0.4", @@ -141,8 +141,8 @@ }, "devDependencies": { "@libp2p/daemon-server": "^1.0.0", - "@libp2p/interface-compliance-tests": "^1.1.20", - "@libp2p/peer-id-factory": "^1.0.8", + "@libp2p/interface-compliance-tests": "^1.1.23", + "@libp2p/peer-id-factory": "^1.0.9", "aegir": "^37.0.5", "it-all": "^1.0.6", "it-pipe": "^2.0.3", diff --git a/packages/libp2p-daemon-client/test/pubsub.spec.ts b/packages/libp2p-daemon-client/test/pubsub.spec.ts index de577359..d97950e1 100644 --- a/packages/libp2p-daemon-client/test/pubsub.spec.ts +++ b/packages/libp2p-daemon-client/test/pubsub.spec.ts @@ -72,18 +72,18 @@ describe('daemon pubsub client', function () { await client.pubsub.publish(topic, data) - expect(pubsub.dispatchEvent.called).to.be.true() + expect(pubsub.publish.called).to.be.true() - const event = pubsub.dispatchEvent.getCall(0).args[0] + const call = pubsub.publish.getCall(0) - expect(event.type).to.equal(topic) - expect(event.detail).to.equalBytes(data) + expect(call).to.have.nested.property('args[0]', topic) + expect(call).to.have.deep.nested.property('args[1]', data) }) it('should error if receive an error message', async () => { const topic = 'test-topic' const data = uint8ArrayFromString('hello world') - pubsub.dispatchEvent.throws(new Error('Urk!')) + pubsub.publish.throws(new Error('Urk!')) await expect(client.pubsub.publish(topic, data)).to.eventually.be.rejectedWith(/Urk!/) }) diff --git a/packages/libp2p-daemon-protocol/package.json b/packages/libp2p-daemon-protocol/package.json index 3adc18c7..2c3930d7 100644 --- a/packages/libp2p-daemon-protocol/package.json +++ b/packages/libp2p-daemon-protocol/package.json @@ -149,10 +149,10 @@ "release": "aegir release" }, "dependencies": { - "protons-runtime": "^1.0.0" + "protons-runtime": "^1.0.3" }, "devDependencies": { - "aegir": "^37.0.5", - "protons": "^3.0.1" + "aegir": "^37.0.14", + "protons": "^3.0.3" } } diff --git a/packages/libp2p-daemon-server/package.json b/packages/libp2p-daemon-server/package.json index 6662f5e5..027e8d74 100644 --- a/packages/libp2p-daemon-server/package.json +++ b/packages/libp2p-daemon-server/package.json @@ -134,10 +134,10 @@ }, "dependencies": { "@libp2p/daemon-protocol": "^1.0.0", - "@libp2p/interfaces": "^1.3.17", - "@libp2p/logger": "^1.1.2", - "@libp2p/peer-id": "^1.1.8", - "@libp2p/tcp": "^1.0.6", + "@libp2p/interfaces": "^1.3.22", + "@libp2p/logger": "^1.1.4", + "@libp2p/peer-id": "^1.1.10", + "@libp2p/tcp": "^1.0.8", "@multiformats/multiaddr": "^10.1.8", "it-drain": "^1.0.5", "it-length-prefixed": "^7.0.1", diff --git a/packages/libp2p-daemon-server/src/pubsub.ts b/packages/libp2p-daemon-server/src/pubsub.ts index 22bc2ab8..262a9d45 100644 --- a/packages/libp2p-daemon-server/src/pubsub.ts +++ b/packages/libp2p-daemon-server/src/pubsub.ts @@ -7,7 +7,6 @@ import { ErrorResponse, OkResponse } from './responses.js' import type { PubSub } from '@libp2p/interfaces/pubsub' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { pushable } from 'it-pushable' -import { CustomEvent } from '@libp2p/interfaces' import { logger } from '@libp2p/logger' const log = logger('libp2p:daemon-server:pubsub') @@ -42,10 +41,15 @@ export class PubSubOperations { async * subscribe (topic: string) { try { const onMessage = pushable() + this.pubsub.subscribe(topic) - await this.pubsub.addEventListener(topic, (evt) => { + await this.pubsub.addEventListener('message', (evt) => { const msg = evt.detail + if (msg.topic !== topic) { + return + } + onMessage.push(PSMessage.encode({ from: msg.from.toBytes(), data: msg.data, @@ -66,7 +70,7 @@ export class PubSubOperations { async * publish (topic: string, data: Uint8Array) { try { - this.pubsub.dispatchEvent(new CustomEvent(topic, { detail: data })) + this.pubsub.publish(topic, data) yield OkResponse() } catch (err: any) { log.error(err) diff --git a/packages/libp2p-daemon/package.json b/packages/libp2p-daemon/package.json index 21e210d2..9baa324e 100644 --- a/packages/libp2p-daemon/package.json +++ b/packages/libp2p-daemon/package.json @@ -132,7 +132,7 @@ }, "dependencies": { "@libp2p/daemon-server": "^1.0.0", - "@libp2p/interfaces": "^1.3.17", + "@libp2p/interfaces": "^1.3.22", "@multiformats/multiaddr": "^10.1.8", "es-main": "^1.0.2", "yargs": "^17.3.1",