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

enface-auth-widget

v1.1.3

Published

Enface blockchain & biometric authorization (browser widget)

Downloads

59

Readme

Enface biometric authentication (browser widget)

Enface offers biometric authorization feature for any websites (or apps) using Enface application and neural networks face recognition engine. Our authentication process is based on strong cryptographic algorithms combined with biometric user's data.

To enable our solution you should pass the following steps:

  • Integrate the EnfaceAuth library with your backend.
  • Setup frontend widget on your website or application, using instructions below.

Installation

npm

npm i --save enface-auth-widget

yarn

yarn add enface-auth-widget

Usage

ES2015 module import:

import { EnfaceAuthWidget } from "enface-auth-widget";

CommonJS module require:

const { EnfaceAuthWidget } = require("enface-auth-widget");

Initialization:

new EnfaceAuthWidget({

  url: <string>,
  buttonHolderId: <string>
  debug: <boolean> // debug logs

  onUserAuthInfo() {
    // get user's session token, session id, cookie etc.
  },

  onChangeState(isActive, isInitialCheck) {
    // status of biometric signin for current user.
  },

  onAuthorized(token) {
    // user succesfully authorized
  },

  onFailed() {
    // user authorization failed
  },

});

EnfaceAuthWidget parameters and callbacks (all functions can be asynchronous):

url <string>

Full EnfaceAuth library backend URL. If backend mode is "WebSockets", this variable should looks like ws(s)://yourdomain.com:12345, where "12345" is the listening port of EnfaceAuth library. If backend mode is "HTTP/S" this variable should looks like http(s)://yourdomain.com

buttonHolderId: <string>

Upon creation Enface Widget will look for the element with corresponding "id" on the page and attach "onClick" handler with biometric actions. If "onUserAuthInfo" callback returns any data (user is currently logged in) - the enable/disable actions will be performed, authorization chain will be started instead.

onUserAuthInfo(): <string>

Return current user authorization data (token, session id, cookie etc.) if any. The returned value will be processed in "onUserValidate" callback of EnfaceAuth library and must definetly identify the user. If current user is guest, return an empty string, null or nothing at all.

onChangeState(isActive, isInitialCheck)

This function is used to determine current state of biometric signin (turned ON/OFF). The only task of this callback is to correctly visualize your interface parts to let the user manipulate biometric signin state - show a button with appropriate caption, checkbox etc. See example below.

onAuthorized(token)

This function will be called on successfull user authorization. "onUserTokenByBioId" method of EnfaceAuth library should send a valid user session data in incoming "token" variable (token, session id, cookie etc). Javascript should use this data to initialize authorized session for current user.

onFailed : <string>

This function will be called on biometric authorization failure. Show any messages or dialogs to notify the user about the failure.

Here is how EnfaceAuthWidget is integrated at our own React frontend.

We are widely using hooks in the frontend application, so we put "useAuthWidget" at signin page and in the settings component, where the switcher "Turn biometric signin ON/OF" is placed.

export const SignInPage = () => {

  useAuthWidget();

  /* the rest of SignInPage component's code*/
}
export const TopBar = () => {

  useAuthWidget();

  /* the rest of TopBar component's code*/
}

Here is full "useAuthWidget" hook code:

const useAuthWidget = () => {

  const { history } = useReactRouter();

  useEffect(() => {
    new EnfaceAuthWidget({
      url: 'https://enface-api-server.herokuapp.com',
      buttonHolderId: 'enfaceWidgetButtonHolder',

      onUserAuthInfo() {
        // return current session token
        return sessionStorage.getItem('token');
      },

      onChangeState(isActive, isInitialCheck) {
        // if "isInitialCheck" is true - this is just initialization check and no messages should be shown to the user
        const statusElem = document.getElementById('enfaceWidgetButtonHolder');
        // changing interface elements regarding the biometric state
        statusElem && (statusElem.innerHTML = `${isActive ? 'Disable' : 'Enable'} biometric sign in`);
        isInitialCheck || dialog.show({
          caption: 'Operation succeed',
          message: `Your biometric signin is now ${isActive ? 'enabled' : 'disabled'}`,
          buttons: ['I got it'],
        });
      },

      onAuthorized(token) {
        // use the "token" variable to initialize authorized session
        sessionStorage.setItem('token', token);
        history.push(paths.PATH_ROOT);
      },

      onFailed() {
        dialog.show({
          caption: 'Biometric signin failed',
          message: "We don't know you or biometric signin is turned off in your profile settings. Please sign in using email & password and enable biometric authorization in the members are.",
          buttons: ['I got it'],
        });
      },

    });
  }, []);
};