0.1.55 • Published 3 years ago

guardee v0.1.55

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

guardee-js

NPM Version

NPM Install Size

NPM Downloads

Installation

  npm install guardee

Basic Usage

The constructor of the guardee client takes an object with parameters such as signalserver_host, signalserver_key and connect_option. Syntax:

const Guardee = require('guardee');
const guardee = new Guardee({
    signalserver_host: 'http://signalserver.guardee.io',
    signalserver_key: '906c7939ed0007b48b9c779302d788299183cb4a',
    connect_option: {
        initiator: true,
    },
});

signalserver_host and signalserver_key

You need to acquire signalserver_host and signalserver_key which contemporary Guardee wallet provides. These arguments are used to communicate with the signal server for peer-to-peer connection between your dApp and Guardee wallet.

connect_option

connetion_option is used by guardee.connector to provide options for its peer-to-peer connection. In case of NodeJS, you need to provide wrtc as a parameter.

const Guardee = require('guardee');
const wrtc = require('wrtc');
const guardee = new Guardee({
    signalserver_host: 'http://signalserver.guardee.io',
    signalserver_key: '906c7939ed0007b48b9c779302d788299183cb4a',
    connect_option: {
        initiator: true,
        wrtc: wrtc
    },
});

API

guardee.connector

RegisterGenesisOffer

Register genesis connection offer to the signal server.

  • connectionOffer : Object { connectionId, offer } (optional) connection offer object
  • waitSeconds : Number How long should the code wait measured in seconds (default = 60)

CancelGenesisOffer

Cancel genesis connection offer and notice to the signal server

Request

Send request to connected peer

  • type : String request type (account_connection, sign_tx, send_tx)
  • body : Object request body
  • encode : Boolean (optional) whether to stringify request body
  • encrypt : Boolean (optional) whether to encode and encrypt request body with password
  • password : String (optional) password to encrypt request body

Response

Send response to connected peer

  • type : String response type (account_connection, sign_tx, send_tx)
  • body : Object response body
  • encode : Boolean (optional) whether to stringify response body
  • encrypt : Boolean (optional) whether to encode and encrypt response body with password
  • password : String (optional) password to encrypt response body

SendDataSequence

Send data sequence to the connected peer

  • type : String data sequence type ('sign_tx', 'send_tx')
  • dataSequence : Array array of sequential transactions

SendDataChunkSequence

Send already chunked data sequence to the connected peer

  • type : String data sequence type ('sign_tx', 'send_tx')
  • dataChunkSequence : Array chunked array of sequential transactions

Disconnect

Destroy all guardee.connector.connections

Reset

Reset connections

On

Listen on given event and run callback

  • event: String
  • cb: Function
  • options: Object

RemoveEventListener

Remove EventListener on given event callback function

  • event: String
  • fn: Function
  • options: Object

guardee.encoder

Stringify

Encode given object into safe uri component

  • obj: Object

Parse

Decode given string into original object

  • stringified: String

Events

There are 15 different events that guardee.connector emits when connection issues occur.

  • genesis_connection: Emitted when the genesis connection is initiated
  • genesis_offer: Emitted when the genesis connection offer is generated
  • genesis_offer_register: Emitted when the genesis connection offer is registered to the signal server
  • genesis_offer_cancel: Emitted when the genesis connection offer is cancelled
  • genesis_answer_received: Emitted when the answer for the genesis connection offer is received
  • genesis_answer_set: Emitted when the answer for the genesis connection is set to the instance
  • error: Emitted when error occurs
  • ready: Emitted when stable amount of connections are alive
  • disconnect: Emitted when every peer connection is destroyed
  • request: Emitted when request is received
  • response: Emitted when response is received
  • chunk: Emitted when chunk is received
  • chunk_start: Emitted when the first chunk is sent
  • chunk_data: Emitted when chunk data is sent
  • chunk_end: Emitted when the last chunk is sent
0.1.52

3 years ago

0.1.53

3 years ago

0.1.54

3 years ago

0.1.55

3 years ago

0.1.50

3 years ago

0.1.51

3 years ago

0.1.49

3 years ago

0.1.41

3 years ago

0.1.42

3 years ago

0.1.43

3 years ago

0.1.44

3 years ago

0.1.45

3 years ago

0.1.46

3 years ago

0.1.47

3 years ago

0.1.48

3 years ago

0.1.40

3 years ago

0.1.38

3 years ago

0.1.39

3 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.36

3 years ago

0.1.37

3 years ago

0.1.27

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.0.106

3 years ago

0.1.20

3 years ago

0.0.105

3 years ago

0.1.21

3 years ago

0.0.104

3 years ago

0.1.22

3 years ago

0.0.103

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.0.109

3 years ago

0.1.25

3 years ago

0.0.108

3 years ago

0.1.26

3 years ago

0.0.107

3 years ago

0.0.102

3 years ago

0.0.101

3 years ago

0.0.100

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.0.117

3 years ago

0.0.116

3 years ago

0.1.10

3 years ago

0.0.115

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.0.119

3 years ago

0.1.15

3 years ago

0.0.118

3 years ago

0.0.113

3 years ago

0.0.112

3 years ago

0.0.111

3 years ago

0.0.110

3 years ago

0.0.120

3 years ago

0.0.123

3 years ago

0.0.122

3 years ago

0.0.121

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.0.95

3 years ago

0.0.96

3 years ago

0.0.97

3 years ago

0.0.98

3 years ago

0.0.99

3 years ago

0.0.93

3 years ago

0.0.92

3 years ago

0.0.91

3 years ago

0.0.90

3 years ago

0.0.89

3 years ago

0.0.88

3 years ago

0.0.87

3 years ago

0.0.86

3 years ago

0.0.85

3 years ago

0.0.84

3 years ago

0.0.83

3 years ago

0.0.82

3 years ago

0.0.81

3 years ago

0.0.80

3 years ago

0.0.79

3 years ago

0.0.78

3 years ago

0.0.77

3 years ago

0.0.76

3 years ago

0.0.75

3 years ago

0.0.74

3 years ago

0.0.73

3 years ago

0.0.72

3 years ago

0.0.71

3 years ago

0.0.70

3 years ago

0.0.69

3 years ago

0.0.68

3 years ago

0.0.67

3 years ago

0.0.66

3 years ago

0.0.65

3 years ago

0.0.64

3 years ago

0.0.63

3 years ago

0.0.62

3 years ago

0.0.61

3 years ago

0.0.60

3 years ago

0.0.59

3 years ago

0.0.58

3 years ago

0.0.57

3 years ago

0.0.56

3 years ago

0.0.55

3 years ago

0.0.54

3 years ago

0.0.53

3 years ago

0.0.52

3 years ago

0.0.51

3 years ago

0.0.50

3 years ago

0.0.49

3 years ago

0.0.48

3 years ago

0.0.47

3 years ago

0.0.46

3 years ago

0.0.45

3 years ago

0.0.44

3 years ago

0.0.43

3 years ago

0.0.42

3 years ago

0.0.41

3 years ago

0.0.40

3 years ago

0.0.39

3 years ago

0.0.38

3 years ago

0.0.37

3 years ago

0.0.35

3 years ago

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago