Skip to content

Latest commit

 

History

History
86 lines (69 loc) · 2.56 KB

GETTING_STARTED_WEB_CLI.md

File metadata and controls

86 lines (69 loc) · 2.56 KB

Web application integration guide

Installation

  1. Install polaris-web-extension from Chrome Web Store
  2. Install signify-polaris-web by listing it into package.json dependencies:
"dependencies": {
  "signify-polaris-web": "https://github.com/WebOfTrust/polaris-web.git",
}

Usage

import following methods from signify-polaris-web

import {
  subscribeToSignature, // subscribe to receive signature
  unsubscribeFromSignature, // can be used to unsubscribe
  requestAid, // call to select aid for signing in
  requestCredential, // call to select credential for signing in
  requestAidORCred, // call to select either aid of credential
  requestAutoSignin, // call for auto signin
} from "signify-polaris-web";

Usage subscribeToSignature

subscribeToSignature is a mandatory subscription call that receives a function to return signature, e.g:


const handleSignifyData = (data: ISignature) => {
    console.log("signature", data);
};

useEffect(() => {
    subscribeToSignature(handleSignifyData);
    return () => {
      unsubscribeFromSignature();
    };
  }, []);

ISignature data type

The callback from subscribeToSignature receives signature that contains header and credential(optional)

Usage unsubscribeFromSignature

unsubscribeFromSignature to unsubscription e.g:

useEffect(() => {
    subscribeToSignature(handleSignifyData);
    return () => {
      unsubscribeFromSignature();
    };
  }, []);

Usage requestAid

requestAid is called when authentication with AID is required, e.g:

<button onClick={requestAid}>Request AID</button>

Usage requestCredential

requestCredential is called when authentication with Credential is required, e.g:

<button onClick={requestCredential}>Request CREDENTIAL</button>

Usage requestAidORCred

requestAidORCred is called when authentication with either AID or Credential is required, e.g:

<button onClick={requestAidORCred}>Request AID or CREDENTIAL</button>

Usage requestAutoSignin

requestAutoSignin is called to auto-signin with an already selected pair. The app asks to select one from the extension if there is no auto sign-in pair exists.

<button onClick={requestAutoSignin}>Auto Sign in</button>  

Example Usage

Visit example-web/my-app to see example.

Visit Live Demo for production demo.