Giter Club home page Giter Club logo

eosjs-keygen's Introduction

NPM

Repository

The purpose of this library is for managing keys in local storage. This is designed to derive and cache keys but also needs a password manager to store a "root" key. This library does not have secure or password protected storage. It does however figure out permission hierarchies and is configurable enough to only store keys you feel are safe to store.

General purpose cryptography is found in eosjs-ecc library. Hierarchical deterministic key generation uses PrivateKey.getChildKey in eosjs-ecc.

Usage

let {Keystore, Keygen} = require('eosjs-keygen')
Eos = require('eosjs')

sessionConfig = {
  timeoutInMin: 30,
  uriRules: {
    'owner' : '/account_recovery',
    'active': '/(transfer|contracts)',
    'active/**': '/producers'
  }
}

keystore = Keystore('myaccount', sessionConfig)
eos = Eos.Testnet({keyProvider: keystore.keyProvider})

Keygen.generateMasterKeys().then(keys => {
  // create blockchain account called 'myaccount'
  console.log(keys)

  eos.getAccount('myaccount').then(account => {
    keystore.deriveKeys({
      parent: keys.masterPrivateKey,
      accountPermissions: account.permissions
    })
  })

})

See ./API

Development

let {Keystore, Keygen} = require('./src')

Use Node v8+ (updates package-lock.json)

Browser

git clone https://github.com/EOSIO/eosjs-keygen.git
cd eosjs-keygen
npm install
npm run build
# builds: ./dist/eosjs-keygen.js
<script src="eosjs-keygen.js"></script>
<script>
//kos.Keystore
//kos.Keygen
//...
</script>

Runtime Environment

Node 6+ and browser (browserify, webpack, etc)

Built with React Native in mind, create an issue if you find a bug.

eosjs-keygen's People

Contributors

dependabot[bot] avatar jcalfee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eosjs-keygen's Issues

Keygen is not defined

Trying to add eosjs-keygen to Angular project. Eosjs and eosjs-api are already added.
Code is looking like:

declare var Keygen: any
declare var Keystore: any
import { Keystore, Keygen } from 'eosjs-keygen'
//…
Keygen.generateMasterKeys().then(keys => {
    console.log(keys)
  })

I have tried different ways to do it, but same result: "ReferenceError: Keygen is not defined".
Have tried also generate eosjs-keygen.js file and use it with simple html page. Same result.
Help needed or some more documentation.

UPDATE:
Keygen is also missing there:
var {format, api, ecc, json, Fcbuffer} = Eos.modules

Probably it could be taken somehow from eos initialization.

keystore storage query

is the keystore component platform independent? we are considerring to dev a wallet app with RN, not sure whether if will be supported or not.

React Native got error: "Browser history needs a DOM"

when import eosjs-keygen, i got the error: "Browser history needs a DOM"

Environment

Environment:
  OS: macOS High Sierra 10.13.1
  Node: 8.9.1
  Yarn: 0.24.5
  npm: 5.5.1

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.4 => 0.55.4

wx20180616-130458 2x

Module `assert` does not exist

Hey,
I am using eosjs-keygen for generating EOS key, in my React and React-Native app. Key-pairs are generated successfully in React, but when I tried same thing on React-Native, it causes following issue :

Error: Unable to resolve module assert from /home/Desktop/React-Native/project/node_modules/eosjs-keygen/lib/keystore.js: Module assert does not exist in the Haste module map.

Error: "secure random number generation not supported by this browser"

Sorry for noob question here, but I want to know how I use this library.

So I ran the command:

// Install library
git clone https://github.com/EOSIO/eosjs-keygen.git
cd eosjs-keygen
npm install
npm run build

// Then go to the `dist` directory
cd dist

// And run the compiled JS file
node eosjs-keygen

After I ran this code, an error popped up:

C:\eosjs-keygen-master\dist\eosjs-keygen.js:18594
  throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
  ^

Error: secure random number generation not supported by this browser
use chrome, FireFox or Internet Explorer 11
    at oldBrowser (C:\eosjs-keygen-master\dist\eosjs-keygen.js:18594:9)
    at Object.<anonymous> (C:\eosjs-keygen-master\dist\eosjs-keygen.js:13352:28)
    at Object.62../hash (C:\eosjs-keygen-master\dist\eosjs-keygen.js:13595:4)
    at s (C:\eosjs-keygen-master\dist\eosjs-keygen.js:1:679)
    at C:\eosjs-keygen-master\dist\eosjs-keygen.js:1:730
    at Object.<anonymous> (C:\eosjs-keygen-master\dist\eosjs-keygen.js:13170:16)
    at Object.61../hash (C:\eosjs-keygen-master\dist\eosjs-keygen.js:13325:4)
    at s (C:\eosjs-keygen-master\dist\eosjs-keygen.js:1:679)
    at C:\eosjs-keygen-master\dist\eosjs-keygen.js:1:730
    at Object.<anonymous> (C:\eosjs-keygen-master\dist\eosjs-keygen.js:11966:17)

Please help :D

Eos.Testnet in the README is undefined

the README states I should be able to do:

Eos = require('eosjs')
eos = Eos.Testnet(...)

but if I:

console.log(Eos.Testnet)

I get undefined. I'm using v20.0.0-beta3 of eosjs. how is this supposed to work?

Can't run build

Hi, I get this error when running node run build:

JSDOC_ERROR: /.../eosjs-keygen/node_modules/requizzle/lib/requizzle.js:45
if (lookupPaths[0] === targetPath && lookupPaths[1].length === 0) {
TypeError: Cannot read property '0' of null
....

Random number generator problem in React Native

I'm building a React Native app and on IOS when I attempt to run it, get the following error:

Error: secure random number generation not supported by this browser. use chrome, Firefox or Internet Explorer 11

what package can I install to fix this?

sample code fails

code from readme fails with error:

api error =>  https://t1readonly.eos.io/v1/chain/get_account {"account_name":"myaccount1231548489"}
{ FetchError: request to https://t1readonly.eos.io/v1/chain/get_account failed, reason: connect ETIMEDOUT 35.164.81.64:443
    at ClientRequest.<anonymous> (/Users/info/_sites/eos/node_modules/node-fetch/index.js:133:11)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at TLSSocket.socketErrorListener (_http_client.js:385:9)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'FetchError',
  message: 'request to https://t1readonly.eos.io/v1/chain/get_account failed, reason: connect ETIMEDOUT 35.164.81.64:443',
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT' }
{ FetchError: request to https://t1readonly.eos.io/v1/chain/get_account failed, reason: connect ETIMEDOUT 35.164.81.64:443
    at ClientRequest.<anonymous> (/Users/info/_sites/eos/node_modules/node-fetch/index.js:133:11)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at TLSSocket.socketErrorListener (_http_client.js:385:9)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'FetchError',
  message: 'request to https://t1readonly.eos.io/v1/chain/get_account failed, reason: connect ETIMEDOUT 35.164.81.64:443',
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT' }
Error:  { FetchError: request to https://t1readonly.eos.io/v1/chain/get_account failed, reason: connect ETIMEDOUT 35.164.81.64:443
    at ClientRequest.<anonymous> (/Users/info/_sites/eos/node_modules/node-fetch/index.js:133:11)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at TLSSocket.socketErrorListener (_http_client.js:385:9)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'FetchError',
  message: 'request to https://t1readonly.eos.io/v1/chain/get_account failed, reason: connect ETIMEDOUT 35.164.81.64:443',
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT' }

Possible Unresolved promise in deriveKeys

Executing the following code will hang

const deriveAccountKeys = async (accountName) => {
    const masterKeys = await Keygen.generateMasterKeys()
    const eosioKeystore = Keystore("eosio")
    eosioKeystore.deriveKeys({ parent: <use a valid key here> })
}

When I remove deriveKeys it properly exits or if I call process.exit().

Oddly enough I can still print out the keys it generates

const pubKeys = eosioKeystore.getKeys("active").map(key => key.pubkey)
console.log(pubKeys)

create a new account as the readme

{ Error: {"code":500,"message":"Internal Service Error","error":{"code":0,"name":"exception","what":"unspecified","details":[{"message":"unk
nown key",

Keys without network access

How to generate master key and derived keys without network access?
How to convert keys to corresponding address?

Keystore 'invalid login' behaviour

Invalid login happens in keystore.deriveKeys only as a result of a complete blockchain miss-match in keys:

  • you provide a blockchain account permissions object and your login (key) does not match any key in the permissions

To assist with a new user sign-up process, deriveKeys may encounter key changes even if they are saved to the device's storage.

Using eosjs-ecc, should migrate to eosjs v21 methodology

With the near release of eosjs v21, a push from eosjs-ecc to elliptic has been decided. This repository utilizes eosjs-ecc and should migrate to the new methodology using eosjs v21 and elliptic.

Before the release of eosjs v21, the eosjs edge release on npm will have the necessary functionality as well as the elliptic npm package to create a branch for this repo ready to release after eosjs v21.

Please see related PRs for example migrations:
EOSIO/eosio-reference-chrome-extension-authenticator-app#37
EOSIO/ual-scatter#56
EOSIO/eosjs-ledger-signature-provider#32

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.