npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oreid-webwidget

v1.4.2

Published

Popup Web User Experience for ORE ID

Downloads

51

Readme

ORE ID Web Widget Popup

Popup Web User Experience for ORE ID

This library can be used in any web application. However, if you are using React, you should use the React alternative to this library instead oreid-react.

Overview

This library works with oreid-js to provide a web pop-up user experince for common ORE ID flows - like logging-in and signing a transaction

Start a flow by triggering the user popup:

oreid.popup.auth({
    provider: 'google'
  })
  .then(onSuccess)
  .catch(onError);

This will launch a pop-up. When the user finishes the flow, the onError or onSuccess callback will be called.

This library works with oreid-js to save a users' accessToken after login to LocalStorage as well as perform other housekeeping functions.

Important

  • This library must be used within browser or a web wrapper component that has a window object
  • The auth login flow should be triggered by the user clicking on a button, link, or some other item that causes an Event. This will help get around pop-up blockers

Installation

npm install oreid-js oreid-webwidget

or

yarn add oreid-js oreid-webwidget

Sample Code

Initalize

import { OreId } from 'oreid-js'
import { WebWidget } from 'oreid-webwidget'

// Initialize libraries
const oreId = new OreId({ appId, apiKey, plugins:{ popup: WebWidget() }});
oreId.init().then(
  // oreid is ready
) 

Auth

import { oreId, isInitialized } from "./bootstrap";

<script>
  const onClick = () => {
    oreid.popup.auth({
      provider: 'google'
    })
    .then(data => { console.log(data) })
    .catch(error => { console.log(error) });
  }
</script>
<button click="onClick()">Auth</button>

Sign

import { oreId, isInitialized } from "./bootstrap";

<script>
  const onClick = () => {
    const userChainAccounts = oreId.auth.user.data.chainAccounts;
    // get first Ethereum account in user’s OREID account
    const ethAccount = userChainAccounts.find(ca => ca.chainNetwork === 'eth_main')
    // transactionBody is blockchain transaction (differs by chain type) 
    const transactionBody = {
      from: "0xF478...",
      to: "0xA200...",
      value: "1" // always a string
    };

    oreId.createTransaction({
      transaction: transactionBody,
      chainAccount: ethAccount.chainAccount,
      chainNetwork: ethAccount.chainNetwork,
    }).then(transaction => {
      // have the user approve signature
      oreId.popup.sign({ transaction })
        .then({ transactionId } => { ... })
        .catch(onError);
  })
  }
</script>
<button click="onClick()">Sign Transaction</button>

Create New Chain Account

import { oreId, isInitialized } from "./bootstrap";

<script>
  const onClick = () => {
      // have the user approve signature
      oreId.popup.newChainAccount({
        chainNetwork: 'eos-kylin',
      })
      .then({ chainAccount } => { ... })
      .catch(onError);
  }
</script>
<button click="onClick()">Create New Chain Account</button>

Recomended Startup Pattern

// bootstrap.ts
import { OreId } from "oreid-js";

export let oreId: OreId;
export let isInitialized: boolean = false;
const appId = "MY_APP_ID";

// Initialize libraries
() => {
  if(initialized) return;
  oreId = new OreId({ appId, plugins:{ popup: WebWidget() }}); // apiKey is required for some features
  oreId.init().then(() => {
    // webwidget is ready to use
    isInitialized = true
  })
}();