@ekyc_qoobiss/qbs-ect-cmp 3.6.27 → 3.6.28
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/dist/cjs/agreement-check_19.cjs.entry.js +9498 -0
- package/dist/cjs/base-component-aa9e52bf.js +832 -0
- package/dist/cjs/index-41696e0e.js +1573 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader-dots.cjs.entry.js +19 -0
- package/dist/cjs/loader.cjs.js +22 -0
- package/dist/cjs/qbs-ect-cmp.cjs.js +23 -0
- package/dist/cjs/random-actions.cjs.entry.js +23 -0
- package/dist/collection/assets/canvas-masks/face_green.svg +8 -0
- package/dist/collection/assets/canvas-masks/face_white.svg +8 -0
- package/dist/collection/assets/canvas-masks/id_green.svg +6 -0
- package/dist/collection/assets/canvas-masks/id_white.svg +6 -0
- package/dist/collection/assets/complete.svg +4 -0
- package/dist/collection/assets/landing/device.svg +14 -0
- package/dist/collection/assets/landing/id.svg +3 -0
- package/dist/collection/assets/landing/info.svg +3 -0
- package/dist/collection/assets/landing/validation.svg +16 -0
- package/dist/collection/assets/loader.svg +29 -0
- package/dist/collection/collection-manifest.json +32 -0
- package/dist/collection/components/base-component.js +63 -0
- package/dist/collection/components/common/agreement-check/agreement-check.css +0 -0
- package/dist/collection/components/common/agreement-check/agreement-check.js +104 -0
- package/dist/collection/components/common/camera-error/camera-error.css +0 -0
- package/dist/{qbs-ect-cmp/camera-error.entry.js → collection/components/common/camera-error/camera-error.js} +52 -20
- package/dist/collection/components/common/capture-error/capture-error.css +0 -0
- package/dist/{qbs-ect-cmp/capture-error.entry.js → collection/components/common/capture-error/capture-error.js} +63 -16
- package/dist/collection/components/common/how-to-info/how-to-info.css +0 -0
- package/dist/collection/components/common/how-to-info/how-to-info.js +121 -0
- package/dist/collection/components/common/id-back-capture/id-back-capture.css +35 -0
- package/dist/{qbs-ect-cmp/id-back-capture.entry.js → collection/components/common/id-back-capture/id-back-capture.js} +94 -24
- package/dist/collection/components/common/id-capture/id-capture.css +35 -0
- package/dist/{qbs-ect-cmp/id-capture.entry.js → collection/components/common/id-capture/id-capture.js} +94 -24
- package/dist/collection/components/common/id-tilt/id-tilt.css +35 -0
- package/dist/{qbs-ect-cmp/id-tilt.entry.js → collection/components/common/id-tilt/id-tilt.js} +94 -24
- package/dist/collection/components/common/random-actions/random-actions.css +0 -0
- package/dist/collection/components/common/random-actions/random-actions.js +24 -0
- package/dist/collection/components/common/selfie-capture/selfie-capture.css +7 -0
- package/dist/{qbs-ect-cmp/selfie-capture.entry.js → collection/components/common/selfie-capture/selfie-capture.js} +95 -24
- package/dist/collection/components/common/selfie-tilt/selfie-tilt.css +7 -0
- package/dist/{qbs-ect-cmp/selfie-tilt.entry.js → collection/components/common/selfie-tilt/selfie-tilt.js} +95 -24
- package/dist/collection/components/controls/camera/camera.css +47 -0
- package/dist/collection/components/controls/camera/camera.js +289 -0
- package/dist/collection/components/controls/loader-dots/loader-dots.css +61 -0
- package/dist/collection/components/controls/loader-dots/loader-dots.js +18 -0
- package/dist/collection/components/flow/agreement-info/agreement-info.css +0 -0
- package/dist/{qbs-ect-cmp/agreement-info.entry.js → collection/components/flow/agreement-info/agreement-info.js} +57 -18
- package/dist/collection/components/flow/end-redirect/end-redirect.css +128 -0
- package/dist/collection/components/flow/end-redirect/end-redirect.js +47 -0
- package/dist/collection/components/flow/error-end/error-end.css +0 -0
- package/dist/collection/components/flow/error-end/error-end.js +61 -0
- package/dist/collection/components/flow/landing-validation/landing-validation.css +0 -0
- package/dist/collection/components/flow/landing-validation/landing-validation.js +122 -0
- package/dist/collection/components/flow/mobile-redirect/mobile-redirect.css +10 -0
- package/dist/collection/components/flow/mobile-redirect/mobile-redirect.js +143 -0
- package/dist/collection/components/flow/process-id/process-id.css +0 -0
- package/dist/{qbs-ect-cmp/process-id.entry.js → collection/components/flow/process-id/process-id.js} +100 -32
- package/dist/collection/components/flow/sms-code-validation/sms-code-validation.css +0 -0
- package/dist/{qbs-ect-cmp/sms-code-validation.entry.js → collection/components/flow/sms-code-validation/sms-code-validation.js} +63 -30
- package/dist/collection/components/flow/user-liveness/user-liveness.css +0 -0
- package/dist/{qbs-ect-cmp/user-liveness.entry.js → collection/components/flow/user-liveness/user-liveness.js} +91 -25
- package/dist/collection/components/identification-component/identification-component.css +991 -0
- package/dist/collection/components/identification-component/identification-component.js +408 -0
- package/dist/collection/global.js +0 -0
- package/dist/collection/helpers/ApiCall.js +223 -0
- package/dist/{qbs-ect-cmp/Cameras-dfbebc29.js → collection/helpers/Cameras.js} +6 -9
- package/dist/collection/helpers/DeviceDetection.js +85 -0
- package/dist/collection/helpers/Events.js +58 -0
- package/dist/collection/helpers/ML5.js +38 -0
- package/dist/collection/helpers/Stream.js +229 -0
- package/dist/collection/helpers/TranslationUtils.js +37 -0
- package/dist/collection/helpers/canvas.js +10 -0
- package/dist/collection/helpers/index.js +21 -0
- package/dist/collection/helpers/security.js +25 -0
- package/dist/collection/helpers/store.js +48 -0
- package/dist/collection/helpers/textValues.js +48 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/libs/FaceML5Detector/FaceML5Detector.js +182 -0
- package/dist/collection/libs/FaceML5Detector/FacePose.js +85 -0
- package/dist/collection/libs/IDML5Detector/IDML5Detector.js +99 -0
- package/dist/{qbs-ect-cmp/IDPose-181bcb25.js → collection/libs/IDML5Detector/IDPose.js} +2 -4
- package/dist/{qbs-ect-cmp/CaptureFlow-db5d90a4.js → collection/models/CaptureFlow.js} +4 -6
- package/dist/collection/models/FlowStatus.js +14 -0
- package/dist/collection/models/FlowSteps.js +30 -0
- package/dist/collection/models/IAbortResult.js +1 -0
- package/dist/collection/models/IAddRequest.js +1 -0
- package/dist/collection/models/IAgreement.js +1 -0
- package/dist/collection/models/ICamera.js +1 -0
- package/dist/{qbs-ect-cmp/IDevice-15ecfdeb.js → collection/models/IDevice.js} +4 -6
- package/dist/collection/models/IEctStore.js +1 -0
- package/dist/collection/models/IGeneration.js +1 -0
- package/dist/collection/models/ILinkSend.js +1 -0
- package/dist/collection/models/ILogResult.js +1 -0
- package/dist/collection/models/IOrderStatus.js +1 -0
- package/dist/collection/models/IOtpCheck.js +1 -0
- package/dist/collection/models/IOtpSend.js +1 -0
- package/dist/collection/models/ITranslationValues.js +1 -0
- package/dist/collection/models/IUploadFile.js +1 -0
- package/dist/collection/models/IVerificationMode.js +5 -0
- package/dist/collection/models/OrderStatuses.js +8 -0
- package/dist/{qbs-ect-cmp/utils-8225f0b7.js → collection/utils/utils.js} +8 -10
- package/dist/esm/agreement-check_19.entry.js +9476 -0
- package/dist/{qbs-ect-cmp/base-component-2e490fd9.js → esm/base-component-b7f50d31.js} +384 -62
- package/dist/esm/index-cf54a432.js +1543 -0
- package/dist/esm/index.js +1 -0
- package/dist/{qbs-ect-cmp → esm}/loader-dots.entry.js +1 -1
- package/dist/esm/loader.js +18 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/qbs-ect-cmp.js +18 -0
- package/dist/{qbs-ect-cmp → esm}/random-actions.entry.js +2 -4
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +3 -0
- package/dist/loader/index.cjs.js +3 -0
- package/dist/loader/index.d.ts +21 -0
- package/dist/loader/index.es2017.js +3 -0
- package/dist/loader/index.js +4 -0
- package/dist/loader/package.json +11 -0
- package/dist/qbs-ect-cmp/index.esm.js +0 -1
- package/dist/qbs-ect-cmp/p-054dc5b3.entry.js +1 -0
- package/dist/qbs-ect-cmp/p-215a7e76.entry.js +1 -0
- package/dist/qbs-ect-cmp/p-7bedffaa.js +1 -0
- package/dist/qbs-ect-cmp/p-8942656c.js +2 -0
- package/dist/qbs-ect-cmp/p-c32a782a.entry.js +1373 -0
- package/dist/qbs-ect-cmp/qbs-ect-cmp.css +1 -320
- package/dist/qbs-ect-cmp/qbs-ect-cmp.esm.js +1 -148
- package/package.json +1 -1
- package/dist/qbs-ect-cmp/ML5-657ef934.js +0 -1370
- package/dist/qbs-ect-cmp/Stream-b867a2be.js +0 -3104
- package/dist/qbs-ect-cmp/_commonjsHelpers-321aa363.js +0 -44
- package/dist/qbs-ect-cmp/agreement-check.entry.js +0 -41
- package/dist/qbs-ect-cmp/app-globals-0f993ce5.js +0 -3
- package/dist/qbs-ect-cmp/camera-comp.entry.js +0 -103
- package/dist/qbs-ect-cmp/css-shim-b7d3d95f.js +0 -4
- package/dist/qbs-ect-cmp/dom-64053c71.js +0 -73
- package/dist/qbs-ect-cmp/end-redirect.entry.js +0 -25
- package/dist/qbs-ect-cmp/error-end.entry.js +0 -19
- package/dist/qbs-ect-cmp/how-to-info.entry.js +0 -52
- package/dist/qbs-ect-cmp/identification-component.entry.js +0 -909
- package/dist/qbs-ect-cmp/index-78a05b9e.js +0 -3371
- package/dist/qbs-ect-cmp/landing-validation.entry.js +0 -90
- package/dist/qbs-ect-cmp/mobile-redirect.entry.js +0 -2984
- package/dist/qbs-ect-cmp/shadow-css-98135883.js +0 -387
- package/dist/qbs-ect-cmp/textValues-6bcc85dd.js +0 -302
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-41696e0e.js');
|
|
4
|
+
|
|
5
|
+
exports.OrderStatuses = void 0;
|
|
6
|
+
(function (OrderStatuses) {
|
|
7
|
+
OrderStatuses[OrderStatuses["Capturing"] = 0] = "Capturing";
|
|
8
|
+
OrderStatuses[OrderStatuses["FinishedCapturing"] = 1] = "FinishedCapturing";
|
|
9
|
+
OrderStatuses[OrderStatuses["Waiting"] = 2] = "Waiting";
|
|
10
|
+
OrderStatuses[OrderStatuses["NotFound"] = 3] = "NotFound";
|
|
11
|
+
OrderStatuses[OrderStatuses["Aborted"] = 4] = "Aborted";
|
|
12
|
+
})(exports.OrderStatuses || (exports.OrderStatuses = {}));
|
|
13
|
+
|
|
14
|
+
const appendToMap = (map, propName, value) => {
|
|
15
|
+
const items = map.get(propName);
|
|
16
|
+
if (!items) {
|
|
17
|
+
map.set(propName, [value]);
|
|
18
|
+
}
|
|
19
|
+
else if (!items.includes(value)) {
|
|
20
|
+
items.push(value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const debounce = (fn, ms) => {
|
|
24
|
+
let timeoutId;
|
|
25
|
+
return (...args) => {
|
|
26
|
+
if (timeoutId) {
|
|
27
|
+
clearTimeout(timeoutId);
|
|
28
|
+
}
|
|
29
|
+
timeoutId = setTimeout(() => {
|
|
30
|
+
timeoutId = 0;
|
|
31
|
+
fn(...args);
|
|
32
|
+
}, ms);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if a possible element isConnected.
|
|
38
|
+
* The property might not be there, so we check for it.
|
|
39
|
+
*
|
|
40
|
+
* We want it to return true if isConnected is not a property,
|
|
41
|
+
* otherwise we would remove these elements and would not update.
|
|
42
|
+
*
|
|
43
|
+
* Better leak in Edge than to be useless.
|
|
44
|
+
*/
|
|
45
|
+
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
46
|
+
const cleanupElements = debounce((map) => {
|
|
47
|
+
for (let key of map.keys()) {
|
|
48
|
+
map.set(key, map.get(key).filter(isConnected));
|
|
49
|
+
}
|
|
50
|
+
}, 2000);
|
|
51
|
+
const stencilSubscription = () => {
|
|
52
|
+
if (typeof index.getRenderingRef !== 'function') {
|
|
53
|
+
// If we are not in a stencil project, we do nothing.
|
|
54
|
+
// This function is not really exported by @stencil/core.
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
const elmsToUpdate = new Map();
|
|
58
|
+
return {
|
|
59
|
+
dispose: () => elmsToUpdate.clear(),
|
|
60
|
+
get: (propName) => {
|
|
61
|
+
const elm = index.getRenderingRef();
|
|
62
|
+
if (elm) {
|
|
63
|
+
appendToMap(elmsToUpdate, propName, elm);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
set: (propName) => {
|
|
67
|
+
const elements = elmsToUpdate.get(propName);
|
|
68
|
+
if (elements) {
|
|
69
|
+
elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
|
|
70
|
+
}
|
|
71
|
+
cleanupElements(elmsToUpdate);
|
|
72
|
+
},
|
|
73
|
+
reset: () => {
|
|
74
|
+
elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
|
|
75
|
+
cleanupElements(elmsToUpdate);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const unwrap = (val) => (typeof val === 'function' ? val() : val);
|
|
81
|
+
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
|
|
82
|
+
const unwrappedState = unwrap(defaultState);
|
|
83
|
+
let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
|
|
84
|
+
const handlers = {
|
|
85
|
+
dispose: [],
|
|
86
|
+
get: [],
|
|
87
|
+
set: [],
|
|
88
|
+
reset: [],
|
|
89
|
+
};
|
|
90
|
+
const reset = () => {
|
|
91
|
+
var _a;
|
|
92
|
+
// When resetting the state, the default state may be a function - unwrap it to invoke it.
|
|
93
|
+
// otherwise, the state won't be properly reset
|
|
94
|
+
states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
|
|
95
|
+
handlers.reset.forEach((cb) => cb());
|
|
96
|
+
};
|
|
97
|
+
const dispose = () => {
|
|
98
|
+
// Call first dispose as resetting the state would
|
|
99
|
+
// cause less updates ;)
|
|
100
|
+
handlers.dispose.forEach((cb) => cb());
|
|
101
|
+
reset();
|
|
102
|
+
};
|
|
103
|
+
const get = (propName) => {
|
|
104
|
+
handlers.get.forEach((cb) => cb(propName));
|
|
105
|
+
return states.get(propName);
|
|
106
|
+
};
|
|
107
|
+
const set = (propName, value) => {
|
|
108
|
+
const oldValue = states.get(propName);
|
|
109
|
+
if (shouldUpdate(value, oldValue, propName)) {
|
|
110
|
+
states.set(propName, value);
|
|
111
|
+
handlers.set.forEach((cb) => cb(propName, value, oldValue));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const state = (typeof Proxy === 'undefined'
|
|
115
|
+
? {}
|
|
116
|
+
: new Proxy(unwrappedState, {
|
|
117
|
+
get(_, propName) {
|
|
118
|
+
return get(propName);
|
|
119
|
+
},
|
|
120
|
+
ownKeys(_) {
|
|
121
|
+
return Array.from(states.keys());
|
|
122
|
+
},
|
|
123
|
+
getOwnPropertyDescriptor() {
|
|
124
|
+
return {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
configurable: true,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
has(_, propName) {
|
|
130
|
+
return states.has(propName);
|
|
131
|
+
},
|
|
132
|
+
set(_, propName, value) {
|
|
133
|
+
set(propName, value);
|
|
134
|
+
return true;
|
|
135
|
+
},
|
|
136
|
+
}));
|
|
137
|
+
const on = (eventName, callback) => {
|
|
138
|
+
handlers[eventName].push(callback);
|
|
139
|
+
return () => {
|
|
140
|
+
removeFromArray(handlers[eventName], callback);
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const onChange = (propName, cb) => {
|
|
144
|
+
const unSet = on('set', (key, newValue) => {
|
|
145
|
+
if (key === propName) {
|
|
146
|
+
cb(newValue);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// We need to unwrap the defaultState because it might be a function.
|
|
150
|
+
// Otherwise we might not be sending the right reset value.
|
|
151
|
+
const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
|
|
152
|
+
return () => {
|
|
153
|
+
unSet();
|
|
154
|
+
unReset();
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
const use = (...subscriptions) => {
|
|
158
|
+
const unsubs = subscriptions.reduce((unsubs, subscription) => {
|
|
159
|
+
if (subscription.set) {
|
|
160
|
+
unsubs.push(on('set', subscription.set));
|
|
161
|
+
}
|
|
162
|
+
if (subscription.get) {
|
|
163
|
+
unsubs.push(on('get', subscription.get));
|
|
164
|
+
}
|
|
165
|
+
if (subscription.reset) {
|
|
166
|
+
unsubs.push(on('reset', subscription.reset));
|
|
167
|
+
}
|
|
168
|
+
if (subscription.dispose) {
|
|
169
|
+
unsubs.push(on('dispose', subscription.dispose));
|
|
170
|
+
}
|
|
171
|
+
return unsubs;
|
|
172
|
+
}, []);
|
|
173
|
+
return () => unsubs.forEach((unsub) => unsub());
|
|
174
|
+
};
|
|
175
|
+
const forceUpdate = (key) => {
|
|
176
|
+
const oldValue = states.get(key);
|
|
177
|
+
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
state,
|
|
181
|
+
get,
|
|
182
|
+
set,
|
|
183
|
+
on,
|
|
184
|
+
onChange,
|
|
185
|
+
use,
|
|
186
|
+
dispose,
|
|
187
|
+
reset,
|
|
188
|
+
forceUpdate,
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const removeFromArray = (array, item) => {
|
|
192
|
+
const index = array.indexOf(item);
|
|
193
|
+
if (index >= 0) {
|
|
194
|
+
array[index] = array[array.length - 1];
|
|
195
|
+
array.length--;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const createStore = (defaultState, shouldUpdate) => {
|
|
200
|
+
const map = createObservableMap(defaultState, shouldUpdate);
|
|
201
|
+
map.use(stencilSubscription());
|
|
202
|
+
return map;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
exports.FlowStatus = void 0;
|
|
206
|
+
(function (FlowStatus) {
|
|
207
|
+
FlowStatus[FlowStatus["LANDING"] = 0] = "LANDING";
|
|
208
|
+
FlowStatus[FlowStatus["AGREEMENT"] = 1] = "AGREEMENT";
|
|
209
|
+
FlowStatus[FlowStatus["PHONE"] = 2] = "PHONE";
|
|
210
|
+
FlowStatus[FlowStatus["CODE"] = 3] = "CODE";
|
|
211
|
+
FlowStatus[FlowStatus["CODEERROR"] = 4] = "CODEERROR";
|
|
212
|
+
FlowStatus[FlowStatus["ID"] = 5] = "ID";
|
|
213
|
+
FlowStatus[FlowStatus["LIVENESS"] = 6] = "LIVENESS";
|
|
214
|
+
FlowStatus[FlowStatus["COMPLETE"] = 7] = "COMPLETE";
|
|
215
|
+
FlowStatus[FlowStatus["ERROREND"] = 8] = "ERROREND";
|
|
216
|
+
FlowStatus[FlowStatus["CAMERAERROR"] = 9] = "CAMERAERROR";
|
|
217
|
+
FlowStatus[FlowStatus["NONE"] = 10] = "NONE";
|
|
218
|
+
})(exports.FlowStatus || (exports.FlowStatus = {}));
|
|
219
|
+
|
|
220
|
+
class IdCaptureValues {
|
|
221
|
+
}
|
|
222
|
+
IdCaptureValues.IDPoseDemoMapping = {
|
|
223
|
+
0: 'https://ekyc.blob.core.windows.net/$web/animations/id/id_front.mp4',
|
|
224
|
+
1: 'https://ekyc.blob.core.windows.net/$web/animations/id/id_front_tilt.mp4',
|
|
225
|
+
2: 'https://ekyc.blob.core.windows.net/$web/animations/id/id_rotate.mp4',
|
|
226
|
+
3: 'https://ekyc.blob.core.windows.net/$web/animations/id/id_back.mp4',
|
|
227
|
+
4: 'https://ekyc.blob.core.windows.net/$web/animations/id/id_back_tilt.mp4',
|
|
228
|
+
};
|
|
229
|
+
class SelfieCaptureValues {
|
|
230
|
+
}
|
|
231
|
+
SelfieCaptureValues.FacePoseDemoMapping = {
|
|
232
|
+
0: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_rotate_left.mp4',
|
|
233
|
+
1: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_rotate_right.mp4',
|
|
234
|
+
2: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_tilt_back.mp4',
|
|
235
|
+
3: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_tilt_front.mp4',
|
|
236
|
+
// 4: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_tilt_left.mp4',
|
|
237
|
+
// 5: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_tilt_right.mp4',
|
|
238
|
+
4: 'https://ekyc.blob.core.windows.net/$web/animations/selfie/selfie_main.mp4',
|
|
239
|
+
};
|
|
240
|
+
class SessionKeys {
|
|
241
|
+
}
|
|
242
|
+
SessionKeys.FlowStatusKey = 'qbs-ect-flowstatus';
|
|
243
|
+
SessionKeys.RequestIdKey = 'qbs-ect-requestid';
|
|
244
|
+
SessionKeys.TokenKey = 'qbs-ect-token';
|
|
245
|
+
SessionKeys.InitialisedKey = 'qbs-ect-initialised';
|
|
246
|
+
SessionKeys.HasIdBackKey = 'qbs-ect-has-id-back';
|
|
247
|
+
SessionKeys.AgreementValidationKey = 'qbs-ect-agreement-validation';
|
|
248
|
+
SessionKeys.PhoneValidationKey = 'qbs-ect-phone-validation';
|
|
249
|
+
SessionKeys.RefreshDoneKey = 'qbs-ect-refresh-done';
|
|
250
|
+
class ApiUrls {
|
|
251
|
+
constructor() {
|
|
252
|
+
this.uriEnv = '/';
|
|
253
|
+
this.uriEnv = state.environment == 'QA' ? '/dev_' : '/';
|
|
254
|
+
this.OtpSend = this.uriEnv + 'validation/otp/send';
|
|
255
|
+
this.OtpCheck = this.uriEnv + 'validation/otp/check';
|
|
256
|
+
this.IdentityInsert = this.uriEnv + 'validation/identity/insert';
|
|
257
|
+
this.UploadCapture = this.uriEnv + 'validation/upload/capture';
|
|
258
|
+
this.GetAgreement = this.uriEnv + 'validation/agreement/content';
|
|
259
|
+
this.GenerateAgreement = this.uriEnv + 'validation/agreement/generate';
|
|
260
|
+
this.SendLink = this.uriEnv + 'validation/otp/sendlink';
|
|
261
|
+
this.GetStatus = this.uriEnv + 'validation/identity/status';
|
|
262
|
+
this.AddLog = this.uriEnv + 'validation/logs/add';
|
|
263
|
+
this.AddStep = this.uriEnv + 'validation/logs/step';
|
|
264
|
+
this.AbortRequest = this.uriEnv + 'validation/identity/abort';
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const { state, onChange } = createStore({
|
|
269
|
+
flowStatus: exports.FlowStatus.NONE,
|
|
270
|
+
environment: 'PROD',
|
|
271
|
+
debug: false,
|
|
272
|
+
requestId: '',
|
|
273
|
+
redirectId: '',
|
|
274
|
+
initialised: false,
|
|
275
|
+
token: '',
|
|
276
|
+
cameraIds: [],
|
|
277
|
+
cameraId: '',
|
|
278
|
+
hasIdBack: false,
|
|
279
|
+
hasSelfieGesture: false,
|
|
280
|
+
hasIdTilt: false,
|
|
281
|
+
agreementsValidation: true,
|
|
282
|
+
phoneValidation: true,
|
|
283
|
+
phoneNumber: '',
|
|
284
|
+
apiBaseUrl: 'https://apiro.id-kyc.com',
|
|
285
|
+
device: null,
|
|
286
|
+
langIso: 'ro',
|
|
287
|
+
});
|
|
288
|
+
onChange('environment', value => {
|
|
289
|
+
state.debug = value == 'QA';
|
|
290
|
+
});
|
|
291
|
+
onChange('flowStatus', value => {
|
|
292
|
+
sessionStorage.setItem(SessionKeys.FlowStatusKey, exports.FlowStatus[value]);
|
|
293
|
+
});
|
|
294
|
+
onChange('token', value => {
|
|
295
|
+
sessionStorage.setItem(SessionKeys.TokenKey, value);
|
|
296
|
+
});
|
|
297
|
+
onChange('requestId', value => {
|
|
298
|
+
sessionStorage.setItem(SessionKeys.RequestIdKey, value);
|
|
299
|
+
});
|
|
300
|
+
onChange('initialised', value => {
|
|
301
|
+
sessionStorage.setItem(SessionKeys.InitialisedKey, String(value));
|
|
302
|
+
});
|
|
303
|
+
onChange('hasIdBack', value => {
|
|
304
|
+
sessionStorage.setItem(SessionKeys.HasIdBackKey, String(value));
|
|
305
|
+
});
|
|
306
|
+
onChange('agreementsValidation', value => {
|
|
307
|
+
sessionStorage.setItem(SessionKeys.AgreementValidationKey, String(value));
|
|
308
|
+
});
|
|
309
|
+
onChange('phoneValidation', value => {
|
|
310
|
+
sessionStorage.setItem(SessionKeys.PhoneValidationKey, String(value));
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
exports.FlowSteps = void 0;
|
|
314
|
+
(function (FlowSteps) {
|
|
315
|
+
FlowSteps[FlowSteps["ComponentLoaded"] = 'component-loaded'] = "ComponentLoaded";
|
|
316
|
+
FlowSteps[FlowSteps["MobileRedirect"] = 'mobile-redirect'] = "MobileRedirect";
|
|
317
|
+
FlowSteps[FlowSteps["Landing"] = 'landing'] = "Landing";
|
|
318
|
+
FlowSteps[FlowSteps["Agreements"] = 'agreements'] = "Agreements";
|
|
319
|
+
FlowSteps[FlowSteps["OtpSend"] = 'otp-send'] = "OtpSend";
|
|
320
|
+
FlowSteps[FlowSteps["OtpCheck"] = 'otp-check'] = "OtpCheck";
|
|
321
|
+
FlowSteps[FlowSteps["CiFront"] = 'ci-front'] = "CiFront";
|
|
322
|
+
FlowSteps[FlowSteps["CiFrontHowTo"] = 'ci-front-how-to'] = "CiFrontHowTo";
|
|
323
|
+
FlowSteps[FlowSteps["CiFrontCapture"] = 'ci-front-capture'] = "CiFrontCapture";
|
|
324
|
+
FlowSteps[FlowSteps["CiBack"] = 'ci-back'] = "CiBack";
|
|
325
|
+
FlowSteps[FlowSteps["CiBackHowTo"] = 'ci-back-how-to'] = "CiBackHowTo";
|
|
326
|
+
FlowSteps[FlowSteps["CiBackCapture"] = 'ci-back-capture'] = "CiBackCapture";
|
|
327
|
+
FlowSteps[FlowSteps["CiTilt"] = 'ci-tilt'] = "CiTilt";
|
|
328
|
+
FlowSteps[FlowSteps["CiError"] = 'ci-error'] = "CiError";
|
|
329
|
+
FlowSteps[FlowSteps["SelfieHowTo"] = 'selfie-how-to'] = "SelfieHowTo";
|
|
330
|
+
FlowSteps[FlowSteps["SelfieTilt"] = 'selfie-tilt'] = "SelfieTilt";
|
|
331
|
+
FlowSteps[FlowSteps["SelfieCapture"] = 'selfie-capture'] = "SelfieCapture";
|
|
332
|
+
FlowSteps[FlowSteps["Selfie"] = 'selfie'] = "Selfie";
|
|
333
|
+
FlowSteps[FlowSteps["SelfieError"] = 'selfie-error'] = "SelfieError";
|
|
334
|
+
FlowSteps[FlowSteps["End"] = 'end'] = "End";
|
|
335
|
+
FlowSteps[FlowSteps["CameraError"] = 'camera-error'] = "CameraError";
|
|
336
|
+
})(exports.FlowSteps || (exports.FlowSteps = {}));
|
|
337
|
+
exports.FlowMoments = void 0;
|
|
338
|
+
(function (FlowMoments) {
|
|
339
|
+
FlowMoments[FlowMoments["Initialized"] = 'initialized'] = "Initialized";
|
|
340
|
+
FlowMoments[FlowMoments["Finalized"] = 'finalized'] = "Finalized";
|
|
341
|
+
FlowMoments[FlowMoments["None"] = 'none'] = "None";
|
|
342
|
+
})(exports.FlowMoments || (exports.FlowMoments = {}));
|
|
343
|
+
|
|
344
|
+
class ApiCall {
|
|
345
|
+
constructor() {
|
|
346
|
+
this.serviceErrors = ['Service Unavailable', 'Unauthorized'];
|
|
347
|
+
this.toBase64 = (file) => new Promise((resolve, reject) => {
|
|
348
|
+
const reader = new FileReader();
|
|
349
|
+
reader.readAsDataURL(file);
|
|
350
|
+
reader.onload = () => resolve(reader.result);
|
|
351
|
+
reader.onerror = error => reject(error);
|
|
352
|
+
});
|
|
353
|
+
this.urls = new ApiUrls();
|
|
354
|
+
}
|
|
355
|
+
// private async http2<T>(method: string, url: string, data: string): Promise<T> {
|
|
356
|
+
// return new Promise((resolve, reject) => {
|
|
357
|
+
// var xhr = new XMLHttpRequest();
|
|
358
|
+
// xhr.open(method, url);
|
|
359
|
+
// xhr.onload = function () {
|
|
360
|
+
// if (xhr.status >= 200 && xhr.status < 300) {
|
|
361
|
+
// resolve(xhr.response);
|
|
362
|
+
// } else {
|
|
363
|
+
// reject({
|
|
364
|
+
// status: xhr.status,
|
|
365
|
+
// statusText: xhr.statusText,
|
|
366
|
+
// });
|
|
367
|
+
// }
|
|
368
|
+
// };
|
|
369
|
+
// xhr.onerror = function () {
|
|
370
|
+
// reject({
|
|
371
|
+
// status: xhr.status,
|
|
372
|
+
// statusText: xhr.statusText,
|
|
373
|
+
// });
|
|
374
|
+
// };
|
|
375
|
+
// xhr.send(data);
|
|
376
|
+
// });
|
|
377
|
+
// }
|
|
378
|
+
async http(request) {
|
|
379
|
+
const response = await fetch(request);
|
|
380
|
+
if (!response.ok) {
|
|
381
|
+
throw new Error(response.statusText);
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
// may error if there is no body
|
|
385
|
+
return await response.json();
|
|
386
|
+
}
|
|
387
|
+
catch (ex) {
|
|
388
|
+
throw new Error('No json found in response ' + ex);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async post(url, data, withRetry = true) {
|
|
392
|
+
var request = new Request(state.apiBaseUrl + url, {
|
|
393
|
+
method: 'POST',
|
|
394
|
+
body: data,
|
|
395
|
+
headers: {
|
|
396
|
+
'Content-Type': 'application/json',
|
|
397
|
+
'Authorization': 'IDKYC-TOKEN ' + state.token,
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
try {
|
|
401
|
+
return await this.http(request);
|
|
402
|
+
}
|
|
403
|
+
catch (ex) {
|
|
404
|
+
if (!withRetry || this.serviceErrors.includes(ex.message)) {
|
|
405
|
+
throw ex;
|
|
406
|
+
}
|
|
407
|
+
this.AddLog('Error in post ', ex);
|
|
408
|
+
try {
|
|
409
|
+
var request2 = new Request(state.apiBaseUrl + url, {
|
|
410
|
+
method: 'POST',
|
|
411
|
+
body: data,
|
|
412
|
+
headers: {
|
|
413
|
+
'Content-Type': 'application/json',
|
|
414
|
+
'Authorization': 'IDKYC-TOKEN ' + state.token,
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
return await this.http(request2);
|
|
418
|
+
}
|
|
419
|
+
catch (ex2) {
|
|
420
|
+
this.AddLog('Error in post ', ex2);
|
|
421
|
+
var request3 = new Request(state.apiBaseUrl + url, {
|
|
422
|
+
method: 'POST',
|
|
423
|
+
body: data,
|
|
424
|
+
headers: {
|
|
425
|
+
'Content-Type': 'application/json',
|
|
426
|
+
'Authorization': 'IDKYC-TOKEN ' + state.token,
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
return await this.http(request3);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async get(url, withRetry = true) {
|
|
434
|
+
var request = new Request(state.apiBaseUrl + url, {
|
|
435
|
+
method: 'GET',
|
|
436
|
+
headers: {
|
|
437
|
+
'Content-Type': 'application/json',
|
|
438
|
+
'Authorization': 'IDKYC-TOKEN ' + state.token,
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
try {
|
|
442
|
+
return await this.http(request);
|
|
443
|
+
}
|
|
444
|
+
catch (ex) {
|
|
445
|
+
if (!withRetry || this.serviceErrors.includes(ex.message)) {
|
|
446
|
+
throw ex;
|
|
447
|
+
}
|
|
448
|
+
this.AddLog('Error in get ', ex);
|
|
449
|
+
try {
|
|
450
|
+
var request2 = new Request(state.apiBaseUrl + url, {
|
|
451
|
+
method: 'GET',
|
|
452
|
+
headers: {
|
|
453
|
+
'Content-Type': 'application/json',
|
|
454
|
+
'Authorization': 'IDKYC-TOKEN ' + state.token,
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
return await this.http(request2);
|
|
458
|
+
}
|
|
459
|
+
catch (ex2) {
|
|
460
|
+
this.AddLog('Error in get ', ex2);
|
|
461
|
+
var request3 = new Request(state.apiBaseUrl + url, {
|
|
462
|
+
method: 'GET',
|
|
463
|
+
headers: {
|
|
464
|
+
'Content-Type': 'application/json',
|
|
465
|
+
'Authorization': 'IDKYC-TOKEN ' + state.token,
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
return await this.http(request3);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async SendOTPCode(requestId, phoneNumber) {
|
|
473
|
+
let data = { requestId: requestId, phone: phoneNumber };
|
|
474
|
+
let jsonResp = await this.post(this.urls.OtpSend, JSON.stringify(data));
|
|
475
|
+
return jsonResp.sent;
|
|
476
|
+
}
|
|
477
|
+
async CheckOTPCode(requestId, otpCode) {
|
|
478
|
+
let data = { requestId: requestId, otp: otpCode };
|
|
479
|
+
let jsonResp = await this.post(this.urls.OtpCheck, JSON.stringify(data));
|
|
480
|
+
return jsonResp.valid;
|
|
481
|
+
}
|
|
482
|
+
async AddIdentificationRequest(deviceInfo, version) {
|
|
483
|
+
if (state.debug)
|
|
484
|
+
console.log('Calling identity request with store:' + JSON.stringify(state));
|
|
485
|
+
let data = {
|
|
486
|
+
requestId: state.requestId,
|
|
487
|
+
clientDeviceInfo: JSON.stringify(deviceInfo),
|
|
488
|
+
redirectId: state.redirectId,
|
|
489
|
+
phoneNumber: state.phoneNumber,
|
|
490
|
+
version: version,
|
|
491
|
+
};
|
|
492
|
+
let jsonResp = await this.post(this.urls.IdentityInsert, JSON.stringify(data));
|
|
493
|
+
if (state.requestId == '') {
|
|
494
|
+
state.requestId = jsonResp.requestId;
|
|
495
|
+
}
|
|
496
|
+
state.hasIdBack = jsonResp.hasIdBack;
|
|
497
|
+
state.hasIdTilt = jsonResp.hasIdTilt;
|
|
498
|
+
state.hasSelfieGesture = jsonResp.hasSelfieGesture;
|
|
499
|
+
state.agreementsValidation = jsonResp.agreementsValidation;
|
|
500
|
+
state.phoneValidation = jsonResp.phoneValidation;
|
|
501
|
+
state.phoneNumber = jsonResp.phoneNumber;
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
async UploadFileForRequestB64(requestId, type, file) {
|
|
505
|
+
let data = {
|
|
506
|
+
requestId: requestId,
|
|
507
|
+
type: type,
|
|
508
|
+
data: await this.toBase64(file),
|
|
509
|
+
};
|
|
510
|
+
let respJson = await this.post(this.urls.UploadCapture, JSON.stringify(data));
|
|
511
|
+
if (!state.hasIdBack && type == 'IdFront') {
|
|
512
|
+
return respJson.isValid;
|
|
513
|
+
}
|
|
514
|
+
if (state.hasIdBack && type == 'IdBack') {
|
|
515
|
+
return respJson.isValid;
|
|
516
|
+
}
|
|
517
|
+
if (type == 'Selfie') {
|
|
518
|
+
return respJson.isValid;
|
|
519
|
+
}
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
async GetAgreement(agreementType) {
|
|
523
|
+
let resp = await this.get(this.urls.GetAgreement + '?type=' + agreementType + '&requestId=' + state.requestId);
|
|
524
|
+
return resp.htmlText;
|
|
525
|
+
}
|
|
526
|
+
async GenerateAgreement(agreementType) {
|
|
527
|
+
let data = { requestId: state.requestId, documentType: agreementType };
|
|
528
|
+
let resp = await this.post(this.urls.GenerateAgreement, JSON.stringify(data));
|
|
529
|
+
return resp.generation;
|
|
530
|
+
}
|
|
531
|
+
async GetStatus(requestId) {
|
|
532
|
+
let resp = await this.get(this.urls.GetStatus + '?orderId=' + requestId);
|
|
533
|
+
return exports.OrderStatuses[resp.status];
|
|
534
|
+
}
|
|
535
|
+
async SendLink(link, phoneNumber) {
|
|
536
|
+
let data = { requestId: state.requestId, link: link, phoneNumber: phoneNumber };
|
|
537
|
+
let resp = await this.post(this.urls.SendLink, JSON.stringify(data));
|
|
538
|
+
return resp.sent;
|
|
539
|
+
}
|
|
540
|
+
async AddLog(error, context) {
|
|
541
|
+
try {
|
|
542
|
+
let data = {
|
|
543
|
+
requestId: state.requestId,
|
|
544
|
+
action: exports.FlowStatus[state.flowStatus],
|
|
545
|
+
message: JSON.stringify({ error, context }),
|
|
546
|
+
};
|
|
547
|
+
let result = await this.post(this.urls.AddLog, JSON.stringify(data), false);
|
|
548
|
+
return result.saved;
|
|
549
|
+
}
|
|
550
|
+
catch (_a) { }
|
|
551
|
+
}
|
|
552
|
+
async AddStep(step, moment) {
|
|
553
|
+
let data = { requestId: state.requestId, redirectId: state.redirectId, step: exports.FlowSteps[step], moment: exports.FlowMoments[moment], timestamp: new Date().toISOString() };
|
|
554
|
+
let result = await this.post(this.urls.AddStep, JSON.stringify(data));
|
|
555
|
+
return result.saved;
|
|
556
|
+
}
|
|
557
|
+
async AbortRequest() {
|
|
558
|
+
let result = await this.post(this.urls.AbortRequest, JSON.stringify({ requestId: state.requestId }));
|
|
559
|
+
return result.saved;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
exports.MobileOS = void 0;
|
|
564
|
+
(function (MobileOS) {
|
|
565
|
+
MobileOS["Android"] = "android";
|
|
566
|
+
MobileOS["iOS"] = "ios";
|
|
567
|
+
MobileOS["Unknown"] = "unknown";
|
|
568
|
+
MobileOS["WindowsPhone"] = "Windows Phone";
|
|
569
|
+
})(exports.MobileOS || (exports.MobileOS = {}));
|
|
570
|
+
var DesktopOS;
|
|
571
|
+
(function (DesktopOS) {
|
|
572
|
+
DesktopOS["Linux"] = "linux";
|
|
573
|
+
DesktopOS["MacOS"] = "mac_os";
|
|
574
|
+
DesktopOS["Unix"] = "unix";
|
|
575
|
+
DesktopOS["Unknown"] = "unknown";
|
|
576
|
+
DesktopOS["Windows"] = "windows";
|
|
577
|
+
})(DesktopOS || (DesktopOS = {}));
|
|
578
|
+
exports.Browser = void 0;
|
|
579
|
+
(function (Browser) {
|
|
580
|
+
Browser["Chrome"] = "chrome";
|
|
581
|
+
Browser["Firefox"] = "firefox";
|
|
582
|
+
Browser["Safari"] = "safari";
|
|
583
|
+
Browser["Mi"] = "mi";
|
|
584
|
+
Browser["Unknown"] = "unknown";
|
|
585
|
+
})(exports.Browser || (exports.Browser = {}));
|
|
586
|
+
|
|
587
|
+
class DeviceDetection {
|
|
588
|
+
constructor() {
|
|
589
|
+
var _a, _b, _c, _d;
|
|
590
|
+
this.supportedScreenOrientation = (_b = (_a = ((screen === null || screen === void 0 ? void 0 : screen.orientation) || {}).type) !== null && _a !== void 0 ? _a : screen.mozOrientation) !== null && _b !== void 0 ? _b : screen.msOrientation;
|
|
591
|
+
this.safariScreenOrientation = !(screen === null || screen === void 0 ? void 0 : screen.orientation) && matchMedia('(orientation: portrait)').matches ? 'portrait-primary' : 'landscape-primary';
|
|
592
|
+
this.initialScreenOrientation = (_d = (_c = this.supportedScreenOrientation) !== null && _c !== void 0 ? _c : this.safariScreenOrientation) !== null && _d !== void 0 ? _d : 'portrait-primary';
|
|
593
|
+
this.userAgent = navigator.userAgent || navigator.vendor || window.opera || undefined;
|
|
594
|
+
this.isMobile = this.isMobileDevice();
|
|
595
|
+
this.isTablet = this.isTabletDevice();
|
|
596
|
+
this.isDesktop = !this.isMobile && !this.isTablet;
|
|
597
|
+
}
|
|
598
|
+
// Device typology
|
|
599
|
+
isMobileDevice() {
|
|
600
|
+
const regexs = [/(Android)(.+)(Mobile)/i, /BlackBerry/i, /iPhone|iPod/i, /Opera Mini/i, /IEMobile/i];
|
|
601
|
+
return regexs.some(b => this.userAgent.match(b));
|
|
602
|
+
}
|
|
603
|
+
isTabletDevice() {
|
|
604
|
+
const regex = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/;
|
|
605
|
+
return regex.test(this.userAgent.toLowerCase());
|
|
606
|
+
}
|
|
607
|
+
// Device Operating System
|
|
608
|
+
getMobileOS() {
|
|
609
|
+
if (this.isMobileDevice()) {
|
|
610
|
+
if (/windows phone/i.test(this.userAgent))
|
|
611
|
+
return exports.MobileOS.WindowsPhone;
|
|
612
|
+
else if (/android/i.test(this.userAgent))
|
|
613
|
+
return exports.MobileOS.Android;
|
|
614
|
+
else if (/iPad|iPhone|iPod/.test(this.userAgent) && !window.MSStream)
|
|
615
|
+
return exports.MobileOS.iOS;
|
|
616
|
+
return exports.MobileOS.Unknown;
|
|
617
|
+
}
|
|
618
|
+
else
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
getDesktopOS() {
|
|
622
|
+
if (this.isDesktop) {
|
|
623
|
+
if (this.userAgent.indexOf('Win') !== -1)
|
|
624
|
+
return DesktopOS.Windows;
|
|
625
|
+
else if (this.userAgent.indexOf('Mac') !== -1)
|
|
626
|
+
return DesktopOS.MacOS;
|
|
627
|
+
else if (this.userAgent.indexOf('X11') !== -1)
|
|
628
|
+
return DesktopOS.Unix;
|
|
629
|
+
else if (this.userAgent.indexOf('Linux') !== -1)
|
|
630
|
+
return DesktopOS.Linux;
|
|
631
|
+
return DesktopOS.Unknown;
|
|
632
|
+
}
|
|
633
|
+
else
|
|
634
|
+
return undefined;
|
|
635
|
+
}
|
|
636
|
+
getDeviceOS() {
|
|
637
|
+
var _a;
|
|
638
|
+
return (_a = this.getMobileOS()) !== null && _a !== void 0 ? _a : this.getDesktopOS();
|
|
639
|
+
}
|
|
640
|
+
getBrowser() {
|
|
641
|
+
if (/XiaoMi/i.test(this.userAgent) || /MiuiBrowser/i.test(this.userAgent))
|
|
642
|
+
return exports.Browser.Mi;
|
|
643
|
+
var isChrome = /chrome/i.test(this.userAgent);
|
|
644
|
+
if (isChrome)
|
|
645
|
+
return exports.Browser.Chrome;
|
|
646
|
+
if (/firefox/i.test(navigator.userAgent))
|
|
647
|
+
return exports.Browser.Firefox;
|
|
648
|
+
else if (!isChrome && /safari/i.test(navigator.userAgent))
|
|
649
|
+
return exports.Browser.Safari;
|
|
650
|
+
else
|
|
651
|
+
return exports.Browser.Unknown;
|
|
652
|
+
}
|
|
653
|
+
getDevice() {
|
|
654
|
+
var device = {
|
|
655
|
+
isDesktop: this.isDesktop,
|
|
656
|
+
desktopOS: this.getDesktopOS(),
|
|
657
|
+
isWindowsDesktop: this.getDeviceOS() === DesktopOS.Windows,
|
|
658
|
+
isLinuxOrUnixDesktop: this.getDeviceOS() === DesktopOS.Linux || this.getDeviceOS() === DesktopOS.Unix,
|
|
659
|
+
isMobile: this.isMobile,
|
|
660
|
+
mobileOS: this.getMobileOS(),
|
|
661
|
+
isAndroidDevice: this.getDeviceOS() === exports.MobileOS.Android,
|
|
662
|
+
isAppleDevice: this.getDeviceOS() === exports.MobileOS.iOS || this.getDeviceOS() === DesktopOS.MacOS,
|
|
663
|
+
isUnknownMobileDevice: this.getDeviceOS() === exports.MobileOS.Unknown,
|
|
664
|
+
browser: this.getBrowser(),
|
|
665
|
+
isTablet: this.isTablet,
|
|
666
|
+
initialScreenOrientation: this.initialScreenOrientation,
|
|
667
|
+
};
|
|
668
|
+
return device;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
class Events {
|
|
673
|
+
static init(element) {
|
|
674
|
+
this.callingModule = element;
|
|
675
|
+
}
|
|
676
|
+
static flowEvent(step, moment) {
|
|
677
|
+
const eventName = `ect-${step.toString()}-${moment.toString()}-event`;
|
|
678
|
+
this.callingModule.dispatchEvent(new CustomEvent(eventName, {
|
|
679
|
+
detail: {},
|
|
680
|
+
bubbles: true,
|
|
681
|
+
cancelable: true,
|
|
682
|
+
composed: true,
|
|
683
|
+
}));
|
|
684
|
+
}
|
|
685
|
+
static flowStarted() {
|
|
686
|
+
this.callingModule.dispatchEvent(new CustomEvent('ect-started', {
|
|
687
|
+
detail: {},
|
|
688
|
+
bubbles: true,
|
|
689
|
+
cancelable: true,
|
|
690
|
+
composed: true,
|
|
691
|
+
}));
|
|
692
|
+
}
|
|
693
|
+
static flowAborted() {
|
|
694
|
+
sessionStorage.clear();
|
|
695
|
+
this.callingModule.dispatchEvent(new CustomEvent('ect-aborted', {
|
|
696
|
+
detail: {},
|
|
697
|
+
bubbles: true,
|
|
698
|
+
cancelable: true,
|
|
699
|
+
composed: true,
|
|
700
|
+
}));
|
|
701
|
+
}
|
|
702
|
+
static flowCompleted() {
|
|
703
|
+
sessionStorage.clear();
|
|
704
|
+
this.callingModule.dispatchEvent(new CustomEvent('ect-completed', {
|
|
705
|
+
detail: {},
|
|
706
|
+
bubbles: true,
|
|
707
|
+
cancelable: true,
|
|
708
|
+
composed: true,
|
|
709
|
+
}));
|
|
710
|
+
}
|
|
711
|
+
static flowError(error) {
|
|
712
|
+
sessionStorage.clear();
|
|
713
|
+
this.callingModule.dispatchEvent(new CustomEvent('ect-error', {
|
|
714
|
+
detail: { error },
|
|
715
|
+
bubbles: true,
|
|
716
|
+
cancelable: true,
|
|
717
|
+
composed: true,
|
|
718
|
+
}));
|
|
719
|
+
}
|
|
720
|
+
static tokenExpired() {
|
|
721
|
+
sessionStorage.clear();
|
|
722
|
+
this.callingModule.dispatchEvent(new CustomEvent('ect-session-expired', {
|
|
723
|
+
detail: {},
|
|
724
|
+
bubbles: true,
|
|
725
|
+
cancelable: true,
|
|
726
|
+
composed: true,
|
|
727
|
+
}));
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
class TranslationsController {
|
|
732
|
+
async getValues() {
|
|
733
|
+
if (this.values) {
|
|
734
|
+
return this.values;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
this.values = await this.fetchTranslations();
|
|
738
|
+
return this.values;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
getLocale(element = document.body) {
|
|
742
|
+
const closestElement = element.closest('[lang]');
|
|
743
|
+
return closestElement ? closestElement.lang : state.langIso;
|
|
744
|
+
}
|
|
745
|
+
async fetchTranslations() {
|
|
746
|
+
const locale = this.getLocale();
|
|
747
|
+
const existingTranslations = JSON.parse(sessionStorage.getItem(`i18n.${locale}`));
|
|
748
|
+
if (existingTranslations && Object.keys(existingTranslations).length > 0) {
|
|
749
|
+
return existingTranslations;
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
try {
|
|
753
|
+
const result = await fetch(`/i18n/${locale}.json`);
|
|
754
|
+
if (result.ok) {
|
|
755
|
+
const data = await result.json();
|
|
756
|
+
sessionStorage.setItem(`i18n.${locale}`, JSON.stringify(data));
|
|
757
|
+
return data;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
catch (exception) {
|
|
761
|
+
console.error(`Error loading locale: ${locale}`, exception);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
const Translations = new TranslationsController();
|
|
767
|
+
|
|
768
|
+
class BaseComponent {
|
|
769
|
+
constructor(step) {
|
|
770
|
+
this.apiErrorEvent = null;
|
|
771
|
+
this.processError = null;
|
|
772
|
+
this.apiCall = new ApiCall();
|
|
773
|
+
if (step)
|
|
774
|
+
this.flowStep = step;
|
|
775
|
+
if (!state.device) {
|
|
776
|
+
state.device = new DeviceDetection().getDevice();
|
|
777
|
+
}
|
|
778
|
+
Translations.getValues().then(data => {
|
|
779
|
+
this.translations = data;
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
setEventEmitter(event) {
|
|
783
|
+
this.apiErrorEvent = event;
|
|
784
|
+
}
|
|
785
|
+
setErrorCallback(callback) {
|
|
786
|
+
this.processError = callback;
|
|
787
|
+
}
|
|
788
|
+
async logStep(step, moment) {
|
|
789
|
+
Events.flowEvent(step, moment);
|
|
790
|
+
try {
|
|
791
|
+
await this.apiCall.AddStep(step, moment);
|
|
792
|
+
}
|
|
793
|
+
catch (e) {
|
|
794
|
+
if (this.apiErrorEvent)
|
|
795
|
+
this.apiErrorEvent.emit(e);
|
|
796
|
+
else
|
|
797
|
+
this.processError(e, `${step}-${moment}`);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
async initialize() {
|
|
801
|
+
Events.flowEvent(this.flowStep, exports.FlowMoments.Initialized);
|
|
802
|
+
try {
|
|
803
|
+
await this.apiCall.AddStep(this.flowStep, exports.FlowMoments.Initialized);
|
|
804
|
+
}
|
|
805
|
+
catch (e) {
|
|
806
|
+
if (this.apiErrorEvent)
|
|
807
|
+
this.apiErrorEvent.emit(e);
|
|
808
|
+
else
|
|
809
|
+
this.processError(e, `${this.flowStep}-${exports.FlowMoments.Initialized}`);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
async finalize() {
|
|
813
|
+
Events.flowEvent(this.flowStep, exports.FlowMoments.Finalized);
|
|
814
|
+
try {
|
|
815
|
+
await this.apiCall.AddStep(this.flowStep, exports.FlowMoments.Finalized);
|
|
816
|
+
}
|
|
817
|
+
catch (e) {
|
|
818
|
+
if (this.apiErrorEvent)
|
|
819
|
+
this.apiErrorEvent.emit(e);
|
|
820
|
+
else
|
|
821
|
+
this.processError(e, `${this.flowStep}-${exports.FlowMoments.Finalized}`);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
exports.ApiCall = ApiCall;
|
|
827
|
+
exports.BaseComponent = BaseComponent;
|
|
828
|
+
exports.Events = Events;
|
|
829
|
+
exports.IdCaptureValues = IdCaptureValues;
|
|
830
|
+
exports.SelfieCaptureValues = SelfieCaptureValues;
|
|
831
|
+
exports.SessionKeys = SessionKeys;
|
|
832
|
+
exports.state = state;
|