4.7.2 • Published 9 months ago

oreid-js v4.7.2

Weekly downloads
154
License
MIT
Repository
github
Last release
9 months ago

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

4.7.0

11 months ago

4.7.2-pre

9 months ago

4.7.2

9 months ago

4.7.1

11 months ago

4.7.1-pre2

9 months ago

4.7.2-pre2

9 months ago

4.5.2

1 year ago

4.5.1

1 year ago

4.4.1

2 years ago

4.4.2

2 years ago

4.5.0-beta-1

1 year ago

4.5.0

1 year ago

4.4.0

2 years ago

4.4.1-beta.0

2 years ago

4.4.1-beta.1

2 years ago

4.4.1-beta.2

2 years ago

4.4.1-beta.3

2 years ago

4.4.1-beta.4

2 years ago

4.3.2

2 years ago

4.3.1-beta.0

2 years ago

4.3.1

2 years ago

4.3.0

2 years ago

4.2.2

2 years ago

4.1.1-beta.0

2 years ago

4.1.1-beta.2

2 years ago

4.1.1-beta.1

2 years ago

4.1.1-beta.7

2 years ago

4.1.1-beta.4

2 years ago

4.1.1-beta.3

2 years ago

4.1.1-beta.5

2 years ago

4.0.5

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.4

2 years ago

4.1.3

2 years ago

4.1.0

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

3.2.0

2 years ago

4.0.4

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

4.0.2-beta3

2 years ago

4.0.2-beta2

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.4

2 years ago

4.0.2-beta

2 years ago

3.4.0

2 years ago

3.4.2

2 years ago

3.4.1

2 years ago

4.0.0-next.0

2 years ago

4.0.1-beta.0

2 years ago

4.0.0-beta.0

2 years ago

4.0.1-beta.1

2 years ago

3.0.10

2 years ago

3.0.11

2 years ago

3.0.8-beta.0

2 years ago

3.0.8-beta.1

2 years ago

1.0.3

2 years ago

3.0.0-beta.20

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

3.0.5-beta.0

2 years ago

3.0.0-beta.13

2 years ago

3.0.0-beta.14

2 years ago

3.0.0-beta.15

2 years ago

3.0.0-beta.16

2 years ago

3.0.0-beta.17

2 years ago

3.0.9

2 years ago

3.0.9-next.0

2 years ago

2.17.0-next.2

2 years ago

3.0.0-beta.10

2 years ago

3.0.0-beta.11

2 years ago

3.0.0-beta.12

2 years ago

3.0.0-beta.1

2 years ago

3.0.0-beta.0

2 years ago

2.17.0-next.1

2 years ago

3.0.0-beta.3

2 years ago

3.0.0-beta.2

2 years ago

3.0.0-beta.5

2 years ago

3.0.0-beta.4

2 years ago

3.0.0-beta.7

2 years ago

3.0.0-beta.6

2 years ago

3.0.0-beta.9

2 years ago

3.0.0-beta.8

2 years ago

2.16.3-beta.0

2 years ago

2.15.1-beta.4

2 years ago

2.15.1-beta.5

2 years ago

2.15.0-next.0

2 years ago

2.15.0-next.1

2 years ago

2.13.11

2 years ago

2.13.10

2 years ago

2.13.8

2 years ago

2.13.9

2 years ago

2.13.7

2 years ago

2.15.0

2 years ago

2.15.1-beta.0

2 years ago

2.15.1-beta.1

2 years ago

2.15.1-beta.2

2 years ago

2.15.1-beta.3

2 years ago

2.17.0-next.0

2 years ago

2.16.3

2 years ago

2.16.1

2 years ago

2.16.2

2 years ago

2.14.1

2 years ago

2.16.0

2 years ago

2.14.2

2 years ago

2.14.0

2 years ago

2.13.6

3 years ago

2.13.5

3 years ago

2.13.4

3 years ago

2.13.3

3 years ago

2.13.2

3 years ago

2.13.0

3 years ago

2.13.1

3 years ago

2.12.8

3 years ago

2.12.7

3 years ago

2.12.5

3 years ago

2.12.6

3 years ago

2.12.3

3 years ago

2.12.4

3 years ago

2.12.1

3 years ago

2.12.2

3 years ago

2.12.0

3 years ago

2.11.0

3 years ago

2.10.8

3 years ago

2.10.6

3 years ago

2.10.5

3 years ago

2.10.3

3 years ago

2.10.4

3 years ago

2.10.2

3 years ago

2.10.1

3 years ago

2.10.0

3 years ago

2.9.0

3 years ago

2.8.2

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.7.12

3 years ago

2.7.11

3 years ago

2.7.10

3 years ago

2.7.9

3 years ago

2.7.8

3 years ago

2.7.6

4 years ago

2.7.5

4 years ago

2.7.4

4 years ago

2.7.3

4 years ago

2.7.2

4 years ago

2.7.1

4 years ago

2.7.0

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.3

4 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago