Skip to content

Library to interact with Matrix

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

lorena-ssi/matrix-lib

Folders and files

NameName
Last commit message
Last commit date
Apr 23, 2020
Mar 5, 2020
Apr 29, 2020
Apr 29, 2020
Mar 11, 2020
Mar 31, 2020
Mar 3, 2020
Mar 9, 2020
Mar 3, 2020
Mar 3, 2020
Mar 3, 2020
Mar 10, 2020
Apr 29, 2020

Repository files navigation

matrix-lib

matrix-lib is a caelum api for matrix connection used in Lorena SSI.

Build Status Coverage Status

Installation

npm @lorena-ssi/matrix-lib

Getting Started

const Matrix = require('@lorena-ssi/lorena-matrix')
// Creating class Matrix with parameter `homeserver`
const matrix = new Matrix('https://matrix.org')
// Check if user exists
if ( (await matrix.available(username)) ) {
    // Registering to matrix `homeserver` with `username` and `password`
    const primaryUser = await matrix.register('username', 'password')
    // Connecting to account with username `username` and password `password`
    matrix.connect(username, password)
        .then((res)=>{console.log("Connected:", res)})
        .catch((e)=>{console.log("Error:", e)})
    // Read events: If argument=='' then all history events are received
    matrix.events('')
        .then((a,b)=>{console.log("Correct:", a)})
        .catch((e)=>{console.log("Error in events:", e)})
}