Coder Social home page Coder Social logo

eosjs-keos's Introduction

eosjs-keos

JavaScript API for using keos as Signature Provider to replace the JsSignatureProvider.

Install

$ npm install eosjs-keos

Import

The official distribution package can be found at npm.

const { Api, JsonRpc, RpcError } = require('eosjs');
const { KeosSignatureProvider } = require('eosjs-keos/sig');
const fetch = require('node-fetch');                         // node only; not needed in browsers
const { TextEncoder, TextDecoder } = require('util');        // node only; native TextEncoder/Decoder

Basic Usage

The Signature Provider HOLDS the wallet password to unlock the wallet to signing transactions.

The Signature Provider DOES NOT HOLD any private keys directly.

const options = {
    keosApi: 'http://127.0.0.1:8900',
    wallet: 'keosjs_test',
    password: 'PWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
};
const signatureProvider = new KeosSignatureProvider(options);

It should be a drop in replacement. After these config, you can use native eosjs APIs smoothly. The Signature Provider will do the rest under the hood. More details can be found here.

Advance Options

skipUnlock

skipUnlock: false by default. You can enable this option skipUnlock: true to turn off the auto-unlock feature for extreme security. The Signature Provider can be run WITHOUT any password or key configurations. You have to lock/unlock the wallet all by yourself.

checkBeforeUnlock

checkBeforeUnlock: false by default. This means the Signature Provider will try to unlock the wallet whenever needed. It's fast and stable but will case annoying logs in the keosd console.

Example:

thread-0  http_plugin.cpp:932  handle_exception  ] FC Exception encountered while processing wallet.unlock

Set checkBeforeUnlock: true will force The Signature Provider to query and determine if the wallet needs to be unlocked, before actually unlock runs. It's a little bit slower but you can get a cleaner keosd console. It might cause issues when the wallet-unlock timeouts after check-action and before sign-action.

Complete Implementation of keos APIs

const KEOS = require('eosjs-keos');
const keos = new KEOS({ /* options */ });

API available:

  • getRpcUrl: AsyncFunction
  • rpcRequest: AsyncFunction
  • getSupportedApis: AsyncFunction
  • createWallet: AsyncFunction
  • listWallet: AsyncFunction
  • unlock: AsyncFunction
  • lock: AsyncFunction
  • lockAll: AsyncFunction
  • createKey: AsyncFunction
  • getPublicKeys: AsyncFunction
  • importKey: AsyncFunction
  • stop: AsyncFunction
  • openWallet: AsyncFunction
  • listKeys: AsyncFunction
  • removeKey: AsyncFunction
  • setTimeout: AsyncFunction
  • signDigest: AsyncFunction
  • signTransaction: AsyncFunction

Required chain access APIs

const CHAIN = require('eosjs-keos/chain');
const chain = new CHAIN({ /* options */ });

API available:

  • getRpcUrl: AsyncFunction
  • rpcRequest: AsyncFunction
  • makeActions: Function
  • getExpiration: Function
  • makeTransaction: AsyncFunction
  • getInfo: AsyncFunction
  • getAbiByAccountName: AsyncFunction
  • abiJsonToBin: AsyncFunction
  • getAbiBin: AsyncFunction
  • makeAbiActions: AsyncFunction
  • getRequiredKeys: AsyncFunction
  • getBlock: AsyncFunction
  • pushTransaction: AsyncFunction

Test

$ npm test

eosjs-keos's People

Contributors

leask avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.