This is emitted whenever the keyring is done initializing after an init() call. You must wait to login or register until after this event.
Example:
client.on("ready", () => {
await client.register()
});
This is emitted when you are logged in succesfully. You can now call the rest of the methods in the api.
Example:
client.on("authed", (user) => {
// do something
});
This is emitted for every sent and received message.
Example:
client.on("message", (msg: IMessage) => {
console.log(message);
});
This is emitted when the user is granted a new permission.
Example:
client.on("permission", (perm: IPermission) => {
console.log(perm);
});
This is emitted for a new encryption session being created with a specific user.
Example:
client.on("session", (session: ISession, user: IUser) => {
console.log(session);
console.log(user);
});
This is emitted whenever the connection is closed. You must discard the client and connect again with a fresh one.
Example:
client.on("disconnect", () => {
// do something
});
This is emitted whenever the close() event is called and completed successfully. Note this is not fired for an unintentional disconnect, see the disconnect event.
Example:
client.on("closed", () => {
process.exit(0);
});
This is true if the client has ever been initialized. You can only initialize a client once.
This is true if the client has ever logged in before. You can only login a client once.
Manually closes the client. Emits the closed event on successful shutdown.
Gets the hex string representations of the public and private keys.
Initializes the keyring. This must be called before anything else.
Logs in to the server. You must have registered() before with your current private key.
Registers a new account on the server.
The username to register. Must be unique.
The error, or the user object.
Generates an ed25519 secret key as a hex string.
Generates a random username using bip39.
Creates a new channel in a server.
Deletes a channel.
Retrieves all channels in a server.
Retrieves channel details by its unique channelID.
The IMessages interface contains methods for dealing with messages.
Uploads an encrypted file and returns the details and the secret key.
The IMessages interface contains methods for dealing with messages.
Send a group message to a channel.
Gets the message history with a specific userID.
Gets the group message history with a specific channelID.
Send a direct message.
The IPermissions object contains all methods for dealing with permissions.
Creates a new permission for the givern resourceID and userID.
Creates a new server.
Deletes a server.
Retrieves all servers the logged in user has access to.
Retrieves server details by its unique serverID.
The ISessions interface contains methods for dealing with encryption sessions.
Marks a mnemonic verified, implying that the the user has confirmed that the session mnemonic matches with the other user.
Gets all encryption sessions.
Returns a mnemonic for the session, to verify with the other user.
The IUsers interface contains methods for dealing with users.
Retrieves the list of users you can currently access, or are already familiar with.
Retrieves the currently logged in user's (you) information.
Retrieves a user's information by a string identifier.
Generated using TypeDoc
Client provides an interface for you to use a vex chat server and send end to end encrypted messages to other users.
import { Client } from "@vex-chat/libvex"; async function main() { // generate a secret key to use, save this somewhere permanent const privateKey = Client.generateSecretKey(); const client = new Client(privateKey); // the ready event is emitted when init() is finished. // you must wait until this event fires to perform // registration or login. client.on("ready", async () => { // you must register once before you can log in await client.register(Client.randomUsername()); await client.login(); }) // The authed event fires when login() successfully completes // and the server indicates you are authorized. You must wait to // perform any operations besides register() and login() until // this occurs. client.on("authed", async () => { const me = await client.users.me(); // send a message await client.messages.send(me.userID, "Hello world!"); }) // Outgoing and incoming messages are emitted here. client.on("message", (message) => { console.log("message:", message); }) // you must call init() to initialize the keyring and // start the client. client.init(); } main();