npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cuser/client

v0.0.36

Published

client logic for reading and publishing message using restfull transport

Readme

@cuser/client

Status

codecov npm npm-downloads

Class: CuserClient

Cuser client instance which provides an interface to read, publish, edit and delete messages through ipfs. By default the client will be only allowed to read messages unless you provide a CuserServer url, which will enable the publishing capabilities to the users.

Note To enable publisher capabilities, you need deploy a CuserServer, please refer to getting started section to gets more information.

example

const { create } = require('ipfs');

const node = create({ ...ipfsOptions });
const cuserId = 'CUSER_SERVER_IDENTIFIER';
const client = new CuserClient(node, cuserId);
const topicId = 'custom-topic-id';

client.getMessages(topicId).then((messages) => {
 console.log(messages);
 // should return empty array when no comments
});

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new CuserClient(node: IPFSAPI | Promise<IPFSAPI>, cuserId: string, opts?: CuserClientOptions & CuserReaderOptions & CuserCoreOptions): CuserClient

Overrides void

Defined in client/client.js:53

Parameters:

Name | Type | Default value | ------ | ------ | ------ | node | IPFSAPI | Promise<IPFSAPI> | - | cuserId | string | - | opts | CuserClientOptions & CuserReaderOptions & CuserCoreOptions | {} |

Returns: CuserClient

Properties

_core

_core: CuserCore

Inherited from CuserClient._core

Defined in reader/reader.d.ts:44


_process

_process: (message: any, cursor: string) => Promise<CuserReaderMessageIteratorResult>

Inherited from CuserClient._process

Defined in reader/reader.d.ts:48

Methods

authenticate

authenticate(username: string, avatar: string): Promise<any>

Defined in client/client.js:80

Authenticates a user with the required fields of username and avatar, this will epect to recieve an access_token to be used in publishing operations

Parameters:

Name | Type | Description | ------ | ------ | ------ | username | string | | avatar | string | data url scheme https://tools.ietf.org/html/rfc2397 |

Returns: Promise<any>


deleteMessage

deleteMessage(topicId: string, accessToken: string, messageId: string): Promise<[any, Response]>

Defined in client/client.js:142

Deletes message for certain topic using topicId as identifier and accessToken to identify the user

Parameters:

Name | Type | ------ | ------ | topicId | string | accessToken | string | messageId | string |

Returns: Promise<[any, Response]>


getMessage

getMessage(cid: string): Promise<GraphMessage>

Inherited from CuserClient.getMessage

Defined in reader/reader.d.ts:76

Gets the message from ipfs using the CID given by parameter

Parameters:

Name | Type | ------ | ------ | cid | string |

Returns: Promise<GraphMessage>


getMessages

getMessages(topicId: string, opts: CuserReaderMessagesIteratorOptions): Promise<CuserReaderMessageIteratorResult[]> | AsyncIterable<CuserReaderMessageIteratorResult>

Inherited from CuserClient.getMessages

Defined in reader/reader.d.ts:70

Gets messages from ipfs layer

example

Array

const messages = reader.getMessages('custom_topic_id');
console.log(messages);

Iterator

const messages = reader.getMessages('custom_topic_id', {
  iterator: true,
});
for await (let value of messages) {
  console.log(value);
}

Parameters:

Name | Type | ------ | ------ | topicId | string | opts | CuserReaderMessagesIteratorOptions |

Returns: Promise<CuserReaderMessageIteratorResult[]> | AsyncIterable<CuserReaderMessageIteratorResult>


publishMessage

publishMessage(topicId: string, accessToken: string, content: string): Promise<[any, Response]>

Defined in client/client.js:97

Publish a new message for certain topic using topicId as identifier and accessToken to identify the user

Parameters:

Name | Type | ------ | ------ | topicId | string | accessToken | string | content | string |

Returns: Promise<[any, Response]>


subscribe

subscribe(topicId: string, subscriber: CuserClientSubscriber): function

Defined in client/client.js:184

Subscribe to message changes of a certain topic.

example This will attach the listener to three types of events:

  • created when a user publish a message
  • updated when a user updates a message
  • deleted when a user removes a message
client.subscribe('CUSTOM_TOPIC_ID', ({ type, messageCid }) => {
 switch(type) {
   case 'created':
     // when a user publish a message
     // console.log(client.getMessage(messageCid));
     break;
   case 'updated':
     // when a user updates a message
     // console.log(client.getMessage(messageCid));
     break;
   case 'deleted':
     // when a user removes a message
     // console.log(client.getMessage(messageCid));
     break;
 }
});

Parameters:

Name | Type | Description | ------ | ------ | ------ | topicId | string | topic identifier | subscriber | CuserClientSubscriber | function event subscriber |

Returns: function


updateMessage

updateMessage(topicId: string, accessToken: string, messageId: string, content: string): Promise<[any, Response]>

Defined in client/client.js:120

Updates message for certain topic using topicId as identifier and accessToken to identify the user

Parameters:

Name | Type | ------ | ------ | topicId | string | accessToken | string | messageId | string | content | string |

Returns: Promise<[any, Response]>