GithubHelp home page GithubHelp logo

oreid-js's Introduction

oreid-js

ORE ID Helper library written in Javascript

About

oreid-js is a javascript helper library for interacting with the Aikon ORE ID service.

ORE ID is a simple way to add OAuth login to your blockchain enabled app.

Install this npm package as well as the related oreid-webpopup package:

yarn add oreid-js oreid-webpopup

Usage

Example code:

// import this library and the Web popup widget
import { OreId } from "oreid-js";
import { WebPopup } from "oreid-webpopup";
// Initialize libraries
const oreId = new OreId({ appId, apiKey, plugins: { popup: WebPopup() } })
oreId
  .init()
  .then
  // oreId is ready
  ()

Auth

//Initialize the libraries
const oreId = new OreId({ appId, apiKey, plugins:{popup: WebPopup()}});
await oreId.init()

// launch popup for user to login
oreId.popup.auth({ provider: 'google' })
  .then((data) => {console.log(data)})
  .catch((errors) => {console.log(errors)});

User

// access logged-in user info
const userData = await oreid.auth.user.getData()
console.log(`Hello ${userData.name}`)

Transaction

// Get the first Ethereum account in the user's account
const ethAccount = user.data.chainAccounts.find(ca => ca.chainNetwork === 'eth_ropsten');

// create and sign transaction
const transaction = await oreid.createTransaction({
  chainAccount: ethAccount,
  chainNetwork: 'eth_ropsten',
  transaction: { to: '0x123...', amount: '.0001' },
  signOptions: { broadcast: true }
});

// launch popup for sign flow - when completed, transaction info is returned
oreId.popup.sign({ transaction })
  .then((results) => { console.log('txId:', results.transactionId)}),
  .catch(error => { ... });

Express Middleware

This library includes Express middleware that you can use to simplify handling the callbacks from the ORE ID service.

// authCallbackHandler middleware handles callback response from ORE ID and extracts results
app.use('/authcallback', authCallbackHandler(oreId))

Check out the Express Server example for a complete example.

For Ethereum chains

We support Ethereum and related test networks. Just use one of the following for chainNetwork parameter in the sign request. For example...

  • 'eth_main' - Etherem Main network
  • 'eth_ropsten' - Etherem Ropsten test network
  • 'eth_rinkeby' - Etherem Rinkeby test network

For Algorand chains

We support Algorand and related test networks. Just use one of the following for chainNetwork parameter in the sign request. For example...

  • 'algo_main' - Algorand Main network
  • 'algo_test' - Algorand test network
  • 'algo_beta' - Algorand Beta test network (upcoming features)

NOTE: Algorand chains require an API Key (to be added to OreId options). You can get a free key by signing-up here

For EOS chains

We support EOS, ORE, and other EOSIO-based chains. Just use one of the following for chainNetwork parameter in the sign request. For example...

  • 'eos_main' - Eos Main network
  • 'eos_kylin' - Eos Kylin test network
  • 'eos_jungle' - Eos Jungle test network
  • 'ore_main' - ORE Main network
  • 'ore_test' - ORE test network

Using EOS Transit

oreid-js makes it easy for you to add many popular blockchain wallets to your app. It integrates EOS Transit so that you can use any wallet they support. oreid-js is the easiest way to add support for signing with blockchain wallets to your app.

EOS Transit

// add the provider package for each wallet you want to support
import scatterProvider from 'eos-transit-scatter-provider';
// pass in the array of providers when you initialize the library
const eosTransitWalletProviders = [ scatterProvider(), ... ]
const oreId = new OreId({ ..., eosTransitWalletProviders });

NOTE: This project uses a forked version of Eos-Transit library to support non-Eos blockchains (package: @aikon/eos-transit).


Current Support

Providers/Authenticators
Algorand - AlgoSigner
Ethereum - web3 (Metamask)
Ethereum - walletConnect
EOS - Keycat
EOS - Ledger
EOS - Lynx
EOS - Meet One
EOS - Portis
EOS - Scatter
EOS - Token Pocket
EOS - Whalevault

Check out the Express Server example for a complete example.

Example projects

Refer to the examples folder in the ore-id-docs repo for the following sample projects

  • ReactJS - A simple ReactJS website that includes React Login button component

  • React Native - A React Native app that includes a React OAuth flow modal component

  • Express Server - A simple Express server that includes the use of middleware to automate handling of callbacks

  • React Passwordless - A simple ReactJS website to call the passwordless api

Tests

Check this file

oreid-js's People

Contributors

artmanque avatar basarrcan avatar blackwatertepes avatar deckb avatar dependabot[bot] avatar dhruv-kumar-jha avatar fractallian avatar mamoonahmad avatar randytorres avatar sgehrman avatar snyk-bot avatar surabhil avatar traylewin avatar warrickfitz avatar yardz avatar zsnake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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

oreid-js's 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.