libvex

4.1.0 • Public • Published

libvex-js

npm version

a library for interacting with a vex server in javascript.

This library provides three exported classes.

  • KeyRing class, which contains a pair of ed25519 keys and sign / verify methods
  • Client class, which you can use to interact with the chat server
  • Utils class, which contains a couple useful type conversion functions

Install

yarn add libvex

Documentation

You can find a link to the documentation here

Quickstart

import { v4 as uuidv4 } from "uuid";
import { Client, IChatMessage } from "../src/Client";
import { KeyRing } from "../src/Keyring";
import { Utils } from "../src/Utils";
 
const keyring = new KeyRing(":memory:");
 
keyring.on("ready", () => {
  console.log("--------keys---------");
  console.log("PUBLIC KEY", Utils.toHexString(keyring.getPub()));
  // make sure you save your private key somewhere
  console.log("PRIVATE KEY", Utils.toHexString(keyring.getPriv()));
});
 
const vexClient = new Client("dev.vex.chat", keyring, null, true);
 
const testID = uuidv4();
console.log("TEST ID", testID);
 
vexClient.on("ready", async () => {
  const account = await vexClient.register();
  diagPrint("account", account);
  const serverPubkey = await vexClient.auth();
  console.log("SERVER PUBKEY", serverPubkey);
 
  const botChannel = "c27ce1af-4b68-4d9b-aef0-8c7cb7503d5e";
 
  await vexClient.channels.join(botChannel);
  await vexClient.messages.send(botChannel, testID);
});
 
vexClient.on("message", async (message: IChatMessage) => {
  diagPrint("message", message);
  if (message.message === testID) {
    console.log("All tests passed.");
    process.exit(0);
  }
});
 
vexClient.on("error", (error: any) => {
  console.log(error);
});
 
function diagPrint(name: string, object: Record<string, any>) {
  console.log("--------" + name + "---------");
  // tslint:disable-next-line: forin
  for (const key in object) {
    console.log(key.toUpperCase(), object[key]);
  }
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.1.00latest

Version History

VersionDownloads (Last 7 Days)Published
4.1.00
4.0.00
3.0.20
3.0.10
3.0.00
2.5.10
2.5.00
2.4.230
2.4.220
2.4.210
2.4.200
2.4.190
2.4.180
2.4.170
2.4.160
2.4.150
2.4.140
2.4.130
2.4.120
2.4.110
2.4.100
2.4.90
2.4.80
2.4.70
2.4.60
2.4.50
2.4.40
2.4.30
2.4.20
2.4.10
2.4.00
2.3.20
2.3.10
2.3.00
2.2.90
2.2.80
2.2.70
2.2.60
2.2.50
2.2.40
2.2.30
2.2.20
2.2.10
2.2.00
2.1.00
0.3.00
0.2.00
0.1.00

Package Sidebar

Install

npm i libvex

Weekly Downloads

0

Version

4.1.0

License

MIT

Unpacked Size

62.8 kB

Total Files

18

Last publish

Collaborators

  • extrahash