0.1.55 • Published 2 years ago

guardee v0.1.55

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.49

2 years ago

0.1.41

2 years ago

0.1.42

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.45

2 years ago

0.1.46

2 years ago

0.1.47

2 years ago

0.1.48

2 years ago

0.1.40

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.0.106

2 years ago

0.1.20

2 years ago

0.0.105

2 years ago

0.1.21

2 years ago

0.0.104

2 years ago

0.1.22

2 years ago

0.0.103

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.0.109

2 years ago

0.1.25

2 years ago

0.0.108

2 years ago

0.1.26

2 years ago

0.0.107

2 years ago

0.0.102

2 years ago

0.0.101

2 years ago

0.0.100

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.0.117

2 years ago

0.0.116

2 years ago

0.1.10

2 years ago

0.0.115

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.0.119

2 years ago

0.1.15

2 years ago

0.0.118

2 years ago

0.0.113

2 years ago

0.0.112

2 years ago

0.0.111

2 years ago

0.0.110

2 years ago

0.0.120

2 years ago

0.0.123

2 years ago

0.0.122

2 years ago

0.0.121

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.0.95

2 years ago

0.0.96

2 years ago

0.0.97

2 years ago

0.0.98

2 years ago

0.0.99

2 years ago

0.0.93

2 years ago

0.0.92

2 years ago

0.0.91

2 years ago

0.0.90

2 years ago

0.0.89

2 years ago

0.0.88

2 years ago

0.0.87

2 years ago

0.0.86

2 years ago

0.0.85

2 years ago

0.0.84

2 years ago

0.0.83

2 years ago

0.0.82

2 years ago

0.0.81

2 years ago

0.0.80

2 years ago

0.0.79

2 years ago

0.0.78

2 years ago

0.0.77

2 years ago

0.0.76

2 years ago

0.0.75

2 years ago

0.0.74

2 years ago

0.0.73

2 years ago

0.0.72

2 years ago

0.0.71

2 years ago

0.0.70

2 years ago

0.0.69

2 years ago

0.0.68

2 years ago

0.0.67

2 years ago

0.0.66

2 years ago

0.0.65

2 years ago

0.0.64

2 years ago

0.0.63

2 years ago

0.0.62

2 years ago

0.0.61

2 years ago

0.0.60

2 years ago

0.0.59

2 years ago

0.0.58

2 years ago

0.0.57

2 years ago

0.0.56

2 years ago

0.0.55

2 years ago

0.0.54

2 years ago

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.49

2 years ago

0.0.48

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago