Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

guardee

Package Overview
Dependencies
Maintainers
1
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

guardee

Guardee Wallet API

  • 0.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75
decreased by-63.59%
Maintainers
1
Weekly downloads
 
Created
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 signal server.

  • connectionOffer : Object { connectionId, offer } (optional) connection offer object
  • waitSeconds : Number How long should the code wait measured in seconds (default = 60)
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
Destroy

Destroy all guardee.connector.connections

  • notice: Boolean whether to notice connection peer of destruction
On

Listen on given event and run callback

  • event: String
  • cb: Function

guardee.encoder

Stringify

Encode given object into safe uri component

  • obj: Object
Parse

Decode given string into original object

  • stringified: String

Events

There are 14 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_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
  • destroy: Emitted when all 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

Package last updated on 12 Oct 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc