The global signature policy controls whether or not we sill send and receive signed or unsigned messages.
Signed messages prevent spoofing message senders and should be preferred to using unsigned messages.
A list of multicodecs that contain the pubsub protocol name.
Pubsub routers support message validators per topic, which will validate the message before its propagations. They are stored in a map where keys are the topic name and values are the validators.
const topic = 'topic'
const validateMessage = (msgTopic, msg) => {
const input = uint8ArrayToString(msg.data)
const validInputs = ['a', 'b', 'c']
if (!validInputs.includes(input)) {
throw new Error('no valid input received')
}
}
libp2p.pubsub.topicValidators.set(topic, validateMessage)
Optional
options: boolean | AddEventListenerOptionsDispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Publishes messages to the given topic.
const topic = 'topic'
const data = uint8ArrayFromString('data')
await libp2p.pubsub.publish(topic, data)
Optional
listener: null | EventHandler<Events[K]>Optional
options: boolean | EventListenerOptionsOptional
listener: EventHandler<Event>Optional
options: boolean | EventListenerOptions
Adds types to the EventTarget class. Hopefully this won't be necessary forever.
https://github.com/microsoft/TypeScript/issues/28357 https://github.com/microsoft/TypeScript/issues/43477 https://github.com/microsoft/TypeScript/issues/299 etc