This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

guardee

0.1.55 • Public • Published

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

Package Sidebar

Install

npm i guardee

Weekly Downloads

28

Version

0.1.55

License

MIT

Unpacked Size

79.5 kB

Total Files

29

Last publish

Collaborators

  • artifriends