youverify-liveness-web 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # Youverify Livess Web SDK
2
+
3
+ > Software Development Kit for [Youverify](https://youverify.co)'s Liveness Check
4
+
5
+ ## Installation
6
+
7
+ To install, run one of the following commands:
8
+
9
+ ```sh
10
+ npm install youverify-liveness-web
11
+ ```
12
+ or
13
+
14
+ ```sh
15
+ yarn add youverify-liveness-web
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ 1. Import the package into your web page like so:
21
+
22
+ ```js
23
+ import YouverifyLiveness from "youverify-liveness-web";
24
+ ```
25
+
26
+ 2. Initialize an instance of the package, like so:
27
+
28
+ ```js
29
+ const yvLiveness = new YouverifyLiveness(options);
30
+ ```
31
+
32
+ > For a list of the valid options, check [this](#options) out
33
+
34
+ 3. Start the process, like so:
35
+
36
+ ```js
37
+ yvLiveness.start();
38
+ ```
39
+
40
+ This could also be called with an array of tasks. The supplied tasks override those provided during initialization.
41
+
42
+ ```js
43
+ const tasks = [{ id: "complete-the-circle" }];
44
+ yvLiveness.start();
45
+ ```
46
+
47
+ Full Example:
48
+
49
+ ```js
50
+ import YouverifyLiveness from "youverify-liveness-web";
51
+
52
+ try {
53
+ const yvLiveness = new YouverifyLiveness({
54
+ tasks: [{ id: "complete-the-circle" }],
55
+ });
56
+ yvLiveness.start();
57
+ } catch (error) {
58
+ // Handle Validation Errors
59
+ console.log(`Something isn't right, ${error}`);
60
+ }
61
+ ```
62
+
63
+ ## Options
64
+ | Option | Type | Required | Description | Default Value | Possible Values |
65
+ | --- | --- | --- | --- | --- | --- |
66
+ | `presentation` | String | No | Controls how UI is displayed | `modal` | `modal`, `page` |
67
+ | `tasks` | Array | No | Sets tasks that need to be performed for liveness to be confirmed | undefined | See [tasks](#tasks) |
68
+ | `user` | Object | No | Sets details of user for which liveness check is being performed | undefined | See nested options below |
69
+ | `user.firstName` | String | Yes | First name of user | - | Any string |
70
+ | `user.lastName` | String | No | Last name of user | undefined | Any string
71
+ | `user.email` | String | No | Email of user | undefined | Any string |
72
+ | `branding` | Object | No | Customizes UI to fit your brand | undefined | See nested options below
73
+ | `branding.color` | String | No | Sets your branding color | undefined | Valid hex or RGB string |
74
+ | `branding.logo` | String | No | Sets your logo | undefined | Valid image link |
75
+ | `allowAudio` | Boolean | No | Sets whether to narrate information to user during tasks | false | `true`, `false` |
76
+ | `onClose` | Function | No | Callback function that gets triggered when modal is closed | undefined | Any valid function |
77
+ | `onSuccess` | Function | No | Callback function that gets triggered when all tasks have been completed and passed. Called with completion [data](#callback-data) | undefined | Any valid function |
78
+ | `onFailure` | Function | No | Callback function that gets triggered when at least one task fails. Called with completion [data](#callback-data) | undefined | Any valid function |
79
+
80
+ ## Tasks
81
+
82
+ A task is a series of instructions for users to follow to confirm liveness. Find below a list of tasks.
83
+
84
+ > PS: We aim to frequently add to this list a variety of fun and yet intuitive ways of confirming liveness, so be on the lookout for more tasks!
85
+
86
+ ### Complete The Circle
87
+
88
+ User passes task by completing imaginary circle with head movement.
89
+
90
+ #### Options
91
+ | Option | Type | Required | Description | Default Value | Possible Values |
92
+ | --- | --- | --- | --- | --- | --- |
93
+ `id` | String | Yes | Id of task | - | `complete-the-circle` |
94
+ `difficulty` | String | No | Sets difficulty of task | `medium` | `easy`, `medium`, `hard` |
95
+ `timeout` | Number | No | Sets time in milliseconds after which task automatically fails | undefined | Any number in milliseconds |
96
+
97
+ ### Yes Or No
98
+
99
+ User passes task by answering a list of arbitrary questions set by you with the tilting of the head; right for a `yes` and left for a `no`.
100
+
101
+ #### Options
102
+ | Option | Type | Required | Description | Default Value | Possible Values |
103
+ | --- | --- | --- | --- | --- | --- |
104
+ | `id` | String | Yes | Id of task | - | `yes-or-no` |
105
+ | `difficulty` | String | No | Sets difficulty of task | `medium` | `easy`, `medium`, `hard` |
106
+ | `timeout` | Number | No | Sets time in milliseconds after which task automatically fails | undefined | Any number in milliseconds |
107
+ | `questions` | Array | No | A set of questions to ask user | undefined | See nested options below
108
+ | `questions.question` | String | Yes | Question to ask user. Should be a `true` or `false` type question. Eg: "Are you ready" | - | Any string
109
+ | `questions.answer` | Boolean | Yes | Answer to the question | - | `true`, `false` |
110
+ | `questions.errorMessage` | String | No | Error message to display if user gets question wrong | undefined | Any string |
111
+
112
+ ### Motions
113
+
114
+ User passes task by performing random motions in random sequences, which include `nodding`, `blinking` and `opening of mouth`.
115
+
116
+ #### Options
117
+ | Option | Type | Required | Description | Default Value | Possible Values |
118
+ | --- | --- | --- | --- | --- | --- |
119
+ | `id` | String | Yes | Id of task | - | `motions` |
120
+ | `difficulty` | String | No | Sets difficulty of task | `medium` | `easy`, `medium`, `hard` |
121
+ | `timeout` | Number | No | Sets time in milliseconds after which task automatically fails | undefined | Any number in milliseconds |
122
+ | `maxNods` | Number | No | Maximum amount of nods a user is asked to perform | 5 | Any number
123
+ | `maxBlinks` | Number | No | Maximum amount of nods a user is asked to perform | 5 | Any number |
124
+
125
+ ## Callback Data
126
+
127
+ The `onSuccess` and `onFailure` callbacks (if supplied) are passed the following data:
128
+
129
+ | Option | Type | Description |
130
+ | --- | --- | --- |
131
+ | `data` | Object | Data passed through callback |
132
+ | `data.video` | File | Video recording of entire liveness process
133
+ | `data.photo` | File | Face Image of user performing liveness check
134
+
135
+ ## Credits
136
+
137
+ This SDK is developed and maintained solely by [Youverify](https://youverify.co)
Binary file
@@ -0,0 +1,76 @@
1
+ declare interface Branding {
2
+ logo?: string;
3
+ color?: string;
4
+ }
5
+
6
+ declare type CompleteTheCircleTask = TaskBase<"complete-the-circle">;
7
+
8
+ declare interface LivenessData {
9
+ video: File;
10
+ photo: File;
11
+ }
12
+
13
+ declare interface LivenessWebSdkProps {
14
+ presentation?: Presentation;
15
+ tasks?: Array<Task>;
16
+ user?: User;
17
+ branding?: Branding;
18
+ allowAudio?: boolean;
19
+ onClose?: () => void;
20
+ onSuccess?: (data: LivenessData) => void;
21
+ onFailure?: (data: LivenessData) => void;
22
+ }
23
+
24
+ declare interface MotionsTask extends TaskBase<"motions"> {
25
+ maxNods?: number;
26
+ maxBlinks?: number;
27
+ }
28
+
29
+ declare type Presentation = "modal" | "page";
30
+
31
+ declare type Task = CompleteTheCircleTask | MotionsTask | YesOrNoTask;
32
+
33
+ declare interface TaskBase<T extends TaskId> {
34
+ id: T;
35
+ difficulty?: TaskDifficulty;
36
+ timeout?: number;
37
+ }
38
+
39
+ declare type TaskDifficulty = "easy" | "medium" | "hard";
40
+
41
+ declare type TaskId = "complete-the-circle" | "yes-or-no" | "facial-expressions" | "motions";
42
+
43
+ declare interface User {
44
+ firstName: string;
45
+ lastName?: string;
46
+ email?: string;
47
+ }
48
+
49
+ declare class WebSDK {
50
+ private tasks;
51
+ private container;
52
+ private namespace;
53
+ private props;
54
+ private presentation;
55
+ private scriptsURLs;
56
+ private addedResources;
57
+ constructor(props: LivenessWebSdkProps);
58
+ private addResources;
59
+ private removeResources;
60
+ start(tasks?: Array<Task>): Promise<void>;
61
+ close(): void;
62
+ terminate(): void;
63
+ }
64
+ export default WebSDK;
65
+
66
+ declare interface YesOrNoQuestion {
67
+ question: string;
68
+ answer: boolean;
69
+ errorMessage?: string;
70
+ }
71
+
72
+ declare interface YesOrNoTask extends TaskBase<"yes-or-no"> {
73
+ questions?: Array<YesOrNoQuestion>;
74
+ }
75
+
76
+ export { }