@ekyc_qoobiss/qbs-ect-cmp 1.2.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.
Files changed (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/dist/assets/canvas-masks/face_green.svg +8 -0
  4. package/dist/assets/canvas-masks/face_white.svg +8 -0
  5. package/dist/assets/canvas-masks/id_green.svg +6 -0
  6. package/dist/assets/canvas-masks/id_white.svg +6 -0
  7. package/dist/assets/complete.svg +4 -0
  8. package/dist/assets/landing/device.svg +14 -0
  9. package/dist/assets/landing/id.svg +3 -0
  10. package/dist/assets/landing/info.svg +3 -0
  11. package/dist/assets/landing/validation.svg +16 -0
  12. package/dist/assets/ml5-preload.png +0 -0
  13. package/dist/cjs/agreement-check_17.cjs.entry.js +9549 -0
  14. package/dist/cjs/index-79f82518.js +1568 -0
  15. package/dist/cjs/index.cjs.js +2 -0
  16. package/dist/cjs/loader-dots.cjs.entry.js +19 -0
  17. package/dist/cjs/loader.cjs.js +22 -0
  18. package/dist/cjs/qbs-ect-cmp.cjs.js +23 -0
  19. package/dist/collection/assets/canvas-masks/face_green.svg +8 -0
  20. package/dist/collection/assets/canvas-masks/face_white.svg +8 -0
  21. package/dist/collection/assets/canvas-masks/id_green.svg +6 -0
  22. package/dist/collection/assets/canvas-masks/id_white.svg +6 -0
  23. package/dist/collection/assets/complete.svg +4 -0
  24. package/dist/collection/assets/landing/device.svg +14 -0
  25. package/dist/collection/assets/landing/id.svg +3 -0
  26. package/dist/collection/assets/landing/info.svg +3 -0
  27. package/dist/collection/assets/landing/validation.svg +16 -0
  28. package/dist/collection/collection-manifest.json +29 -0
  29. package/dist/collection/components/common/agreement-check/agreement-check.css +0 -0
  30. package/dist/collection/components/common/agreement-check/agreement-check.js +95 -0
  31. package/dist/collection/components/common/capture-error/capture-error.css +0 -0
  32. package/dist/collection/components/common/capture-error/capture-error.js +73 -0
  33. package/dist/collection/components/common/how-to-info/how-to-info.css +0 -0
  34. package/dist/collection/components/common/how-to-info/how-to-info.js +98 -0
  35. package/dist/collection/components/common/id-back-capture/id-back-capture.css +35 -0
  36. package/dist/collection/components/common/id-back-capture/id-back-capture.js +212 -0
  37. package/dist/collection/components/common/id-capture/id-capture.css +35 -0
  38. package/dist/collection/components/common/id-capture/id-capture.js +213 -0
  39. package/dist/collection/components/common/selfie-capture/selfie-capture.css +7 -0
  40. package/dist/collection/components/common/selfie-capture/selfie-capture.js +222 -0
  41. package/dist/collection/components/controls/camera/camera.css +47 -0
  42. package/dist/collection/components/controls/camera/camera.js +309 -0
  43. package/dist/collection/components/controls/loader-dots/loader-dots.css +61 -0
  44. package/dist/collection/components/controls/loader-dots/loader-dots.js +18 -0
  45. package/dist/collection/components/flow/agreement-info/agreement-info.css +0 -0
  46. package/dist/collection/components/flow/agreement-info/agreement-info.js +73 -0
  47. package/dist/collection/components/flow/end-redirect/end-redirect.css +128 -0
  48. package/dist/collection/components/flow/end-redirect/end-redirect.js +26 -0
  49. package/dist/collection/components/flow/error-end/error-end.css +0 -0
  50. package/dist/collection/components/flow/error-end/error-end.js +64 -0
  51. package/dist/collection/components/flow/id-double-side/id-double-side.css +0 -0
  52. package/dist/collection/components/flow/id-double-side/id-double-side.js +284 -0
  53. package/dist/collection/components/flow/id-single-side/id-single-side.css +0 -0
  54. package/dist/collection/components/flow/id-single-side/id-single-side.js +225 -0
  55. package/dist/collection/components/flow/landing-validation/landing-validation.css +0 -0
  56. package/dist/collection/components/flow/landing-validation/landing-validation.js +88 -0
  57. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.css +10 -0
  58. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.js +128 -0
  59. package/dist/collection/components/flow/sms-code-validation/sms-code-validation.css +0 -0
  60. package/dist/collection/components/flow/sms-code-validation/sms-code-validation.js +115 -0
  61. package/dist/collection/components/flow/user-liveness/user-liveness.css +0 -0
  62. package/dist/collection/components/flow/user-liveness/user-liveness.js +214 -0
  63. package/dist/collection/components/identification-component/identification-component.css +1043 -0
  64. package/dist/collection/components/identification-component/identification-component.js +355 -0
  65. package/dist/collection/global.js +0 -0
  66. package/dist/collection/helpers/ApiCall.js +113 -0
  67. package/dist/collection/helpers/Cameras.js +98 -0
  68. package/dist/collection/helpers/Events.js +39 -0
  69. package/dist/collection/helpers/ML5.js +35 -0
  70. package/dist/collection/helpers/Stream.js +223 -0
  71. package/dist/collection/helpers/canvas.js +10 -0
  72. package/dist/collection/helpers/index.js +54 -0
  73. package/dist/collection/helpers/security.js +25 -0
  74. package/dist/collection/helpers/store.js +39 -0
  75. package/dist/collection/helpers/textValues.js +128 -0
  76. package/dist/collection/index.js +1 -0
  77. package/dist/collection/libs/FaceML5Detector/FaceML5Detector.js +227 -0
  78. package/dist/collection/libs/FaceML5Detector/FacePose.js +85 -0
  79. package/dist/collection/libs/IDML5Detector/IDML5Detector.js +101 -0
  80. package/dist/collection/libs/IDML5Detector/IDPose.js +8 -0
  81. package/dist/collection/models/FlowStatus.js +12 -0
  82. package/dist/collection/models/IAddRequest.js +1 -0
  83. package/dist/collection/models/IAgreement.js +1 -0
  84. package/dist/collection/models/ICamera.js +1 -0
  85. package/dist/collection/models/IConstraints.js +1 -0
  86. package/dist/collection/models/IDevice.js +1 -0
  87. package/dist/collection/models/IGeneration.js +1 -0
  88. package/dist/collection/models/ILinkSend.js +1 -0
  89. package/dist/collection/models/ILogResult.js +1 -0
  90. package/dist/collection/models/IOrderStatus.js +1 -0
  91. package/dist/collection/models/IOtpCheck.js +1 -0
  92. package/dist/collection/models/IOtpSend.js +1 -0
  93. package/dist/collection/models/IUploadFile.js +1 -0
  94. package/dist/collection/models/OrderStatuses.js +7 -0
  95. package/dist/collection/utils/utils.js +10 -0
  96. package/dist/esm/agreement-check_17.entry.js +9529 -0
  97. package/dist/esm/index-9d69e511.js +1538 -0
  98. package/dist/esm/index.js +1 -0
  99. package/dist/esm/loader-dots.entry.js +15 -0
  100. package/dist/esm/loader.js +18 -0
  101. package/dist/esm/polyfills/core-js.js +11 -0
  102. package/dist/esm/polyfills/css-shim.js +1 -0
  103. package/dist/esm/polyfills/dom.js +79 -0
  104. package/dist/esm/polyfills/es5-html-element.js +1 -0
  105. package/dist/esm/polyfills/index.js +34 -0
  106. package/dist/esm/polyfills/system.js +6 -0
  107. package/dist/esm/qbs-ect-cmp.js +18 -0
  108. package/dist/index.cjs.js +1 -0
  109. package/dist/index.js +1 -0
  110. package/dist/loader/cdn.js +3 -0
  111. package/dist/loader/index.cjs.js +3 -0
  112. package/dist/loader/index.d.ts +21 -0
  113. package/dist/loader/index.es2017.js +3 -0
  114. package/dist/loader/index.js +4 -0
  115. package/dist/loader/package.json +11 -0
  116. package/dist/qbs-ect-cmp/index.esm.js +0 -0
  117. package/dist/qbs-ect-cmp/p-06e42b28.js +2 -0
  118. package/dist/qbs-ect-cmp/p-4c8e922b.entry.js +1 -0
  119. package/dist/qbs-ect-cmp/p-b65cc797.entry.js +1373 -0
  120. package/dist/qbs-ect-cmp/qbs-ect-cmp.css +1 -0
  121. package/dist/qbs-ect-cmp/qbs-ect-cmp.esm.js +1 -0
  122. package/dist/types/components/common/agreement-check/agreement-check.d.ts +12 -0
  123. package/dist/types/components/common/capture-error/capture-error.d.ts +10 -0
  124. package/dist/types/components/common/how-to-info/how-to-info.d.ts +12 -0
  125. package/dist/types/components/common/id-back-capture/id-back-capture.d.ts +28 -0
  126. package/dist/types/components/common/id-capture/id-capture.d.ts +28 -0
  127. package/dist/types/components/common/selfie-capture/selfie-capture.d.ts +30 -0
  128. package/dist/types/components/controls/camera/camera.d.ts +33 -0
  129. package/dist/types/components/controls/loader-dots/loader-dots.d.ts +3 -0
  130. package/dist/types/components/flow/agreement-info/agreement-info.d.ts +13 -0
  131. package/dist/types/components/flow/end-redirect/end-redirect.d.ts +4 -0
  132. package/dist/types/components/flow/error-end/error-end.d.ts +6 -0
  133. package/dist/types/components/flow/id-double-side/id-double-side.d.ts +27 -0
  134. package/dist/types/components/flow/id-single-side/id-single-side.d.ts +23 -0
  135. package/dist/types/components/flow/landing-validation/landing-validation.d.ts +10 -0
  136. package/dist/types/components/flow/mobile-redirect/mobile-redirect.d.ts +22 -0
  137. package/dist/types/components/flow/sms-code-validation/sms-code-validation.d.ts +16 -0
  138. package/dist/types/components/flow/user-liveness/user-liveness.d.ts +22 -0
  139. package/dist/types/components/identification-component/identification-component.d.ts +24 -0
  140. package/dist/types/components.d.ts +370 -0
  141. package/dist/types/global.d.ts +0 -0
  142. package/dist/types/helpers/ApiCall.d.ts +19 -0
  143. package/dist/types/helpers/Cameras.d.ts +8 -0
  144. package/dist/types/helpers/Events.d.ts +8 -0
  145. package/dist/types/helpers/ML5.d.ts +10 -0
  146. package/dist/types/helpers/Stream.d.ts +70 -0
  147. package/dist/types/helpers/canvas.d.ts +2 -0
  148. package/dist/types/helpers/index.d.ts +4 -0
  149. package/dist/types/helpers/security.d.ts +4 -0
  150. package/dist/types/helpers/store.d.ts +16 -0
  151. package/dist/types/helpers/textValues.d.ts +107 -0
  152. package/dist/types/index.d.ts +1 -0
  153. package/dist/types/libs/FaceML5Detector/FaceML5Detector.d.ts +40 -0
  154. package/dist/types/libs/FaceML5Detector/FacePose.d.ts +36 -0
  155. package/dist/types/libs/IDML5Detector/IDML5Detector.d.ts +22 -0
  156. package/dist/types/libs/IDML5Detector/IDPose.d.ts +7 -0
  157. package/dist/types/models/FlowStatus.d.ts +11 -0
  158. package/dist/types/models/IAddRequest.d.ts +6 -0
  159. package/dist/types/models/IAgreement.d.ts +3 -0
  160. package/dist/types/models/ICamera.d.ts +10 -0
  161. package/dist/types/models/IConstraints.d.ts +21 -0
  162. package/dist/types/models/IDevice.d.ts +11 -0
  163. package/dist/types/models/IGeneration.d.ts +3 -0
  164. package/dist/types/models/ILinkSend.d.ts +3 -0
  165. package/dist/types/models/ILogResult.d.ts +3 -0
  166. package/dist/types/models/IOrderStatus.d.ts +4 -0
  167. package/dist/types/models/IOtpCheck.d.ts +3 -0
  168. package/dist/types/models/IOtpSend.d.ts +3 -0
  169. package/dist/types/models/IUploadFile.d.ts +4 -0
  170. package/dist/types/models/OrderStatuses.d.ts +6 -0
  171. package/dist/types/stencil-public-runtime.d.ts +1637 -0
  172. package/dist/types/utils/utils.d.ts +2 -0
  173. package/package.json +52 -0
@@ -0,0 +1,355 @@
1
+ import { h } from '@stencil/core';
2
+ import { initDevice } from '../../helpers';
3
+ import { SessionKeys } from '../../helpers/textValues';
4
+ import { ApiCall } from '../../helpers/ApiCall';
5
+ import store from '../../helpers/store';
6
+ import { ML5 } from '../../helpers/ML5';
7
+ import { FlowStatus } from '../../models/FlowStatus';
8
+ import Events from '../../helpers/Events';
9
+ import * as uuid from 'uuid';
10
+ export class IdentificationComponent {
11
+ async onTokenChange(newValue, _oldValue) {
12
+ if (newValue == '') {
13
+ newValue = store.token;
14
+ return;
15
+ }
16
+ if (store.token !== newValue) {
17
+ store.token = newValue;
18
+ await this.initializeRequest();
19
+ }
20
+ }
21
+ async onOrderIdChange(newValue, _oldValue) {
22
+ if (store.requestId !== newValue) {
23
+ store.requestId = newValue;
24
+ store.initialised = false;
25
+ sessionStorage.clear();
26
+ if (store.flowStatus != FlowStatus.LANDING) {
27
+ store.flowStatus = FlowStatus.LANDING;
28
+ }
29
+ await this.initializeRequest();
30
+ }
31
+ }
32
+ onApiUrlChange(newValue, _oldValue) {
33
+ if (store.apiBaseUrl != '') {
34
+ newValue = store.apiBaseUrl;
35
+ return;
36
+ }
37
+ if (store.apiBaseUrl !== newValue) {
38
+ store.apiBaseUrl = newValue;
39
+ }
40
+ }
41
+ onEnvChange(newValue, _oldValue) {
42
+ if (store.environment != '') {
43
+ newValue = store.environment;
44
+ return;
45
+ }
46
+ if (store.environment !== newValue) {
47
+ store.environment = newValue;
48
+ }
49
+ }
50
+ async onRedirectIdChange(newValue, _oldValue) {
51
+ if (store.redirectId != '') {
52
+ newValue = store.redirectId;
53
+ return;
54
+ }
55
+ if (store.redirectId !== newValue) {
56
+ store.redirectId = newValue;
57
+ }
58
+ await this.initializeRequest();
59
+ }
60
+ agreementAcceptanceEmitted(data) {
61
+ try {
62
+ this.apiCall.GenerateAgreement(data.detail.agreementType);
63
+ }
64
+ catch (e) {
65
+ this.apiErrorEmitter(e);
66
+ }
67
+ }
68
+ async apiErrorEmitter(data) {
69
+ var _a, _b;
70
+ let apiLogData = { message: '', stack: '' };
71
+ if (data.detail) {
72
+ this.errorTitle = (_a = data.detail.message) !== null && _a !== void 0 ? _a : '';
73
+ this.errorMessage = (_b = data.detail.stack) !== null && _b !== void 0 ? _b : '';
74
+ apiLogData.message = data.detail.message;
75
+ apiLogData.stack = data.detail.stack;
76
+ }
77
+ else if (data.message) {
78
+ this.errorTitle = data.message;
79
+ apiLogData.message = data.message;
80
+ }
81
+ else {
82
+ this.errorTitle = data;
83
+ }
84
+ await this.apiCall.AddLog(apiLogData);
85
+ Events.flowError(data);
86
+ store.flowStatus = FlowStatus.ERROREND;
87
+ }
88
+ constructor() {
89
+ this.token = undefined;
90
+ this.order_id = undefined;
91
+ this.api_url = undefined;
92
+ this.env = undefined;
93
+ this.redirect_id = undefined;
94
+ this.idSide = '';
95
+ this.errorMessage = undefined;
96
+ this.errorTitle = undefined;
97
+ ML5.getInstance();
98
+ this.device = initDevice();
99
+ }
100
+ async componentWillLoad() {
101
+ Events.init(window);
102
+ store.apiBaseUrl = this.api_url;
103
+ store.environment = this.env;
104
+ if (this.token) {
105
+ store.token = this.token;
106
+ }
107
+ else {
108
+ store.token = sessionStorage.getItem(SessionKeys.TokenKey);
109
+ }
110
+ if (this.redirect_id) {
111
+ store.redirectId = this.redirect_id;
112
+ }
113
+ var flowSt = sessionStorage.getItem(SessionKeys.FlowStatusKey);
114
+ if (flowSt) {
115
+ store.flowStatus = FlowStatus[flowSt];
116
+ }
117
+ if (!store.flowStatus) {
118
+ store.flowStatus = FlowStatus.LANDING;
119
+ }
120
+ var ini = sessionStorage.getItem(SessionKeys.InitialisedKey);
121
+ if (ini && ini.toLowerCase() == 'true') {
122
+ store.initialised = true;
123
+ }
124
+ var hasIdBk = sessionStorage.getItem(SessionKeys.HasIdBackKey);
125
+ if (hasIdBk && hasIdBk.toLowerCase() == 'true') {
126
+ store.hasIdBack = true;
127
+ }
128
+ var agrVal = sessionStorage.getItem(SessionKeys.AgreementValidationKey);
129
+ if (agrVal && agrVal.toLowerCase() == 'true') {
130
+ store.agreementsValidation = true;
131
+ }
132
+ var phoneVal = sessionStorage.getItem(SessionKeys.PhoneValidationKey);
133
+ if (phoneVal && phoneVal.toLowerCase() == 'true') {
134
+ store.phoneValidation = true;
135
+ }
136
+ const savedRequest = sessionStorage.getItem(SessionKeys.RequestIdKey);
137
+ if (this.order_id) {
138
+ if (savedRequest && savedRequest != this.order_id) {
139
+ sessionStorage.clear();
140
+ store.flowStatus = FlowStatus.LANDING;
141
+ store.initialised = false;
142
+ }
143
+ else {
144
+ store.requestId = this.order_id;
145
+ }
146
+ }
147
+ this.apiCall = new ApiCall();
148
+ await this.initializeRequest();
149
+ }
150
+ componentWillRender() {
151
+ if (this.idSide == '') {
152
+ this.idSide = store.hasIdBack ? 'front' : '';
153
+ }
154
+ }
155
+ async initializeRequest() {
156
+ if (store.initialised) {
157
+ return;
158
+ }
159
+ try {
160
+ if (!this.device.isMobile && store.redirectId == '') {
161
+ store.redirectId = uuid.v4();
162
+ this.redirect_id = store.redirectId;
163
+ }
164
+ if (store.token != '' && (store.requestId != '' || store.redirectId != '')) {
165
+ store.initialised = await this.apiCall.AddIdentificationRequest(this.device);
166
+ if (!this.order_id || this.order_id == '') {
167
+ this.order_id = store.requestId;
168
+ }
169
+ }
170
+ }
171
+ catch (e) {
172
+ this.apiErrorEmitter(e);
173
+ }
174
+ }
175
+ render() {
176
+ let currentBlock = h("div", null);
177
+ if (this.device.isMobile) {
178
+ if (store.flowStatus == FlowStatus.LANDING) {
179
+ currentBlock = h("landing-validation", { device: this.device });
180
+ }
181
+ }
182
+ else {
183
+ currentBlock = h("mobile-redirect", null);
184
+ }
185
+ if (store.flowStatus == FlowStatus.AGREEMENT) {
186
+ currentBlock = h("agreement-info", null);
187
+ }
188
+ if (store.flowStatus == FlowStatus.PHONE) {
189
+ currentBlock = h("sms-code-validation", null);
190
+ }
191
+ if (store.flowStatus == FlowStatus.CODE) {
192
+ currentBlock = h("sms-code-validation", null);
193
+ }
194
+ if (store.flowStatus == FlowStatus.CODEERROR) {
195
+ currentBlock = h("sms-code-validation", null);
196
+ }
197
+ if (store.flowStatus == FlowStatus.ID && !store.hasIdBack) {
198
+ currentBlock = h("id-single-side", { id: "idFront", device: this.device });
199
+ }
200
+ if (store.flowStatus == FlowStatus.ID && store.hasIdBack) {
201
+ currentBlock = h("id-double-side", { id: "idFront", device: this.device });
202
+ }
203
+ if (store.flowStatus == FlowStatus.LIVENESS) {
204
+ currentBlock = h("user-liveness", { device: this.device, id: "camera" });
205
+ }
206
+ if (store.flowStatus == FlowStatus.COMPLETE) {
207
+ currentBlock = h("end-redirect", null);
208
+ }
209
+ if (store.flowStatus == FlowStatus.ERROREND) {
210
+ currentBlock = h("error-end", { errorTitle: this.errorTitle, message: this.errorMessage });
211
+ }
212
+ return h("div", null, currentBlock);
213
+ }
214
+ static get is() { return "identification-component"; }
215
+ static get encapsulation() { return "shadow"; }
216
+ static get originalStyleUrls() {
217
+ return {
218
+ "$": ["identification-component.css"]
219
+ };
220
+ }
221
+ static get styleUrls() {
222
+ return {
223
+ "$": ["identification-component.css"]
224
+ };
225
+ }
226
+ static get properties() {
227
+ return {
228
+ "token": {
229
+ "type": "string",
230
+ "mutable": true,
231
+ "complexType": {
232
+ "original": "string",
233
+ "resolved": "string",
234
+ "references": {}
235
+ },
236
+ "required": false,
237
+ "optional": false,
238
+ "docs": {
239
+ "tags": [],
240
+ "text": ""
241
+ },
242
+ "attribute": "token",
243
+ "reflect": true
244
+ },
245
+ "order_id": {
246
+ "type": "string",
247
+ "mutable": true,
248
+ "complexType": {
249
+ "original": "string",
250
+ "resolved": "string",
251
+ "references": {}
252
+ },
253
+ "required": false,
254
+ "optional": false,
255
+ "docs": {
256
+ "tags": [],
257
+ "text": ""
258
+ },
259
+ "attribute": "order_id",
260
+ "reflect": true
261
+ },
262
+ "api_url": {
263
+ "type": "string",
264
+ "mutable": true,
265
+ "complexType": {
266
+ "original": "string",
267
+ "resolved": "string",
268
+ "references": {}
269
+ },
270
+ "required": false,
271
+ "optional": false,
272
+ "docs": {
273
+ "tags": [],
274
+ "text": ""
275
+ },
276
+ "attribute": "api_url",
277
+ "reflect": true
278
+ },
279
+ "env": {
280
+ "type": "string",
281
+ "mutable": true,
282
+ "complexType": {
283
+ "original": "string",
284
+ "resolved": "string",
285
+ "references": {}
286
+ },
287
+ "required": false,
288
+ "optional": false,
289
+ "docs": {
290
+ "tags": [],
291
+ "text": ""
292
+ },
293
+ "attribute": "env",
294
+ "reflect": true
295
+ },
296
+ "redirect_id": {
297
+ "type": "string",
298
+ "mutable": true,
299
+ "complexType": {
300
+ "original": "string",
301
+ "resolved": "string",
302
+ "references": {}
303
+ },
304
+ "required": false,
305
+ "optional": false,
306
+ "docs": {
307
+ "tags": [],
308
+ "text": ""
309
+ },
310
+ "attribute": "redirect_id",
311
+ "reflect": true
312
+ }
313
+ };
314
+ }
315
+ static get states() {
316
+ return {
317
+ "idSide": {},
318
+ "errorMessage": {},
319
+ "errorTitle": {}
320
+ };
321
+ }
322
+ static get watchers() {
323
+ return [{
324
+ "propName": "token",
325
+ "methodName": "onTokenChange"
326
+ }, {
327
+ "propName": "order_id",
328
+ "methodName": "onOrderIdChange"
329
+ }, {
330
+ "propName": "api_url",
331
+ "methodName": "onApiUrlChange"
332
+ }, {
333
+ "propName": "env",
334
+ "methodName": "onEnvChange"
335
+ }, {
336
+ "propName": "redirect_id",
337
+ "methodName": "onRedirectIdChange"
338
+ }];
339
+ }
340
+ static get listeners() {
341
+ return [{
342
+ "name": "agreementAcceptance",
343
+ "method": "agreementAcceptanceEmitted",
344
+ "target": undefined,
345
+ "capture": false,
346
+ "passive": false
347
+ }, {
348
+ "name": "apiError",
349
+ "method": "apiErrorEmitter",
350
+ "target": undefined,
351
+ "capture": false,
352
+ "passive": false
353
+ }];
354
+ }
355
+ }
File without changes
@@ -0,0 +1,113 @@
1
+ import { OrderStatuses } from '../models/OrderStatuses';
2
+ import store from './store';
3
+ import { ApiUrls } from './textValues';
4
+ import { FlowStatus } from '../models/FlowStatus';
5
+ export class ApiCall {
6
+ constructor() {
7
+ this.toBase64 = (file) => new Promise((resolve, reject) => {
8
+ const reader = new FileReader();
9
+ reader.readAsDataURL(file);
10
+ reader.onload = () => resolve(reader.result);
11
+ reader.onerror = error => reject(error);
12
+ });
13
+ this.urls = new ApiUrls();
14
+ }
15
+ async http(request) {
16
+ const response = await fetch(request);
17
+ if (!response.ok) {
18
+ throw new Error(response.statusText);
19
+ }
20
+ try {
21
+ // may error if there is no body
22
+ return await response.json();
23
+ }
24
+ catch (ex) {
25
+ throw new Error('No json found in response ' + ex);
26
+ }
27
+ }
28
+ async post(url, data) {
29
+ return await this.http(new Request(store.apiBaseUrl + url, {
30
+ method: 'POST',
31
+ body: data,
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ 'Authorization': 'IDKYC-TOKEN ' + store.token,
35
+ },
36
+ }));
37
+ }
38
+ async get(url) {
39
+ return await this.http(new Request(store.apiBaseUrl + url, {
40
+ method: 'GET',
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ 'Authorization': 'IDKYC-TOKEN ' + store.token,
44
+ },
45
+ }));
46
+ }
47
+ async SendOTPCode(requestId, phoneNumber) {
48
+ let data = { requestId: requestId, phone: phoneNumber };
49
+ let jsonResp = await this.post(this.urls.OtpSend, JSON.stringify(data));
50
+ return jsonResp.sent;
51
+ }
52
+ async CheckOTPCode(requestId, otpCode) {
53
+ let data = { requestId: requestId, otp: otpCode };
54
+ let jsonResp = await this.post(this.urls.OtpCheck, JSON.stringify(data));
55
+ return jsonResp.valid;
56
+ }
57
+ async AddIdentificationRequest(deviceInfo) {
58
+ let data = {
59
+ requestId: store.requestId,
60
+ clientDeviceInfo: JSON.stringify(deviceInfo),
61
+ redirectId: store.redirectId,
62
+ };
63
+ let jsonResp = await this.post(this.urls.IdentityInsert, JSON.stringify(data));
64
+ if (store.requestId == '') {
65
+ store.requestId = jsonResp.requestId;
66
+ }
67
+ store.hasIdBack = jsonResp.hasIdBack;
68
+ store.agreementsValidation = jsonResp.agreementsValidation;
69
+ store.phoneValidation = jsonResp.phoneValidation;
70
+ return true;
71
+ }
72
+ async UploadFileForRequestB64(requestId, type, file) {
73
+ let data = {
74
+ requestId: requestId,
75
+ type: type,
76
+ data: await this.toBase64(file),
77
+ };
78
+ let respJson = await this.post(this.urls.UploadCapture, JSON.stringify(data));
79
+ if (!store.hasIdBack && type == 'IdFront') {
80
+ return respJson.isValid;
81
+ }
82
+ if (store.hasIdBack && type == 'IdBack') {
83
+ return respJson.isValid;
84
+ }
85
+ return true;
86
+ }
87
+ async GetAgreement(agreementType) {
88
+ let resp = await this.get(this.urls.GetAgreement + '?type=' + agreementType + '&requestId=' + store.requestId);
89
+ return resp.htmlText;
90
+ }
91
+ async GenerateAgreement(agreementType) {
92
+ let data = { requestId: store.requestId, documentType: agreementType };
93
+ let resp = await this.post(this.urls.GenerateAgreement, JSON.stringify(data));
94
+ return resp.generation;
95
+ }
96
+ async GetStatus(requestId) {
97
+ let resp = await this.get(this.urls.GetStatus + '?orderId=' + requestId);
98
+ return OrderStatuses[resp.status];
99
+ }
100
+ async SendLink(link, phoneNumber) {
101
+ let data = { link: link, phoneNumber: phoneNumber };
102
+ let resp = await this.post(this.urls.SendLink, JSON.stringify(data));
103
+ return resp.sent;
104
+ }
105
+ async AddLog(error) {
106
+ try {
107
+ let data = { requestId: store.requestId, action: FlowStatus[store.flowStatus], message: JSON.stringify(error !== null && error !== void 0 ? error : 'no error data') };
108
+ let result = await this.post(this.urls.AddLog, JSON.stringify(data));
109
+ return result.saved;
110
+ }
111
+ catch (_a) { }
112
+ }
113
+ }
@@ -0,0 +1,98 @@
1
+ export class Cameras {
2
+ async GetCameras(deviceInfo) {
3
+ var allDevices = [];
4
+ const devices = await navigator.mediaDevices.enumerateDevices();
5
+ const videoDevices = devices.filter(device => device.kind === 'videoinput');
6
+ for (const device of videoDevices) {
7
+ const updatedConstraints = this.GetConstraints(device.deviceId, deviceInfo);
8
+ const stream = await navigator.mediaDevices.getUserMedia(updatedConstraints);
9
+ stream.getVideoTracks().forEach(track => {
10
+ if (deviceInfo.isFirefox) {
11
+ const settings = track.getSettings();
12
+ let facingMode = settings.facingMode && settings.facingMode.length > 0 ? settings.facingMode[0] : '';
13
+ facingMode = facingMode === 'e' ? 'environment' : facingMode;
14
+ allDevices.push({
15
+ deviceId: device.deviceId,
16
+ name: device.label,
17
+ height: settings.height,
18
+ width: settings.width,
19
+ frameRate: Number(settings.frameRate.max),
20
+ torch: false,
21
+ recommended: false,
22
+ facingMode: facingMode,
23
+ });
24
+ }
25
+ else {
26
+ const capabilities = track.getCapabilities();
27
+ let facingMode = capabilities.facingMode && capabilities.facingMode.length > 0 ? capabilities.facingMode[0] : '';
28
+ facingMode = facingMode === 'e' ? 'environment' : facingMode;
29
+ allDevices.push({
30
+ deviceId: device.deviceId,
31
+ name: device.label,
32
+ height: capabilities.height.max,
33
+ width: capabilities.width.max,
34
+ frameRate: Number(capabilities.frameRate.max),
35
+ torch: capabilities.torch,
36
+ recommended: false,
37
+ facingMode: facingMode,
38
+ });
39
+ }
40
+ });
41
+ stream.getTracks().forEach(track => {
42
+ track.stop();
43
+ });
44
+ }
45
+ if (allDevices.length > 0) {
46
+ allDevices = allDevices.sort((a, b) => b.frameRate - a.frameRate);
47
+ var firstOption = allDevices.find(i => i.name.indexOf('0,') != -1 && i.facingMode === 'environment');
48
+ if (firstOption) {
49
+ allDevices[allDevices.indexOf(firstOption)].recommended = true;
50
+ }
51
+ else {
52
+ var firstEnv = allDevices.find(i => i.facingMode === 'environment');
53
+ if (firstEnv) {
54
+ allDevices[allDevices.indexOf(firstEnv)].recommended = true;
55
+ }
56
+ }
57
+ }
58
+ return allDevices;
59
+ }
60
+ GetConstraints(selectedDeviceId, device, portrait = false) {
61
+ let constraints = {
62
+ audio: false,
63
+ video: {
64
+ frameRate: 30
65
+ }
66
+ };
67
+ if (selectedDeviceId) {
68
+ constraints.video.deviceId = {
69
+ exact: selectedDeviceId,
70
+ };
71
+ }
72
+ if (device.isWin) {
73
+ constraints.video.width = { ideal: 1280 };
74
+ }
75
+ else {
76
+ if (portrait) {
77
+ constraints.video.facingMode = 'user';
78
+ constraints.video.width = { ideal: 1280 };
79
+ constraints.video.height = { ideal: 720 };
80
+ }
81
+ else {
82
+ constraints.video.facingMode = 'environment';
83
+ constraints.video.width = { ideal: 1280 };
84
+ constraints.video.aspectRatio = 1;
85
+ }
86
+ }
87
+ return constraints;
88
+ }
89
+ GetRecommendedCamera(cameras) {
90
+ if (cameras && cameras.length > 0) {
91
+ var recommDevice = cameras.find(c => c.recommended);
92
+ if (recommDevice) {
93
+ return recommDevice;
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ }
@@ -0,0 +1,39 @@
1
+ export default class Events {
2
+ static init(element) {
3
+ this.cameraModule = element;
4
+ }
5
+ static flowStarted() {
6
+ this.cameraModule.dispatchEvent(new CustomEvent('ect-started', {
7
+ detail: {},
8
+ bubbles: true,
9
+ cancelable: true,
10
+ composed: true,
11
+ }));
12
+ }
13
+ static flowCompleted() {
14
+ sessionStorage.clear();
15
+ this.cameraModule.dispatchEvent(new CustomEvent('ect-completed', {
16
+ detail: {},
17
+ bubbles: true,
18
+ cancelable: true,
19
+ composed: true,
20
+ }));
21
+ }
22
+ static flowError(error) {
23
+ sessionStorage.clear();
24
+ this.cameraModule.dispatchEvent(new CustomEvent('ect-error', {
25
+ detail: { error },
26
+ bubbles: true,
27
+ cancelable: true,
28
+ composed: true,
29
+ }));
30
+ }
31
+ static tokenExpired() {
32
+ this.cameraModule.dispatchEvent(new CustomEvent('ect-session-expired', {
33
+ detail: {},
34
+ bubbles: true,
35
+ cancelable: true,
36
+ composed: true,
37
+ }));
38
+ }
39
+ }
@@ -0,0 +1,35 @@
1
+ import ml5 from 'ml5';
2
+ import store from './store';
3
+ // @ts-ignore
4
+ import preload from '../assets/ml5-preload.png';
5
+ export class ML5 {
6
+ static getInstance() {
7
+ if (!ML5.instance) {
8
+ ML5.instance = new ML5();
9
+ }
10
+ return ML5.instance;
11
+ }
12
+ constructor() {
13
+ this.init();
14
+ }
15
+ async init() {
16
+ return new Promise(async (resolve) => {
17
+ const modelPath = store.hasIdBack ? 'https://ekyc.blob.core.windows.net/$web/md/model.json' : 'https://ekyc.blob.core.windows.net/$web/model.json';
18
+ this.classifier = await ml5.imageClassifier(modelPath, this.loaded);
19
+ this.faceapi = await ml5.faceApi({ withLandmarks: true, withDescriptors: false }, this.loaded);
20
+ //warmup
21
+ const img = new Image();
22
+ img.src = preload;
23
+ this.classifier.classify(img, this.gotResults);
24
+ this.faceapi.detect(img, this.gotResults);
25
+ resolve();
26
+ });
27
+ }
28
+ loaded() {
29
+ console.log('ML5 LOADED!!!');
30
+ }
31
+ gotResults(error, results) {
32
+ console.log(error);
33
+ console.log(results);
34
+ }
35
+ }