
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@ssense/redis-pubsub
Advanced tools
RedisPubSub allows to quickly set up a client which supports the Redis pub/sub protocol
class RedisPubSub
RedisPubSub allows to quickly set up a client which supports the Redis pub/sub protocol. (see examples here)
| Method | Returns | Description |
|---|---|---|
constructor(connection: RedisPubSubConnectionOptions) | RedisPubSub | Creates a new instance of RedisPubSub |
on(event: string, listener: (message: PubSubMessage) => void) | RedisPubSub | Registers to a Redis topic, adding a listener called when a pub/sub event is received |
on(event: 'error', listener: (err: Error) => void) | RedisPubSub | Adds a listener called when an error occurs in the underlying RedisPubSub |
emit(topic: string, message: any) | Promise<void> | Sends a message on Redis pub/sub for a given topic |
constructor(connection: RedisPubSubConnectionOptions)Creates a new instance of RedisPubSub
| Name | Type | Required | Description |
|---|---|---|---|
| connection | RedisPubSubConnectionOptions | Yes | The parameters used to connect to the Redis pub/sub server |
RedisPubSubConnectionOptions properties
| Name | Type | Required | Description |
|---|---|---|---|
| host | string | Yes | Redis server hostname or IP address |
| port | number | No | Redis server port (default: 6379) |
| password | string | No | Password for Redis server if any (default: undefined) |
| tlsEnabled | boolean | No | Enable TLS connection (default: false) |
| compressionEnabled | boolean | No | Enable compression (default: false) |
| password | string | No | Password for Redis server if any (default: undefined) |
| mode | 'read'|'write' | No | Used to save resources, by avoiding extra connections to Redis if your application only needs to read or write to the pub/sub system. Do not set to get a bi-directional connection (read & write, which is the default). Use read to use a read-only connection (if used, the emit method will be deactivated).Use write to use a write only connection (if used, the on method will be deactivated, except for the error event). |
on(event: string, listener: (message: PubSubMessage) => void)Registers to a Redis topic, adding a listener called when a pub/sub event is received
| Name | Type | Required | Description |
|---|---|---|---|
| event | string | Yes | Redis topic name, you can listen to multiple topics at once using a pattern, eg: *:Created |
| listener | Function | Yes | Function which will be called when a message is received, will be provided a PubSubMessage object |
PubSubMessage properties
| Name | Type | Required | Description |
|---|---|---|---|
| topic | string | Yes | Redis topic on which the message has been sent |
| data | any | Yes | Message data (any object) |
| Type | Description |
|---|---|
RedisPubSub | The current RedisPubSub instance |
on(event: 'error', listener: (err: Error) => void)Adds a listener called when an error occurs in the underlying RedisPubSub
| Name | Type | Required | Description |
|---|---|---|---|
| event | 'error' | Yes | The 'error' string |
| listener | Function | Yes | Function which will be called on RedisPubSub error, will be provided an Error object |
| Type | Description |
|---|---|
RedisPubSub | The current RedisPubSub instance |
emit(topic: string, message: any)Sends a message on Redis pub/sub for a given topic
| Name | Type | Required | Description |
|---|---|---|---|
| topic | string | Yes | Valid topic name (eg: 'Product:Product:Created') |
| message | any | Yes | Content of the message to send, can be any object (needs to be JSON.stringifiable) |
import { RedisPubSub } from '@ssense/redis-pubsub';
// Instantiate the client with the minimum required parameters
const client = new RedisPubSub({ host: 'localhost' });
// Register to a simple topic
client.on('Product:Product:Created', (message) => {
console.log(message);
// Will display: {topic: 'Product:Product:Created', data: {id: 123456789}}
});
// Register using a pattern, to listen to multiple topics at once
client.on('*:Created', (message) => {
console.log(message);
// Will display: {topic: 'Product:Product:Created', data: {id: 123456789}}
});
// Register to a special "error" topic, called if an internal error occurs in the RedisPubSub class
client.on('error', (err: Error) => {
// Manage the error
console.error('An error occurred', err);
});
// Send a message on a specific topic, which will trigger the two listeners above
client.emit('Product:Product:Created', { id: 123456789 });
// Send a message on another topic, which will only trigger the second listener above
client.emit('Product:Brand:Created', { id: 123456789 });
FAQs
RedisPubSub allows to quickly set up a client which supports the Redis pub/sub protocol
We found that @ssense/redis-pubsub demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 24 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.