@nymproject/nodejs-client-commonjs
TypeScript icon, indicating that this package has built-in type declarations

1.2.4-rc.1 • Public • Published

Nym NodeJS wrapper for Sphinx webassembly client

This package is a NodeJS client that uses the wasm from the Sphinx webassembly client, runs it inside a NodeJS Worker thread and allows users to send and receive Sphinx packets to/from a Nym mixnet.

Usage

const { createNymMixnetClient } = require('@nymproject/nodejs-client-commonjs');

async () => {
  const nym = await createNymMixnetClient();

  nym.events.subscribeToTextMessageReceivedEvent(async (e) => {
    console.log("message received", e.args.payload);
  });

  const nymApiUrl = 'https://validator.nymtech.net/api/';

  // start the client and connect to a gateway
  await nym.client.start({
    nymApiUrl,
    clientId: 'my-client',
  });

  nym.events.subscribeToConnected(async (e) => {
    // send a message to yourself
    const message = 'Hello';
    const recipient = await nym.client.selfAddress();
    await nym.client.send({ payload: { message, mimeType: 'text/plain' }, recipient });
  });
};

Readme

Keywords

none

Package Sidebar

Install

npm i @nymproject/nodejs-client-commonjs

Weekly Downloads

0

Version

1.2.4-rc.1

License

Apache-2.0

Unpacked Size

2.89 MB

Total Files

10

Last publish

Collaborators

  • nymbot
  • mmsinclair
  • nymtech
  • jstuczyn