Socket
Socket
Sign inDemoInstall

guardee

Package Overview
Dependencies
7
Maintainers
1
Versions
175
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    guardee

Guardee Wallet API


Version published
Weekly downloads
21
increased by50%
Maintainers
1
Install size
10.2 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 19 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc