Giter VIP home page Giter VIP logo

piconnectdev / edge-core-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edgeapp/edge-core-js

0.0 0.0 0.0 5.55 MB

Edge Core Javascript implementation. Provides Edge account and wallet functionality for NodeJS/HTML/React Native apps

Home Page: https://edge.app

License: Other

Shell 0.07% JavaScript 0.48% Ruby 0.15% C 3.84% Objective-C 0.07% Java 1.57% TypeScript 92.43% Swift 1.37% CMake 0.03%

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.

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.