3.6.7 • Published 2 years ago

@dedis/cothority v3.6.7

Weekly downloads
19
License
LGPL-3.0-or-later
Repository
github
Last release
2 years ago

Cothority client library in Javascript

This library offers methods to talk to a cothority node. At this point, it offers a socket interface that marshals and unmarshals automatically protobuf messages.

Usage

Import the library using

import Cothority from "@dedis/cothority"

Check out the example in index.html for a browser-based usage

Documentation

Execute npm run doc to generate the documentation and browse doc/index.html

Development

You need to have npm installed. Then

git clone https://github.com/dedis/cothority"
cd cothority/external/js/cothority
npm install

You should be able to run the tests with

npm run test

To run the tests, be sure to have docker installed and make docker executed from the root of this repo.

Protobuf generation

To add a new protobuf file to the library, simply place your *.proto file somewhere in lib/protobuf/build/models and then run

npm run protobuf

That would compile all protobuf definitions into a single JSON file (models.json). This json file is then embedded in the library automatically.

Publishing

You must use the given script instead of npm publish because we need to publish the dist folder instead. If you try to use the official command, you will get an error on purpose.

Message classes

You can write a class that will be used when decoding protobuf messages by using this template:

class MyMessage extends Message<MyMessage> {
    /**
     * @see README#Message classes
     */
    static register() {
        registerMessage("abc.MyMessage", MyMessage, MyMessageDependency);
    }

    readonly myField: MyMessageDependency;

    constructor(props?: Properties<MyMessage>) {
        super(props);

        // whatever you need to do for initialization
    }
}

MyMessage.register();

Note that protobuf will instantiate with an empty object and then fill the fields so this happens after the constructor has been called. The register is used to register the dependencies of the message but you also have to use it as a side effect of the package so that as soon as the class is imported, the message will be known by protobuf and used during decoding.

Side note on Buffer

Protobuf definition and classes implemented expect a Buffer for bytes but as you should know, in a browser environment bytes are instantiated with Uint8Array. You should then be aware that the actual type will be Uint8Array when using the library in a browser environment but the buffer interface will be provided thanks to the buffer package.

As this is a polyfill, please check that what you need is implemented or you will need to use a different approach. Of course for NodeJS, you will always get a Buffer.

Use a development version from an external app

Steps to use js/cothority as a local module for a local external app:

1) Build a version

(cothority/external/js/cothority) $ npm run build

2) Create a link

(cothority/external/js/cothority) $ npm run link

3) From the root folder of the external app, link the new package

(external_app) $ npm link @dedis/cothority

4) To unlink

(external_app) $ npm unlink @dedis/cothority
(cothority/external/js/cothority) $ npm unlink
3.6.7

2 years ago

3.6.6

2 years ago

3.6.5

2 years ago

3.6.4

3 years ago

3.6.3

3 years ago

3.6.2

4 years ago

3.6.1

4 years ago

3.5.5

4 years ago

3.5.4

4 years ago

3.5.2

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.7

4 years ago

3.4.6

4 years ago

3.4.4

4 years ago

3.4.3

4 years ago

3.4.2

4 years ago

3.4.1

4 years ago

3.4.0

4 years ago

3.1.11

4 years ago

3.1.10

4 years ago

3.1.9

5 years ago

3.1.8

5 years ago

3.1.7

5 years ago

3.1.5

5 years ago

3.1.5-pretest.0

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

3.0.0-pre6

5 years ago

3.0.0-pre5

5 years ago

3.0.0-pre4

5 years ago

3.0.0-pre3

5 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago