sonic-widget 2.7.21 → 2.7.52
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/LICENSE +21 -21
- package/README.md +399 -391
- package/dist/index.js +1517 -1517
- package/dist/models/Tensorflow/coco_ssd_lite_mobilenet_v2/model.json +21548 -21548
- package/dist/service-worker.js +79 -79
- package/package.json +52 -51
package/README.md
CHANGED
|
@@ -1,391 +1,399 @@
|
|
|
1
|
-
# SONIC WIDGET
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/sonic-widget)
|
|
4
|
-
[](https://www.npmjs.com/package/sonic-widget)
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/sonic-widget)
|
|
6
|
-
[](https://www.jsdelivr.com/package/npm/sonic-widget)
|
|
7
|
-
|
|
8
|
-
## Installation:
|
|
9
|
-
|
|
10
|
-
**Sonic Widget** - _used to show the onboard kyc at your web page itself._
|
|
11
|
-
|
|
12
|
-
Use this script tag to get access to the widget:
|
|
13
|
-
|
|
14
|
-
```html
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@2.7.
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
or
|
|
19
|
-
|
|
20
|
-
in **Angular** can be used by installing package from npm
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
npm install sonic-widget
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
and adding path in `angular.json`
|
|
27
|
-
|
|
28
|
-
```json
|
|
29
|
-
"scripts": [ "node_modules/sonic-widget/dist/index.js" ]
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Implementation Details for Angular TypeScript:
|
|
34
|
-
|
|
35
|
-
**Steps:-**
|
|
36
|
-
|
|
37
|
-
1. Create or open an angular TS project.
|
|
38
|
-
|
|
39
|
-
2. Use this script tag to get access to the widget at initial html page:
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@2.7.
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
or
|
|
46
|
-
|
|
47
|
-
it can be added in `angular.json` by installing the npm package
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
"scripts": [ "node_modules/sonic-widget/dist/index.js" ]
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
3. At `app.component.html`, Add a button with the id **`xxxx`**. It is used to call the widget by on click event.
|
|
54
|
-
|
|
55
|
-
```html
|
|
56
|
-
<button id="xxxx">Open</button>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
4. Add a div tag with the id **`sonic-web-widget`** at the specific place. It is used to display the sonic module with the help of this id.
|
|
60
|
-
|
|
61
|
-
```html
|
|
62
|
-
<div id="sonic-web-widget"></div>
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
5. Add a declaration for var *sonic* at TS file `app.component.ts`.
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
declare var sonic: any;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
6. Next, add the functionality to call widget in the base of onInit.
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
ngOnInit(): void {
|
|
75
|
-
|
|
76
|
-
const config = {
|
|
77
|
-
baseurl: string, // the base url of the backend server
|
|
78
|
-
docModelPath: string, // the doc model url of the document recognition process
|
|
79
|
-
maskModelPath: string, // the mask model url of the mask detect process
|
|
80
|
-
faceModelUrl: string, // the face model url of the face recognition process
|
|
81
|
-
handModelUrl: string, // the hand model url of the hand recognition process
|
|
82
|
-
objectModelUrl: string, // the object model url of the object recognition process
|
|
83
|
-
ipInfoKey: string,
|
|
84
|
-
googleMapKey: string,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
container
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
- _**`
|
|
308
|
-
- _**`
|
|
309
|
-
- _**`
|
|
310
|
-
- _**`
|
|
311
|
-
- _**`
|
|
312
|
-
- _**`
|
|
313
|
-
- _**`
|
|
314
|
-
- _**`
|
|
315
|
-
- _**`
|
|
316
|
-
- _**`
|
|
317
|
-
- _**`
|
|
318
|
-
- _**`
|
|
319
|
-
- _**`
|
|
320
|
-
- _**`
|
|
321
|
-
- _**`
|
|
322
|
-
- _**`
|
|
323
|
-
- _**`
|
|
324
|
-
- _**`
|
|
325
|
-
- _**`
|
|
326
|
-
- _**`
|
|
327
|
-
- _**`
|
|
328
|
-
- _**`
|
|
329
|
-
- _**`
|
|
330
|
-
- _**`
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
Description : The
|
|
384
|
-
Range : 0-1 (default: 0.
|
|
385
|
-
Functionality :
|
|
386
|
-
* If
|
|
387
|
-
* This
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
1
|
+
# SONIC WIDGET
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/sonic-widget)
|
|
4
|
+
[](https://www.npmjs.com/package/sonic-widget)
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/sonic-widget)
|
|
6
|
+
[](https://www.jsdelivr.com/package/npm/sonic-widget)
|
|
7
|
+
|
|
8
|
+
## Installation:
|
|
9
|
+
|
|
10
|
+
**Sonic Widget** - _used to show the onboard kyc at your web page itself._
|
|
11
|
+
|
|
12
|
+
Use this script tag to get access to the widget:
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@2.7.52/dist/index.min.js"></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
or
|
|
19
|
+
|
|
20
|
+
in **Angular** can be used by installing package from npm
|
|
21
|
+
|
|
22
|
+
```shell
|
|
23
|
+
npm install sonic-widget
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
and adding path in `angular.json`
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
"scripts": [ "node_modules/sonic-widget/dist/index.js" ]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Implementation Details for Angular TypeScript:
|
|
34
|
+
|
|
35
|
+
**Steps:-**
|
|
36
|
+
|
|
37
|
+
1. Create or open an angular TS project.
|
|
38
|
+
|
|
39
|
+
2. Use this script tag to get access to the widget at initial html page:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@2.7.52/dist/index.min.js"></script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
or
|
|
46
|
+
|
|
47
|
+
it can be added in `angular.json` by installing the npm package
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
"scripts": [ "node_modules/sonic-widget/dist/index.js" ]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. At `app.component.html`, Add a button with the id **`xxxx`**. It is used to call the widget by on click event.
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<button id="xxxx">Open</button>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. Add a div tag with the id **`sonic-web-widget`** at the specific place. It is used to display the sonic module with the help of this id.
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<div id="sonic-web-widget"></div>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
5. Add a declaration for var *sonic* at TS file `app.component.ts`.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
declare var sonic: any;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
6. Next, add the functionality to call widget in the base of onInit.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
ngOnInit(): void {
|
|
75
|
+
|
|
76
|
+
const config = {
|
|
77
|
+
baseurl: string, // the base url of the backend server
|
|
78
|
+
docModelPath: string, // the doc model url of the document recognition process
|
|
79
|
+
maskModelPath: string, // the mask model url of the mask detect process
|
|
80
|
+
faceModelUrl: string, // the face model url of the face recognition process
|
|
81
|
+
handModelUrl: string, // the hand model url of the hand recognition process
|
|
82
|
+
objectModelUrl: string, // the object model url of the object recognition process
|
|
83
|
+
ipInfoKey: string, // the ip info key
|
|
84
|
+
googleMapKey: string, // the google map key
|
|
85
|
+
googleCaptchaKey: string, // the google reCAPTCHA site key
|
|
86
|
+
passphrase: string, // the encryption key
|
|
87
|
+
showPage: boolean, // used to show the page or not
|
|
88
|
+
speedCheckURL: string, // public URL of the internet speed check
|
|
89
|
+
videoURL: string, // url of video to do (e.g: demo doing kyc) (Optional)
|
|
90
|
+
appId: string, // application policy identifier
|
|
91
|
+
accountId: string, // account can be taken from operator axiom account
|
|
92
|
+
appName: string, // representing name of the application (Optional)
|
|
93
|
+
userName: string, // user prospective data
|
|
94
|
+
userId: string, // user document number to identity
|
|
95
|
+
email: string, // user prospective data
|
|
96
|
+
phone: string, // user prospective data
|
|
97
|
+
applicationNo: string, // user prospective data
|
|
98
|
+
isMalay: boolean, //used to change the default language english to malay
|
|
99
|
+
branchId: string, //used to identify the bank branch
|
|
100
|
+
sendLogsEmail: boolean, //used to send logs through email
|
|
101
|
+
blinkThreshold: number, // used for blink threshold
|
|
102
|
+
eyeOpenThreshold: number, // used for eye open threshold
|
|
103
|
+
disableUploadDocs: boolean, // used to show/hide the upload docs option.
|
|
104
|
+
objectPersonThreshold: number, // used for object Person score threshold
|
|
105
|
+
objectPhoneThreshold: number, // used for object Phone score threshold
|
|
106
|
+
grayscalePercentageThreshold: number, // used for black&white percentage score threshold
|
|
107
|
+
onMessage: function (data) {}, // callback function, when api response message or error or any other actions
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// get the element used in the action button
|
|
111
|
+
var container = document.getElementById('xxxx');
|
|
112
|
+
// on click of element widget works
|
|
113
|
+
container?.addEventListener('click', function () {
|
|
114
|
+
sonic?.SonicWidget(config);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
7. Add service worker for widget to protect the multiple calls for tensorflow. So, it will have cache to reuse it. Here, I'm adding `service-worker.js` file at `src/assets` folder. So, below steps will be based on this file path.
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
const CACHE_NAME = 'demo-app-ai-tensorflow-models-cache-v1';
|
|
123
|
+
const urlsToCache = [
|
|
124
|
+
// coco ssd - tensorflow model
|
|
125
|
+
// document model - teachable machine drive link or folder path
|
|
126
|
+
// mask model - teachable machine drive link or folder path
|
|
127
|
+
// face landmark model - mediapipe tasks-vision
|
|
128
|
+
// hand landmark model - mediapipe tasks-vision
|
|
129
|
+
// Add more model files if necessary
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
self.addEventListener('install', function(event) {
|
|
133
|
+
// Perform install steps
|
|
134
|
+
event.waitUntil(
|
|
135
|
+
caches.open(CACHE_NAME)
|
|
136
|
+
.then(function(cache) {
|
|
137
|
+
return cache.addAll(urlsToCache);
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
self.addEventListener('fetch', function(event) {
|
|
143
|
+
const request = event.request;
|
|
144
|
+
|
|
145
|
+
// Skip caching for requests from browser extensions
|
|
146
|
+
if (request.url.startsWith('chrome-extension://')) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
event.respondWith(
|
|
151
|
+
caches.match(request)
|
|
152
|
+
.then(function(response) {
|
|
153
|
+
// Cache hit - return response
|
|
154
|
+
if (response) {
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Clone the request
|
|
159
|
+
const fetchRequest = request.clone();
|
|
160
|
+
|
|
161
|
+
return fetch(fetchRequest).then(
|
|
162
|
+
function(response) {
|
|
163
|
+
// Check if we received a valid response
|
|
164
|
+
if(!response || response.status !== 200 || response.type !== 'basic') {
|
|
165
|
+
return response;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Clone the response
|
|
169
|
+
const responseToCache = response.clone();
|
|
170
|
+
// Save the response for future matching
|
|
171
|
+
caches.open(CACHE_NAME)
|
|
172
|
+
.then(function(cache) {
|
|
173
|
+
cache.put(request, responseToCache);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return response;
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
})
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
8. Use this script tag to get access to the service worker at initial html page:
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<script src="src/assets/service-worker.js"></script>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
or
|
|
190
|
+
|
|
191
|
+
it can be added in `angular.json` by installing the npm package
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
"scripts": [ ..., "src/assets/service-worker.js" ]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
9. Register the service worker at your required place:
|
|
198
|
+
```ts
|
|
199
|
+
ngAfterViewInit(): void {
|
|
200
|
+
if ('serviceWorker' in navigator) {
|
|
201
|
+
window.addEventListener('load', () => {
|
|
202
|
+
navigator.serviceWorker.register('/demo-app/assets/service-worker.js').then(
|
|
203
|
+
(registration) => {
|
|
204
|
+
console.log(
|
|
205
|
+
'ServiceWorker registered with scope: ',
|
|
206
|
+
registration.scope
|
|
207
|
+
);
|
|
208
|
+
},
|
|
209
|
+
(err) => {
|
|
210
|
+
console.error('ServiceWorker registration failed: ', err);
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
## Implementation Details for Vanilla JavaScript:
|
|
221
|
+
|
|
222
|
+
**Steps:-**
|
|
223
|
+
|
|
224
|
+
1. Create or open an html file.
|
|
225
|
+
|
|
226
|
+
2. Add a button with the id **`xxxx`**. It is used to call the widget by on click event.
|
|
227
|
+
|
|
228
|
+
```html
|
|
229
|
+
<button id="xxxx">Open</button>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
3. Add a div tag with the id **`sonic-web-widget`** at the last or beginning of the body tag. It is used to display the sonic module with the help of this id.
|
|
233
|
+
|
|
234
|
+
```html
|
|
235
|
+
<div id="sonic-web-widget"></div>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
4. Add a Script tag to the head tag or body tag. And use the latest version.
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<script src="https://cdn.jsdelivr.net/npm/sonic-widget@2.7.52/dist/index.min.js"></script>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
5. Next, add the script tag at a necessary place. But add below the widget script.
|
|
245
|
+
|
|
246
|
+
```html
|
|
247
|
+
<script>
|
|
248
|
+
const config = {
|
|
249
|
+
baseurl: string, // the base url of the backend server
|
|
250
|
+
docModelPath: string, // the doc model url of the document recognition process
|
|
251
|
+
maskModelPath: string, // the mask model url of the mask detect process
|
|
252
|
+
faceModelUrl: string, // the face model url of the face recognition process
|
|
253
|
+
handModelUrl: string, // the hand model url of the hand recognition process
|
|
254
|
+
objectModelUrl: string, // the object model url of the object recognition process
|
|
255
|
+
ipInfoKey: string, // the ip info key
|
|
256
|
+
googleMapKey: string, // the google map key
|
|
257
|
+
googleCaptchaKey: string, // the google reCAPTCHA site key
|
|
258
|
+
passphrase: string, // the encryption key
|
|
259
|
+
showPage: boolean, // used to show the page or not
|
|
260
|
+
speedCheckURL: string, // public URL of the internet speed check
|
|
261
|
+
videoURL: string, // url of video to do (e.g: demo doing kyc) (Optional)
|
|
262
|
+
appId: string, // application policy identifier
|
|
263
|
+
appName: string, // representing name of the application (Optional)
|
|
264
|
+
accountId: string, // account can be taken from operator axiom account
|
|
265
|
+
userName: string, // user prospective data
|
|
266
|
+
userId: string, // user document number to identity
|
|
267
|
+
email: string, // user prospective data
|
|
268
|
+
phone: string, // user prospective data
|
|
269
|
+
applicationNo: string, // user prospective data
|
|
270
|
+
isMalay: boolean, //used to change the default language english to malay
|
|
271
|
+
branchId: string, // branch id to identify the branch of the bank
|
|
272
|
+
sendLogsEmail: boolean, //used to send logs through email
|
|
273
|
+
blinkThreshold: number, // threshold used to calculate the user's eye blinked or not, with range limit 0-1(default value is 0.35)
|
|
274
|
+
eyeOpenThreshold: number, // threshold used to calculate the user's eye open or not, with range limit 0-1(default value is 0.2)
|
|
275
|
+
disableUploadDocs: boolean, // used to pass a boolean value. It is used to disable the upload option the document process
|
|
276
|
+
objectPersonThreshold: number, // used for object Person score threshold with range limit 0-1(default value is 0.925)
|
|
277
|
+
objectPhoneThreshold: number, // used for object Phone score threshold with range limit 0-1(default value is 0.5)
|
|
278
|
+
grayscalePercentageThreshold: number, // used for black&white percentage score threshold with range limit 0-100(default value is 80)
|
|
279
|
+
onMessage: function (data) {}, // callback function, when api response message or error or any other actions
|
|
280
|
+
};
|
|
281
|
+
// get the element used in the action button
|
|
282
|
+
var container = document.getElementById('xxxx');
|
|
283
|
+
// on click of element widget works
|
|
284
|
+
container.addEventListener('click', function () {
|
|
285
|
+
sonic.SonicWidget(config);
|
|
286
|
+
});
|
|
287
|
+
</script>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
_Here, the config variable is used to pass the data. And the container variable is to get the dom element of the id **`xxxx`** button and add it to the event listener. It checks if the button is clicked and sends the config object data to the **`sonic`** module.
|
|
291
|
+
**`sonic.SonicWidget(config)`**_
|
|
292
|
+
|
|
293
|
+
_You can get the logs with **`onMessage`** for all actions and stages.
|
|
294
|
+
Check with **`data.code`**_
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
0 - info message from application
|
|
298
|
+
1 - success api call
|
|
299
|
+
-1 - failed api call
|
|
300
|
+
-2 - error message from application
|
|
301
|
+
-3 - configuration error message
|
|
302
|
+
2 - on close application
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Note:-**
|
|
306
|
+
|
|
307
|
+
<!-- - _**`serviceWorkerPath`** should pass as a string value. It is used as the service worker path and its default path is **`/demo-app/assets/service-worker.js`** and Cache name should be different to fix conflict._ -->
|
|
308
|
+
- _**`baseurl`** should pass as a string value. It is used as the base URL for API calls._
|
|
309
|
+
- _**`docModelPath`** should pass as a string value. It is used as the base URL for document model._
|
|
310
|
+
- _**`maskModelPath`** should pass as a string value. It is used as the base URL for mask model._
|
|
311
|
+
- _**`faceModelUrl`** should pass as a string value. It is used as the base URL for task vision face model._
|
|
312
|
+
- _**`handModelUrl`** should pass as a string value. It is used as the base URL for task vision hand model._
|
|
313
|
+
- _**`objectModelUrl`** should pass as a string value. It is used as the base URL for coco-ssd object model._
|
|
314
|
+
- _**`showPage`** is used to pass a boolean value ( **`true`** or **`false`** ). To toggle the widget page open or close._
|
|
315
|
+
- _**`speedCheckURL`** should pass as a string value. It is used to detect internet speed and intimate the user._
|
|
316
|
+
- _**`videoURL`** should pass as a string value as url. It is used to show the video onboard sonic kyc and it is optional._
|
|
317
|
+
- _**`accountId`** should pass as a string value. It is used to get the JWT token and proceed with the operator account._
|
|
318
|
+
- _**`isMalay`** is used to pass a boolean value ( **`true`** or **`false`** ). To toggle the widget default language english or malay._
|
|
319
|
+
- _**`branchId`** should pass as a string value. It is used to find bank branch available for operator account for onboard sonic kyc._
|
|
320
|
+
- _**`appId`** should pass as a string value. It is used to find an application policy for onboard sonic kyc._
|
|
321
|
+
- _**`appName`** should pass as a string value. It is used for onboard kyc application name. it is optional and default **`Sonic`** ._
|
|
322
|
+
- _**`ipInfoKey`** should pass as a string value. It is used for location details and paid api key for VPN restriction. For more details visit **`https://ipinfo.io/`**._
|
|
323
|
+
- _**`googleMapKey`** should pass as a string value. It is used for location details and geo fence. For more details visit **`https://developers.google.com/maps`**._
|
|
324
|
+
- _**`googleCaptchaKey`** should pass as a string value. It is used for spam/bot attack. For more details visit **`https://developers.google.com/recaptcha`**._
|
|
325
|
+
- _**`passphrase`** should pass as a string value. It is used for encrypting the string with this special key and same key need to be used at backend also for decrypting the data._
|
|
326
|
+
- _**`userName`** should pass as a string value. It is used to create an application for onboard sonic kyc._
|
|
327
|
+
- _**`userId`** should pass as a string value. It is used to create an application for onboard sonic kyc and to compare your identity with the document._
|
|
328
|
+
- _**`email`** should pass as a string value. It is used to create an application for onboard sonic kyc._
|
|
329
|
+
- _**`phone`** should pass as a string value. It is used to create an application for onboard sonic kyc._
|
|
330
|
+
- _**`applicationNo`** should pass as a string value. It is used to create an application for onboard sonic kyc._
|
|
331
|
+
- _**`sendLogsEmail`** is used to pass a boolean value. It is used to send logs to client email address._
|
|
332
|
+
- _**`blinkThreshold`** is used to pass a numerical value. It is used to check the user blinking (range 0-1 and default 0.35). Above the threshold consider to be blinking or eye closed._
|
|
333
|
+
- _**`disableUploadDocs`** is used to pass a boolean value. It is used to disable the upload option the document process._
|
|
334
|
+
- _**`eyeOpenThreshold`** is used to pass a numerical value. It is used to check the user eyes are open (range 0-1 and default 0.2). Below the threshold consider to be eyes are open._
|
|
335
|
+
- _**`objectPersonThreshold`** is used to pass a numerical value. It is used to check the image person as object found with required score as threshold (range 0-1 and default 0.925)._
|
|
336
|
+
- _**`objectPhoneThreshold`** is used to pass a numerical value. It is used to check the image phone/laptop as object found with required score as threshold (range 0-1 and default 0.5)._
|
|
337
|
+
- _**`grayscalePercentageThreshold`** is used to pass a numerical value for percentage. It is used to check the image color as black&white found with required percentage as threshold (range 0-100 and default 80)._
|
|
338
|
+
- _**`onMessage`** is a callback function. It is getting called when the API gives a message or at any configuration error. Return data is an object with its API endpoint and result._
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEVELOPER info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
|
342
|
+
|
|
343
|
+
<!-- use node 18 and install packages using yarn and do yarn dev -->
|
|
344
|
+
|
|
345
|
+
<!-- env -->
|
|
346
|
+
|
|
347
|
+
<!--
|
|
348
|
+
VITE_APP_DOCUMENT_DETECT_PATH=""
|
|
349
|
+
VITE_APP_MASK_DETECT_PATH=""
|
|
350
|
+
VITE_APP_COCO_SSD_OBJECT_URL="https://storage.googleapis.com/tfjs-models/savedmodel/ssdlite_mobilenet_v2/model.json"
|
|
351
|
+
VITE_APP_TASK_VISION_WASM_PATH="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
|
|
352
|
+
VITE_APP_TASK_VISION_FACE_URL="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task"
|
|
353
|
+
VITE_APP_TASK_VISION_HAND_URL="https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task"
|
|
354
|
+
VITE_APP_DEFAULT_PASS_PHRASE=""
|
|
355
|
+
VITE_APP_THIRD_PARTY_GET_IP_URL="https://ipv4.icanhazip.com"
|
|
356
|
+
-->
|
|
357
|
+
|
|
358
|
+
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GrayScale info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
|
359
|
+
|
|
360
|
+
<!-- GrayScale Suggestions
|
|
361
|
+
|
|
362
|
+
1. RGB Difference Threshold for Grayscale Detection:
|
|
363
|
+
|
|
364
|
+
Low Threshold: A low threshold (e.g., 5-10) is good if you want to consider any slight variation in color as an indication that the image is colored. This is more sensitive to minor color differences.
|
|
365
|
+
|
|
366
|
+
Moderate Threshold: A threshold of around 10-20 is a more balanced approach. It allows for small variations due to noise or minor imperfections in grayscale images but still classifies them as black and white.
|
|
367
|
+
|
|
368
|
+
High Threshold: A higher threshold (e.g., 20-50) will classify images as grayscale even if there are noticeable color variations, which might be acceptable for images that are predominantly black and white but have some color noise or artifacts.
|
|
369
|
+
|
|
370
|
+
2. Percentage of Grayscale Pixels:
|
|
371
|
+
|
|
372
|
+
After detecting grayscale pixels, you need to determine the percentage of grayscale pixels required to classify the image as black and white.
|
|
373
|
+
|
|
374
|
+
80-90% Grayscale Pixels: This threshold means that if 80-90% of the pixels are grayscale, the image will be classified as black and white. This works well for documents and images that are mostly grayscale but may have some minor color elements (e.g., stamps, logos).
|
|
375
|
+
|
|
376
|
+
90-100% Grayscale Pixels: This is a stricter threshold, ensuring that the image is classified as black and white only if nearly all pixels are grayscale. -->
|
|
377
|
+
|
|
378
|
+
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Selfie info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
|
379
|
+
|
|
380
|
+
<!--
|
|
381
|
+
1.blinkThreshold: number
|
|
382
|
+
|
|
383
|
+
Description : The blinkThreshold is used to determine whether the user's eye is considered blinked. It represents the sensitivity to eye closure during a blink.
|
|
384
|
+
Range : 0-1 (default: 0.35)
|
|
385
|
+
Functionality :
|
|
386
|
+
* If either of the user's eyes exceeds the specified threshold (i.e., the eye closure ratio is greater than the blinkThreshold), the eye is detected as "blinked."
|
|
387
|
+
* This helps identify blinks during facial detection or tracking processes.
|
|
388
|
+
|
|
389
|
+
2.eyeOpenThreshold: number
|
|
390
|
+
|
|
391
|
+
Description : The eyeOpenThreshold is used to detect whether the user's eyes are open or not. It determines the sensitivity to eye openness by checking the openness ratio.
|
|
392
|
+
Range : 0-1 (default: 0.25)
|
|
393
|
+
Functionality :
|
|
394
|
+
* If both eyes fall below the defined threshold, the system interprets that the eyes are open.
|
|
395
|
+
* This value helps differentiate between an open eye and a partially closed
|
|
396
|
+
|
|
397
|
+
Both thresholds work together to archive ekyc selfie process.
|
|
398
|
+
-->
|
|
399
|
+
|