Code Monkey home page Code Monkey logo

matrix-rust-sdk-crypto-wasm's Introduction

matrix-sdk-crypto-wasm

Welcome to the WebAssembly + JavaScript binding for the Rust matrix-sdk-crypto library! WebAssembly can run anywhere, but these bindings are designed to run on a JavaScript host. These bindings are part of the matrix-rust-sdk project, which is a library implementation of a Matrix client-server.

matrix-sdk-crypto is a no-network-IO implementation of a state machine, named OlmMachine, that handles E2EE (End-to-End Encryption) for Matrix clients.

Usage

  1. Install in your project:

    npm install --save @matrix-org/matrix-sdk-crypto-wasm
    

    or:

    yarn add @matrix-org/matrix-sdk-crypto-wasm
    
  2. Import the library into your project and initialise it.

    It is recommended that you use a dynamic import, particularly in a Web environment, because the WASM artifiact is large:

    async function loadCrypto(userId, deviceId) {
        const matrixSdkCrypto = await import("@matrix-org/matrix-sdk-crypto-wasm");
        await matrixSdkCrypto.initAsync();
    
        // Optional: enable tracing in the rust-sdk
        new matrixSdkCrypto.Tracing(matrixSdkCrypto.LoggerLevel.Trace).turnOn();
    
        // Create a new OlmMachine
        //
        // The following will use an in-memory store. It is recommended to use
        // indexedDB where that is available.
        // See https://matrix-org.github.io/matrix-rust-sdk-crypto-wasm/classes/OlmMachine.html#initialize
        const olmMachine = await matrixSdkCrypto.OlmMachine.initialize(
            new RustSdkCryptoJs.UserId(userId),
            new RustSdkCryptoJs.DeviceId(deviceId),
        );
    
        return olmMachine;
    }

Building

These WebAssembly bindings are written in Rust. To build them, you need to install the Rust compiler, see the Install Rust Page. Then, the workflow is pretty classical by using yarn, see the Downloading and installing Node.js and npm Page and installing yarn.

Once the Rust compiler, Node.js and yarn are installed, you can run the following commands:

$ yarn install
$ yarn build  # or 'yarn build:dev' to make an unoptimised build
$ yarn test

The compiled output should be generated in the pkg/ directory.

Documentation

The documentation can be found online.

To generate the documentation locally, please run the following command:

$ yarn doc

The documentation is generated in the ./docs directory.

matrix-rust-sdk-crypto-wasm's People

Contributors

richvdh avatar hywan avatar billcarsonfr avatar jplatte avatar poljar avatar florianduros avatar gnunicorn avatar andybalaam avatar andrewferr avatar uhoreg avatar johannescpk avatar zecakeh avatar anderas avatar bnjbvr avatar mtrnord avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.