4.1.0 • Published 4 years ago

libvex v4.1.0

Weekly downloads
8
License
MIT
Repository
-
Last release
4 years ago

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]);
  }
}
4.1.0

4 years ago

3.0.2

4 years ago

4.0.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.5.0

4 years ago

2.5.1

4 years ago

2.4.23

4 years ago

2.4.21

4 years ago

2.4.20

4 years ago

2.4.22

4 years ago

2.4.19

4 years ago

2.4.18

4 years ago

2.4.17

4 years ago

2.4.16

4 years ago

2.4.15

4 years ago

2.4.14

4 years ago

2.4.13

4 years ago

2.4.10

4 years ago

2.4.12

4 years ago

2.4.11

4 years ago

2.4.9

4 years ago

2.4.8

4 years ago

2.4.7

4 years ago

2.4.6

4 years ago

2.4.3

4 years ago

2.4.5

4 years ago

2.4.4

4 years ago

2.4.2

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.2

4 years ago

2.2.9

4 years ago

2.2.8

4 years ago

2.3.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.2.3

4 years ago

2.3.1

4 years ago

2.2.2

4 years ago

2.2.5

4 years ago

2.2.4

4 years ago

2.2.7

4 years ago

2.2.6

4 years ago

2.1.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago