Giter VIP home page Giter VIP logo

edge-core-js's Introduction

Edge Core

This library implements the Edge login system. It runs inside a client application, and provides zero-knowledge backup for cryptographic keys and other secrets via a familiar password-based login system.

Build Status JavaScript Style Guide code style: prettier

Documentation

We have documentation at https://developer.airbitz.co/javascript/, but our Flow types are the best, most up-to-date reference for what this library contains.

Account Management UI

To quickly get up and running with the UI for account creation, login, and management, use edge-login-ui-web for the web or edge-login-ui-rn for React Native.

Setup

Add this library to your project using npm install --save edge-core-js.

Node.js & Browsers

To create an EdgeContext object, which provides various methods for logging in and creating account, do something like this:

const context = await makeEdgeContext({
  apiKey: '...', // Get this from our support team
  appId: 'com.your-app',
  plugins: {
    // Configure currencies, exchange rates, and swap providers you want to use:
    'bitcoin': true
  }
})

The core uses various plugins to provide its currency, exchange rate, and swap features. These plugins ship separately, and are designed to load in parallel with the core:

import { addEdgeCorePlugins, lockEdgeCorePlugins } from 'edge-core-js'
import exchangePlugins from 'edge-exchange-plugins'
import bitcoinPlugins from 'edge-currency-bitcoin'
import currencyPlugins from 'edge-currency-accountbased'

addEdgeCorePlugins(exchangePlugins)
addEdgeCorePlugins(bitcoinPlugins)
addEdgeCorePlugins(currencyPlugins)
lockEdgeCorePlugins()

If the core seems to hang forever when logging in, you probably forgot to call lockEdgeCorePlugins.

Please note that edge-core-js uses modern JavaScript syntax features such as async, so you may need to run the library through Babel if you plan to run it in a browser. Node 10+ supports these features natively.

React Native

Edge-core-js directly supports React Native v0.60+ with autolinking. Simply add edge-core-js to your application, and React Native will link the necessary native modules & assets.

To create an EdgeContext object, you need to mount a component:

<MakeEdgeContext
  // Get this from our support team:
  apiKey="..."
  appId="com.your-app"

  // Configure currencies and swap providers you want to use:
  plugins={{
    'bitcoin': true
  }}
  pluginUris={[
    "edge-currency-plugins.js",
    "edge-exchange-plugins.js"
  ]}

  // Called when the core is done loading:
  onLoad={edgeContext => {}}
  onError={error => {}}
/>

The core itself runs inside a hidden WebView, which this MakeEdgeContext component mounts & manages.

The core creates a <script> tag for each source file in the pluginUris array. For this to work, you need to add these plugin files to your app's native asset bundle, which is located at /android/app/src/main/assets/ on Android. For iOS, drag these files into the "Resources" section of your Xcode project.

To debug the core, run yarn start inside the edge-core-js project, and then pass a debug={true} property to the MakeEdgeContext component. This tells the WebView to load the core from a local development server.

Contributing

Run yarn to download dependencies, and then run yarn prepare to build the library.

Use yarn verify to run all our code-quality tools. All sources are in the JavaScript Standard Style + Prettier. We check files prior to each commit, so if you have formatting issues, you can run yarn fix to fix them automatically.

If you use Visual Studio Code, consider installing the ESLint extension. This will give you nice error highlighting as you work, along with quick fixes for formatting issues.

edge-core-js's People

Contributors

adyshimony avatar ahujsak avatar amanalili avatar bruscantini avatar dependabot[bot] avatar dylanseago avatar jon-edge avatar koretskiyav avatar kylanhurt avatar omahs avatar passabilities avatar paullinator avatar peachbits avatar samholmes avatar sfncook avatar swansontec avatar teneighty avatar thehobbit85 avatar vird avatar wolverineks 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

Watchers

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

edge-core-js's Issues

Edge claims to be "open source" but is not open source

In the FAQ, Airbitz/Edge claims that the wallet code is "open source"

"Is the Airbitz Wallet Open Source?
Yes. Airbitz believes in complete transparency and our source code is open for use and review by anyone.

Airbitz uses a modified BSD license which freely permits viewing and usage of the source code but requires permission to use modified code.
"

https://airbitz.co/go/faq/airbitz-wallet-open-source/
https://github.com/EdgeApp/edge-core-js/blob/develop/LICENSE

However, the Airbitz license does not meet Criteria 3 of the Open Source definition:

"The license must allow modifications and derived works, and must allow them to be distributed under the same terms as the license of the original software."

https://opensource.org/osd-annotated

Therefore, Airbitz/Edge's claims to be "open source" are incorrect. IMO, you should describe your source code as "source viewable".

How to handle the account after create account.

const abc = require('edge-core-js');
const context = await abc.makeEdgeContext({
apiKey: API_KEY,
appId: APP_ID,
});
const { username, password } = user;
const re = await abcContext.loginWithPassword(
username,
password
);
console.log("Result:", re);

But I can't get edgeaccount after login though there is a new folder called edge wallet created and login account file is created.

why is EdgeMetaToken not EdgeToken?

I haven't found anything about metatokens anywhere. Consensus seems to be simply calling them tokens. erc-20 calls them tokens, coinbase calls them tokens. where does the "meta" part come in?

Uncaught TypeError: Not a bridgeable object

im running into this when archiving then activating a wallet

magic.js:116 Uncaught TypeError: Not a bridgeable object
    at getInstanceMagic (magic.js:116)
    at addListener (manage.js:33)
    at Object.on (bridgeable.js:12)
    at edgeCurrencyWallet.ts:104

wallet._yaob exists when active, but when archived and re-activated it's undefined from then on

console.log({ 
  _yaob: wallet._yaob, // {localId: 27, bridges: Array(0), listeners: {…}, watchers: {…}}
  ...wallet
})
console.log({ 
  _yaob: wallet._yaob, // undefined 
  ...wallet
})

Peer dependency error when installing Yarn

I get this error when trying to initialise yarn, Its a peer dependency issue
➤ YN0000: ┌ Resolution step ➤ YN0002: │ edge-login-ui-web@npm:0.6.12 doesn't provide react-native-fast-crypto (p81562), requested by edge-core-js ➤ YN0002: │ edge-login-ui-web@npm:0.6.12 doesn't provide react-native-randombytes (p5c5f1), requested by edge-core-js ➤ YN0002: │ edge-login-ui-web@npm:0.6.12 doesn't provide react-native-tcp (p213a8), requested by edge-core-js ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code

Non-JSON reply, HTTP status 503

edge-core-js can crash app with unhandled rejection

Error: Non-JSON reply, HTTP status 503, /api/v2/store/ca41***/aedb***
at response.json.catch.jsonError (/usr/src/app/node_modules/edge-core-js/lib/core/storage/storage-servers.js:55:17)
at process._tickCallback (internal/process/next_tick.js:68:7)

There are no specific steps to reproduce, seems there is no retry logic here

response.json().catch(jsonError => {

Seems sync is called without proper error wrapping

Documentation needs to be updated

With the latest changes to edge-login, using require('airbitz-core-js') is now breaking. Documentation still references this as the way to setup and use this project.

JSON corruption due concurrent file write

Due internal actions of edge wallet it can corrupt WalletName.json
sample of corrupted file
{"encryptionType":0,"iv_hex":"KmI7"}nbccfS5KIQIGo9k2iPW3Zp8pxV2Zg4XGo5sG3qHCU="}

You can look at really similar problem here nodejs/node#7978
Problem is located here https://github.com/EdgeApp/edge-core-js/blob/master/src/core/storage/repo.js#L78
We can call saveChanges before other saveChanges is occurs and now disklet comes...
It has relatively slow file write https://github.com/EdgeApp/disklet/blob/master/src/backends/node.ts#L89

So it tries to write, can't, tries to make directory and write one more time.
That's enough for fast second saveChanges call.
So first deepWriteFile made directory and tries to write
second saveChanges call calls deepWriteFile and tries to write too.

Unable to resolve module `crypto`

On a fresh edge-login install to react native, when I run react-native run-ios it will build successfully but when attempting to use the app it gives me the error.

bundling failed: UnableToResolveError: Unable to resolve module crypto from ../node_modules/edge-login/lib/edge-core-index.js: Module does not exist in the module map

xpub address uses wrong magic constants

I tested this for bitcoin and bitcoin testnet. Edge Wallet generates a new seed and uses a BIP49 derivation scheme. According to the spec the expected prefixes in base58 are "ypub" or "upub" respectively. But in the app the prefixes are "xpub" or "tpub" respectively.

ChangePIN is not working

Hi, there is a problem with ChangePIN functionality.
It returns no Error and the same hash as a result no matter what pin passed as a prop.
It works the same on my project or even in your https://github.com/Airbitz/airbitz-core-js-ui

Steps to reproduce

  1. Clone and install https://github.com/Airbitz/airbitz-core-js-ui
  2. Register and try to change pin – it says that pin is successfully changed
  3. Try to login using new pin (you won't be able to do it)
  4. Try to login using old pin (It will work)

Peer dependencies with git URLs made AurgurProject CI unhappy with NPM

"peerDependencies": {

Since this change our CI breaks on installing items with NPM. Works fine in yarn.

npm ERR! peer dep missing: babel-plugin-module-resolver@^2.5.0, required by [email protected]
npm ERR! peer dep missing: react-native-fast-crypto@^1.5.3, required by [email protected]
npm ERR! peer dep missing: react-native-randombytes@git://github.com/Airbitz/react-native-randombytes.git#40d02a5f922, required by [email protected]
npm ERR! peer dep missing: react-native-tcp@git://github.com/Airbitz/react-native-tcp.git, required by [email protected]

Not sure about you guys but putting in git deps for a release version seems... unstable.

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.