- Install polaris-web-extension from Chrome Web Store
- Install signify-polaris-web by listing it into
package.json
dependencies:
"dependencies": {
"signify-polaris-web": "https://github.com/WebOfTrust/polaris-web.git",
}
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";
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)
unsubscribeFromSignature
to unsubscription e.g:
useEffect(() => {
subscribeToSignature(handleSignifyData);
return () => {
unsubscribeFromSignature();
};
}, []);
requestAid
is called when authentication with AID is required, e.g:
<button onClick={requestAid}>Request AID</button>
requestCredential
is called when authentication with Credential is required, e.g:
<button onClick={requestCredential}>Request CREDENTIAL</button>
requestAidORCred
is called when authentication with either AID or Credential is required, e.g:
<button onClick={requestAidORCred}>Request AID or CREDENTIAL</button>
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>
Visit example-web/my-app to see example.
Visit Live Demo for production demo.