
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
chatterbox-core
Advanced tools
The core API for Chatterbox, a messaging application built on IPFS and libp2p.
The core API for Chatterbox, a messaging application built on IPFS and libp2p.
npm install chatterbox-core
const Chatterbox = require('chatterbox-core')
To create a new chatterbox core instance, await on a call to the factory function that is the default export for the module. Note a "ready" IPFS instance is required with pubsub enabled.
const Chatterbox = require('chatterbox-core')
const cbox = await Chatterbox(ipfs, [options])
ipfs: IPFSoptions: Object
repoDir: String (default /.chatterbox)topics: Object
broadcast: String (default /chatterbox/broadcast)beacon: String (default /chatterbox/beacon)friendsMessageHistorySize: Number (default 1000)beaconInterval: Number (default 5 * 60 * 1000)cbox.destroy()Destroy the chatterbox instance.
Promise
cbox.friendsManage friends.
cbox.friends.add(peerId, [details])peerId: Stringdetails: Object
name: Stringavatar: StringPromise
cbox.friends.feed([options])Live updating friend list. Same output as cbox.peers.feed except all peers are friends.
options: Object
signal: AbortSignalfilter: FunctionAsyncIterable<Object[]>
for await (const friends of cbox.friends.feed())
friends.forEach(peerInfo => console.log(peerInfo))
cbox.friends.remove(peerId)peerId: StringPromise
cbox.messagesManage messages received from peers.
cbox.messages.broadcast(text)Send a message to all peers connected to the chatterbox network. Note: this is a temporary PoC API call!
text: StringPromise
cbox.messages.feed(peerId, [options])Live updating list of messages for a given peer.
peerId: Stringoptions: Object
signal: AbortSignalAsyncIterable<Object[]>
for await (const list of cbox.messages.feed('Qm...'))
list.forEach(msg => console.log(msg))
Each message:
id: Stringtext: StringreceivedAt: NumberreadAt: Numbercbox.messages.list(peerId)Get the messages stored for a given peer.
peerId: StringPromise<Object[]>
Each message:
id: Stringtext: StringreceivedAt: NumberreadAt: Numbercbox.messages.read(peerId, messageId)Set the readAt field for a given message to the current time (if not already set).
peerId: StringmessageId: StringPromise
cbox.peercbox.peer.get()Get the local peer's info.
Promise<Object>
id: Stringname: Stringavatar: StringlastSeenAt: NumberlastMessage: Object
text: StringreceivedAt: NumberreadAt: Numbercbox.peer.set(details)Set the peer's info.
details: Object
name: Stringavatar: StringPromise
cbox.peersInformation about peers in the chatterbox network.
cbox.peers.feed([options])Live updating list of known peers in the chatterbox network.
options: Object
filter: Functionsignal: AbortSignalAsyncIterable<Object[]>
for await (const list of cbox.peers.feed())
list.forEach(peerInfo => console.log(peerInfo))
Each peer info:
id: Stringname: Stringavatar: StringlastSeenAt: NumberlastMessage: Object
id: Stringtext: StringreceivedAt: NumberreadAt: NumberisFriend: Booleancbox.peers.gc([options])Clean up peers. Pass an optional filter function.
options: Object
filter: Function (default: collect peers last seen more than an hour ago that are not friends and are not the local peer)Promise
cbox.peers.get(peerId)Get details stored for the passed Peer ID.
peerId: StringPromise<Object>
Peer details:
id: Stringname: Stringavatar: StringlastSeenAt: NumberlastMessage: Object
id: Stringtext: StringreceivedAt: NumberreadAt: NumberisFriend: Booleancbox.peers.set(peerId, details)Set properties for a peer.
peerId: Stringdetails: Object
name: Stringavatar: StringlastSeenAt: NumberlastMessage: Object
id: Stringtext: StringreceivedAt: NumberreadAt: NumberisFriend: Boolean/.chatterbox
├── peers
| ├── QmPeer0
| | ├── info.json # Peer info object
| | └── messages.json # Array of received messages
| ├── QmPeer1
| └── QmPeer2
└── version.json # Data store layout version
peers/Qm.../info.jsonPeer data.
{
"id": "QmPeerId",
"name": "Dave",
"avatar": "http://ipfs.io/ipfs/QmAvatar",
"lastSeenAt": 1568883407737,
"lastMessage": {
"id": "HexMessageId",
"text": "Hello World!",
"receivedAt": 1568883407737,
"readAt": 1568883407737
},
"isFriend": false
}
peers/Qm.../messages.jsonLength limited messages received by a peer. Stored by receivedAt in ascending order.
[
{
"id": "HexMessageId",
"text": "Hello World!",
"receivedAt": 1568883407737,
"readAt": 1568883407737
}
]
messages/index.json and then per message file as id (messages/[id].json) or receivedAt time (messages/1568883407737.json).messages.ndjson for streamingFeel free to dive in! Open an issue or submit PRs.
MIT © Alan Shaw
FAQs
The core API for Chatterbox, a messaging application built on IPFS and libp2p.
The npm package chatterbox-core receives a total of 34 weekly downloads. As such, chatterbox-core popularity was classified as not popular.
We found that chatterbox-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.