-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGETTING_STARTED_WEB_CLI.md
86 lines (69 loc) · 2.56 KB
/
GETTING_STARTED_WEB_CLI.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
## Web application integration guide
### Installation
1. Install [polaris-web-extension](FUTURE_DEPLOYED_EXTENSION_LINK) from [Chrome Web Store](https://chromewebstore.google.com/category/extensions)
2. Install [signify-polaris-web](https://github.com/WebOfTrust/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](./src/config/types.ts) 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](./example-web/my-app/src/App.js) to see example.
Visit [Live Demo](https://signify-browser-extension.vercel.app/) for production demo.