@authme/core 2.3.1-rc.3 → 2.4.2
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/index.cjs +348 -3
- package/index.js +343 -5
- package/package.json +4 -2
- package/src/index.d.ts +1 -0
- package/src/lib/enum/language.enum.d.ts +2 -1
- package/src/lib/features/event-listener/event-listener.service.d.ts +18 -0
- package/src/lib/features/event-listener/event-logging.api.d.ts +4 -0
- package/src/lib/features/event-listener/index.d.ts +5 -0
- package/src/lib/features/event-listener/mock-api.service.d.ts +7 -0
- package/src/lib/features/event-listener/status.enum.d.ts +81 -0
- package/src/lib/features/event-listener/status.interface.d.ts +40 -0
- package/src/lib/features/event-listener/status.service.d.ts +4 -0
- package/src/lib/features/event-listener/tracking-event.d.ts +22 -0
- package/src/lib/features/index.d.ts +1 -0
- package/src/lib/translate/translate.d.ts +1 -0
package/index.cjs
CHANGED
|
@@ -14,6 +14,10 @@ require('core-js/modules/es.symbol.description.js');
|
|
|
14
14
|
require('core-js/modules/es.regexp.exec.js');
|
|
15
15
|
require('core-js/modules/es.string.replace.js');
|
|
16
16
|
require('core-js/modules/es.regexp.constructor.js');
|
|
17
|
+
var rxjs = require('rxjs');
|
|
18
|
+
var operators = require('rxjs/operators');
|
|
19
|
+
var uuid = require('uuid');
|
|
20
|
+
require('core-js/modules/es.string.ends-with.js');
|
|
17
21
|
|
|
18
22
|
function core() {
|
|
19
23
|
return 'core';
|
|
@@ -45,7 +49,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
var name = "@authme/core";
|
|
48
|
-
var version$1 = "2.
|
|
52
|
+
var version$1 = "2.4.2";
|
|
49
53
|
var peerDependencies = {
|
|
50
54
|
"core-js": "^3.6.0"
|
|
51
55
|
};
|
|
@@ -147,6 +151,20 @@ function sendRequest(url, method = 'GET', {
|
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
if (errorMessages.length !== 0) {
|
|
154
|
+
// 5XX
|
|
155
|
+
if (resp.status >= 500 && resp.status < 600 && resp.status !== 503 && resp.status !== 504) {
|
|
156
|
+
throw new util.AuthmeError(util.ErrorCode.SERVER_ERROR, {
|
|
157
|
+
errorMessages,
|
|
158
|
+
meta: {
|
|
159
|
+
status: resp.status,
|
|
160
|
+
ok: resp.ok,
|
|
161
|
+
url,
|
|
162
|
+
responseContentType,
|
|
163
|
+
responseContent,
|
|
164
|
+
parsedError
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
150
168
|
throw new util.AuthmeError(util.ErrorCode.HTTP_ERROR_RESPONSE, {
|
|
151
169
|
errorMessages,
|
|
152
170
|
meta: {
|
|
@@ -167,13 +185,14 @@ exports.AuthmeLanguage = void 0;
|
|
|
167
185
|
(function (AuthmeLanguage) {
|
|
168
186
|
AuthmeLanguage["zh-TW"] = "zh_Hant_TW";
|
|
169
187
|
AuthmeLanguage["en-US"] = "en_US";
|
|
188
|
+
AuthmeLanguage["ja-JP"] = "ja_JP";
|
|
170
189
|
})(exports.AuthmeLanguage || (exports.AuthmeLanguage = {}));
|
|
171
190
|
|
|
172
191
|
class TranslateService {
|
|
173
192
|
constructor() {
|
|
174
193
|
this.originalDict = {};
|
|
175
194
|
this.customDict = {};
|
|
176
|
-
this.languageOptions = [exports.AuthmeLanguage['zh-TW'], exports.AuthmeLanguage['en-US']];
|
|
195
|
+
this.languageOptions = [exports.AuthmeLanguage['zh-TW'], exports.AuthmeLanguage['en-US'], exports.AuthmeLanguage['ja-JP']];
|
|
177
196
|
this.currentLang = exports.AuthmeLanguage['zh-TW'];
|
|
178
197
|
}
|
|
179
198
|
fetchSource(path) {
|
|
@@ -204,12 +223,18 @@ class TranslateService {
|
|
|
204
223
|
translate(key, args = {}) {
|
|
205
224
|
var _a, _b, _c, _d;
|
|
206
225
|
let str = (_d = (_b = (_a = this.customDict[this.currentLang]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = this.originalDict[this.currentLang]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : key;
|
|
226
|
+
if (!str) {
|
|
227
|
+
return '';
|
|
228
|
+
}
|
|
207
229
|
if (Object.keys(args).length > 0) {
|
|
208
230
|
Object.keys(args).forEach(key => {
|
|
209
231
|
str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
|
|
210
232
|
});
|
|
211
233
|
}
|
|
212
|
-
return str;
|
|
234
|
+
return str.replace(/\\n/g, ' \n');
|
|
235
|
+
}
|
|
236
|
+
getCurrentLang() {
|
|
237
|
+
return this.currentLang;
|
|
213
238
|
}
|
|
214
239
|
}
|
|
215
240
|
TranslateService.instance = null;
|
|
@@ -220,6 +245,319 @@ function getTranslateInstance() {
|
|
|
220
245
|
return TranslateService.instance;
|
|
221
246
|
}
|
|
222
247
|
|
|
248
|
+
class MockApiService {
|
|
249
|
+
constructor() {
|
|
250
|
+
this.data = [];
|
|
251
|
+
}
|
|
252
|
+
postStatus(status) {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
+
this.data.push(status);
|
|
255
|
+
return Promise.resolve(status);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
postMutiStatus(status) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
+
this.data.push(...status);
|
|
261
|
+
return Promise.resolve(status);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
getStatus() {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
return Promise.resolve(this.data);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function sendEventLogging(events, pingMethod) {
|
|
272
|
+
var _a;
|
|
273
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
274
|
+
if (util.Storage.getItem(util.STORAGE_KEY.ENABLE_EVENT_TRACKING) === false) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const logs = events.filter(event => event.customerId !== '').map(event => {
|
|
278
|
+
return {
|
|
279
|
+
message: event,
|
|
280
|
+
createTime: event.userTime
|
|
281
|
+
};
|
|
282
|
+
});
|
|
283
|
+
const pingEvent = yield pingMethod();
|
|
284
|
+
const newLog = [{
|
|
285
|
+
message: pingEvent,
|
|
286
|
+
createTime: pingEvent.userTime
|
|
287
|
+
}, ...logs];
|
|
288
|
+
return sendRequest('/api/event-logging/v1/log/ekyc-sdk', 'POST', {
|
|
289
|
+
body: JSON.stringify({
|
|
290
|
+
logs: newLog
|
|
291
|
+
}),
|
|
292
|
+
baseUrl: (_a = util.Storage.getItem(util.STORAGE_KEY.EVENT_TRACK_URL)) !== null && _a !== void 0 ? _a : util.Storage.getItem(util.STORAGE_KEY.API_BASE_URL)
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const initialStatus = {
|
|
298
|
+
eventId: '',
|
|
299
|
+
sessionId: '',
|
|
300
|
+
eventType: '',
|
|
301
|
+
userTime: new Date().toISOString(),
|
|
302
|
+
tenantId: '',
|
|
303
|
+
customerId: '',
|
|
304
|
+
duration: 0,
|
|
305
|
+
deviceInfo: '',
|
|
306
|
+
systemInfo: '',
|
|
307
|
+
version: '1.0.0',
|
|
308
|
+
language: '',
|
|
309
|
+
description: 'description',
|
|
310
|
+
platform: 'Web',
|
|
311
|
+
extraInfo: 'extra info'
|
|
312
|
+
};
|
|
313
|
+
const BUFFER_TINTERVAL = 3000;
|
|
314
|
+
class EventListenerService {
|
|
315
|
+
constructor(getStatusProcess, options) {
|
|
316
|
+
var _a;
|
|
317
|
+
this.getStatusProcess = getStatusProcess;
|
|
318
|
+
this.apiService = new MockApiService();
|
|
319
|
+
this.pingInterval = (_a = options === null || options === void 0 ? void 0 : options.pingInterval) !== null && _a !== void 0 ? _a : BUFFER_TINTERVAL;
|
|
320
|
+
this.statusSubject = new rxjs.BehaviorSubject(initialStatus);
|
|
321
|
+
}
|
|
322
|
+
start() {
|
|
323
|
+
this.statusSubject = new rxjs.BehaviorSubject(initialStatus);
|
|
324
|
+
this.statusSubject.pipe(operators.bufferTime(this.pingInterval), operators.filter(() => util.Storage.getItem(util.STORAGE_KEY.ENABLE_EVENT_TRACKING) === true), operators.mergeMap(events => {
|
|
325
|
+
sendEventLogging(events, this.getStatusProcess);
|
|
326
|
+
return events;
|
|
327
|
+
})).subscribe();
|
|
328
|
+
}
|
|
329
|
+
stop() {
|
|
330
|
+
if (this.pingSubscription) {
|
|
331
|
+
this.pingSubscription.unsubscribe();
|
|
332
|
+
this.pingSubscription = undefined;
|
|
333
|
+
}
|
|
334
|
+
this.statusSubject.complete();
|
|
335
|
+
}
|
|
336
|
+
sendUserActionStatus(status) {
|
|
337
|
+
this.statusSubject.next(status);
|
|
338
|
+
return this.sendStatus(status);
|
|
339
|
+
}
|
|
340
|
+
sendStatus(status) {
|
|
341
|
+
return this.apiService.postStatus(status);
|
|
342
|
+
}
|
|
343
|
+
getStatusObservable() {
|
|
344
|
+
return this.statusSubject;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
exports.Feature = void 0;
|
|
349
|
+
(function (Feature) {
|
|
350
|
+
Feature["OCRFraud"] = "OCRFraud";
|
|
351
|
+
Feature["OCR"] = "OCR";
|
|
352
|
+
Feature["SelectCardTypeAndCountry"] = "SelectCardTypeAndCountry";
|
|
353
|
+
Feature["LivenessActive"] = "LivenessActive";
|
|
354
|
+
Feature["LivenessPassive"] = "LivenessPassive";
|
|
355
|
+
})(exports.Feature || (exports.Feature = {}));
|
|
356
|
+
exports.StatusEvent = void 0;
|
|
357
|
+
(function (StatusEvent) {
|
|
358
|
+
StatusEvent["TWID"] = "TWID";
|
|
359
|
+
StatusEvent["TWIDFraud"] = "TWIDFraud";
|
|
360
|
+
StatusEvent["TWIDFront"] = "TWIDFront";
|
|
361
|
+
StatusEvent["TWDriverLicenseFront"] = "TWDriverLicenseFront";
|
|
362
|
+
StatusEvent["Passport"] = "Passport";
|
|
363
|
+
StatusEvent["ResidencePermitFront"] = "ResidencePermitFront";
|
|
364
|
+
StatusEvent["ResidencePermitBack"] = "ResidencePermitBack";
|
|
365
|
+
StatusEvent["TWIDBack"] = "TWIDBack";
|
|
366
|
+
StatusEvent["TWDriverLicenseBack"] = "TWDriverLicenseBack";
|
|
367
|
+
StatusEvent["TWHealthCardFront"] = "TWHealthCardFront";
|
|
368
|
+
StatusEvent["TWDriverLicense"] = "TWDriverLicense";
|
|
369
|
+
StatusEvent["TWHealthCard"] = "TWHealthCard";
|
|
370
|
+
StatusEvent["ResidencePermit"] = "ResidencePermit";
|
|
371
|
+
StatusEvent["PassportFront"] = "PassportFront";
|
|
372
|
+
StatusEvent["OpenMouth"] = "OpenMouth";
|
|
373
|
+
StatusEvent["CloseMouth"] = "CloseMouth";
|
|
374
|
+
StatusEvent["Smile"] = "Smile";
|
|
375
|
+
StatusEvent["Scale"] = "Scale";
|
|
376
|
+
StatusEvent["Done"] = "Done";
|
|
377
|
+
StatusEvent["Passive"] = "Passive";
|
|
378
|
+
StatusEvent["SelectCardTypeAndCountry"] = "SelectCardTypeAndCountry";
|
|
379
|
+
})(exports.StatusEvent || (exports.StatusEvent = {}));
|
|
380
|
+
exports.StatusView = void 0;
|
|
381
|
+
(function (StatusView) {
|
|
382
|
+
StatusView["Info"] = "Info";
|
|
383
|
+
StatusView["Init"] = "Init";
|
|
384
|
+
StatusView["Aligning"] = "Aligning";
|
|
385
|
+
StatusView["Start"] = "Start";
|
|
386
|
+
StatusView["Up"] = "Up";
|
|
387
|
+
StatusView["Down"] = "Down";
|
|
388
|
+
StatusView["Left"] = "Left";
|
|
389
|
+
StatusView["Right"] = "Right";
|
|
390
|
+
StatusView["Running"] = "Running";
|
|
391
|
+
StatusView["Confirm"] = "Confirm";
|
|
392
|
+
StatusView["Uploading"] = "Uploading";
|
|
393
|
+
StatusView["Select"] = "Select";
|
|
394
|
+
})(exports.StatusView || (exports.StatusView = {}));
|
|
395
|
+
exports.StatusAction = void 0;
|
|
396
|
+
(function (StatusAction) {
|
|
397
|
+
StatusAction["Uploading"] = "Uploading";
|
|
398
|
+
StatusAction["Show"] = "Show";
|
|
399
|
+
StatusAction["BtnClose"] = "BtnClose";
|
|
400
|
+
StatusAction["BtnStart"] = "BtnStart";
|
|
401
|
+
StatusAction["InitError"] = "InitError";
|
|
402
|
+
StatusAction["Start"] = "Start";
|
|
403
|
+
StatusAction["Confirm"] = "Confirm";
|
|
404
|
+
StatusAction["Retry"] = "Retry";
|
|
405
|
+
})(exports.StatusAction || (exports.StatusAction = {}));
|
|
406
|
+
exports.StatusDescription = void 0;
|
|
407
|
+
(function (StatusDescription) {
|
|
408
|
+
StatusDescription["NoCard"] = "NoCard";
|
|
409
|
+
StatusDescription["WrongCardType"] = "WrongCardType";
|
|
410
|
+
StatusDescription["PositionNotMatch"] = "PositionNotMatch";
|
|
411
|
+
StatusDescription["Reflective"] = "Reflective";
|
|
412
|
+
StatusDescription["Blur"] = "Blur";
|
|
413
|
+
StatusDescription["Pass"] = "Pass";
|
|
414
|
+
StatusDescription["Error"] = "Error";
|
|
415
|
+
StatusDescription["Failed"] = "Failed";
|
|
416
|
+
StatusDescription["Timeout"] = "Timeout";
|
|
417
|
+
StatusDescription["Gray"] = "Gray";
|
|
418
|
+
StatusDescription["NeedMoreFrame"] = "NeedMoreFrame";
|
|
419
|
+
StatusDescription["NotAligned"] = "NotAligned";
|
|
420
|
+
StatusDescription["NoFace"] = "NoFace";
|
|
421
|
+
StatusDescription["FaceNotAtCenter"] = "FaceNotAtCenter";
|
|
422
|
+
StatusDescription["FaceTooSmall"] = "FaceTooSmall";
|
|
423
|
+
StatusDescription["FaceTooLarge"] = "FaceTooLarge";
|
|
424
|
+
StatusDescription["NeedFaceToCamera"] = "NeedFaceToCamera";
|
|
425
|
+
StatusDescription["FaceMasked"] = "FaceMasked";
|
|
426
|
+
StatusDescription["NeedOpenMouth"] = "NeedOpenMouth";
|
|
427
|
+
StatusDescription["NeedCloseMouth"] = "NeedCloseMouth";
|
|
428
|
+
StatusDescription["NeedSmile"] = "NeedSmile";
|
|
429
|
+
StatusDescription["NeedOpenEyes"] = "NeedOpenEyes";
|
|
430
|
+
StatusDescription["UploadingStart"] = "UploadingStart";
|
|
431
|
+
StatusDescription["UploadingEnd"] = "UploadingEnd";
|
|
432
|
+
StatusDescription["Complete"] = "Complete";
|
|
433
|
+
})(exports.StatusDescription || (exports.StatusDescription = {}));
|
|
434
|
+
|
|
435
|
+
class TrackingEvent {
|
|
436
|
+
constructor(params) {
|
|
437
|
+
this._feature = params.feature;
|
|
438
|
+
this._event = params.event;
|
|
439
|
+
this._view = params.view;
|
|
440
|
+
this._action = params.action;
|
|
441
|
+
this._description = params.description;
|
|
442
|
+
}
|
|
443
|
+
nonNull(data) {
|
|
444
|
+
return data !== null && data !== undefined;
|
|
445
|
+
}
|
|
446
|
+
get feature() {
|
|
447
|
+
return this._feature;
|
|
448
|
+
}
|
|
449
|
+
set feature(value) {
|
|
450
|
+
if (value && !(value in exports.Feature)) {
|
|
451
|
+
throw new Error('Invalid feature');
|
|
452
|
+
}
|
|
453
|
+
this._feature = value;
|
|
454
|
+
}
|
|
455
|
+
get event() {
|
|
456
|
+
return this._event;
|
|
457
|
+
}
|
|
458
|
+
set event(value) {
|
|
459
|
+
if (value && !(value in exports.StatusEvent)) {
|
|
460
|
+
throw new Error('Invalid event');
|
|
461
|
+
}
|
|
462
|
+
this._event = value;
|
|
463
|
+
}
|
|
464
|
+
get view() {
|
|
465
|
+
return this._view;
|
|
466
|
+
}
|
|
467
|
+
set view(value) {
|
|
468
|
+
if (value && !(value in exports.StatusView)) {
|
|
469
|
+
throw new Error('Invalid view');
|
|
470
|
+
}
|
|
471
|
+
this._view = value;
|
|
472
|
+
}
|
|
473
|
+
get action() {
|
|
474
|
+
return this._action;
|
|
475
|
+
}
|
|
476
|
+
set action(value) {
|
|
477
|
+
if (value && !(value in exports.StatusAction)) {
|
|
478
|
+
throw new Error('Invalid action');
|
|
479
|
+
}
|
|
480
|
+
this._action = value;
|
|
481
|
+
}
|
|
482
|
+
get description() {
|
|
483
|
+
return this._description;
|
|
484
|
+
}
|
|
485
|
+
set description(value) {
|
|
486
|
+
if (value && !(value in exports.StatusDescription)) {
|
|
487
|
+
throw new Error('Invalid description');
|
|
488
|
+
}
|
|
489
|
+
this._description = value;
|
|
490
|
+
}
|
|
491
|
+
toString() {
|
|
492
|
+
let result = '';
|
|
493
|
+
if (this.nonNull(this._feature)) {
|
|
494
|
+
result += `${this._feature}:`;
|
|
495
|
+
}
|
|
496
|
+
if (this.nonNull(this._event)) {
|
|
497
|
+
result += `${this._event}:`;
|
|
498
|
+
}
|
|
499
|
+
if (this.nonNull(this._view)) {
|
|
500
|
+
result += `${this._view}:`;
|
|
501
|
+
}
|
|
502
|
+
if (this.nonNull(this._action)) {
|
|
503
|
+
result += `${this._action}:`;
|
|
504
|
+
}
|
|
505
|
+
if (this.nonNull(this._description)) {
|
|
506
|
+
result += `${this._description}`;
|
|
507
|
+
}
|
|
508
|
+
if (result.endsWith(':')) {
|
|
509
|
+
result = result.slice(0, -1); // 刪除最後一個字符
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return result;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const tokenSubject = new rxjs.BehaviorSubject('');
|
|
517
|
+
tokenSubject.pipe(rxjs.tap(token => {
|
|
518
|
+
if (!token) return;
|
|
519
|
+
const _jwt = util.decodeToken(token);
|
|
520
|
+
setAuthmeJWT(_jwt.payload);
|
|
521
|
+
})).subscribe();
|
|
522
|
+
const defaultEventName = new TrackingEvent({});
|
|
523
|
+
const [getAuthmeJWT, setAuthmeJWT] = util.useState();
|
|
524
|
+
const [getAccessToken, setAccessToken] = util.useState('', tokenSubject);
|
|
525
|
+
const [getSessionId, setSessionId] = util.useState('');
|
|
526
|
+
function generateStatus(params = {}) {
|
|
527
|
+
const _authmeJWT = getAuthmeJWT();
|
|
528
|
+
const {
|
|
529
|
+
eventType = defaultEventName,
|
|
530
|
+
sessionId = getSessionId(),
|
|
531
|
+
userTime = new Date().toISOString(),
|
|
532
|
+
tenantId = _authmeJWT.client_tenant,
|
|
533
|
+
customerId = _authmeJWT.client_id,
|
|
534
|
+
duration = 0,
|
|
535
|
+
deviceInfo = util.getDeviceInfo(),
|
|
536
|
+
systemInfo = util.getSystemInfo(),
|
|
537
|
+
version: version$1 = version,
|
|
538
|
+
language = '',
|
|
539
|
+
description = '',
|
|
540
|
+
platform = 'web',
|
|
541
|
+
extraInfo = ''
|
|
542
|
+
} = params;
|
|
543
|
+
return {
|
|
544
|
+
eventId: uuid.v4(),
|
|
545
|
+
eventType: eventType.toString(),
|
|
546
|
+
sessionId,
|
|
547
|
+
userTime,
|
|
548
|
+
tenantId,
|
|
549
|
+
customerId,
|
|
550
|
+
duration,
|
|
551
|
+
deviceInfo,
|
|
552
|
+
systemInfo,
|
|
553
|
+
version: version$1,
|
|
554
|
+
language,
|
|
555
|
+
description,
|
|
556
|
+
platform,
|
|
557
|
+
extraInfo
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
223
561
|
Object.defineProperty(exports, 'AuthmeError', {
|
|
224
562
|
enumerable: true,
|
|
225
563
|
get: function () { return util.AuthmeError; }
|
|
@@ -232,7 +570,14 @@ Object.defineProperty(exports, 'debugLog', {
|
|
|
232
570
|
enumerable: true,
|
|
233
571
|
get: function () { return util.debugLog; }
|
|
234
572
|
});
|
|
573
|
+
exports.EventListenerService = EventListenerService;
|
|
574
|
+
exports.TrackingEvent = TrackingEvent;
|
|
235
575
|
exports.core = core;
|
|
576
|
+
exports.generateStatus = generateStatus;
|
|
577
|
+
exports.getAccessToken = getAccessToken;
|
|
578
|
+
exports.getSessionId = getSessionId;
|
|
236
579
|
exports.getTranslateInstance = getTranslateInstance;
|
|
237
580
|
exports.sendRequest = sendRequest;
|
|
581
|
+
exports.setAccessToken = setAccessToken;
|
|
582
|
+
exports.setSessionId = setSessionId;
|
|
238
583
|
exports.version = version;
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Storage, getUserAgent, AuthmeError, ErrorCode } from '@authme/util';
|
|
1
|
+
import { Storage, getUserAgent, AuthmeError, ErrorCode, STORAGE_KEY, decodeToken, useState, getDeviceInfo, getSystemInfo } from '@authme/util';
|
|
2
2
|
export { AuthmeError, ErrorCode, debugLog } from '@authme/util';
|
|
3
3
|
import 'core-js/modules/es.object.assign.js';
|
|
4
4
|
import 'core-js/modules/es.regexp.to-string.js';
|
|
@@ -11,6 +11,10 @@ import 'core-js/modules/es.symbol.description.js';
|
|
|
11
11
|
import 'core-js/modules/es.regexp.exec.js';
|
|
12
12
|
import 'core-js/modules/es.string.replace.js';
|
|
13
13
|
import 'core-js/modules/es.regexp.constructor.js';
|
|
14
|
+
import { BehaviorSubject, tap } from 'rxjs';
|
|
15
|
+
import { bufferTime, filter, mergeMap } from 'rxjs/operators';
|
|
16
|
+
import { v4 } from 'uuid';
|
|
17
|
+
import 'core-js/modules/es.string.ends-with.js';
|
|
14
18
|
|
|
15
19
|
function core() {
|
|
16
20
|
return 'core';
|
|
@@ -42,7 +46,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
var name = "@authme/core";
|
|
45
|
-
var version$1 = "2.
|
|
49
|
+
var version$1 = "2.4.2";
|
|
46
50
|
var peerDependencies = {
|
|
47
51
|
"core-js": "^3.6.0"
|
|
48
52
|
};
|
|
@@ -144,6 +148,20 @@ function sendRequest(url, method = 'GET', {
|
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
if (errorMessages.length !== 0) {
|
|
151
|
+
// 5XX
|
|
152
|
+
if (resp.status >= 500 && resp.status < 600 && resp.status !== 503 && resp.status !== 504) {
|
|
153
|
+
throw new AuthmeError(ErrorCode.SERVER_ERROR, {
|
|
154
|
+
errorMessages,
|
|
155
|
+
meta: {
|
|
156
|
+
status: resp.status,
|
|
157
|
+
ok: resp.ok,
|
|
158
|
+
url,
|
|
159
|
+
responseContentType,
|
|
160
|
+
responseContent,
|
|
161
|
+
parsedError
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
147
165
|
throw new AuthmeError(ErrorCode.HTTP_ERROR_RESPONSE, {
|
|
148
166
|
errorMessages,
|
|
149
167
|
meta: {
|
|
@@ -164,13 +182,14 @@ var AuthmeLanguage;
|
|
|
164
182
|
(function (AuthmeLanguage) {
|
|
165
183
|
AuthmeLanguage["zh-TW"] = "zh_Hant_TW";
|
|
166
184
|
AuthmeLanguage["en-US"] = "en_US";
|
|
185
|
+
AuthmeLanguage["ja-JP"] = "ja_JP";
|
|
167
186
|
})(AuthmeLanguage || (AuthmeLanguage = {}));
|
|
168
187
|
|
|
169
188
|
class TranslateService {
|
|
170
189
|
constructor() {
|
|
171
190
|
this.originalDict = {};
|
|
172
191
|
this.customDict = {};
|
|
173
|
-
this.languageOptions = [AuthmeLanguage['zh-TW'], AuthmeLanguage['en-US']];
|
|
192
|
+
this.languageOptions = [AuthmeLanguage['zh-TW'], AuthmeLanguage['en-US'], AuthmeLanguage['ja-JP']];
|
|
174
193
|
this.currentLang = AuthmeLanguage['zh-TW'];
|
|
175
194
|
}
|
|
176
195
|
fetchSource(path) {
|
|
@@ -201,12 +220,18 @@ class TranslateService {
|
|
|
201
220
|
translate(key, args = {}) {
|
|
202
221
|
var _a, _b, _c, _d;
|
|
203
222
|
let str = (_d = (_b = (_a = this.customDict[this.currentLang]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = this.originalDict[this.currentLang]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : key;
|
|
223
|
+
if (!str) {
|
|
224
|
+
return '';
|
|
225
|
+
}
|
|
204
226
|
if (Object.keys(args).length > 0) {
|
|
205
227
|
Object.keys(args).forEach(key => {
|
|
206
228
|
str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
|
|
207
229
|
});
|
|
208
230
|
}
|
|
209
|
-
return str;
|
|
231
|
+
return str.replace(/\\n/g, ' \n');
|
|
232
|
+
}
|
|
233
|
+
getCurrentLang() {
|
|
234
|
+
return this.currentLang;
|
|
210
235
|
}
|
|
211
236
|
}
|
|
212
237
|
TranslateService.instance = null;
|
|
@@ -217,4 +242,317 @@ function getTranslateInstance() {
|
|
|
217
242
|
return TranslateService.instance;
|
|
218
243
|
}
|
|
219
244
|
|
|
220
|
-
|
|
245
|
+
class MockApiService {
|
|
246
|
+
constructor() {
|
|
247
|
+
this.data = [];
|
|
248
|
+
}
|
|
249
|
+
postStatus(status) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
this.data.push(status);
|
|
252
|
+
return Promise.resolve(status);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
postMutiStatus(status) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
this.data.push(...status);
|
|
258
|
+
return Promise.resolve(status);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
getStatus() {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
return Promise.resolve(this.data);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function sendEventLogging(events, pingMethod) {
|
|
269
|
+
var _a;
|
|
270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
+
if (Storage.getItem(STORAGE_KEY.ENABLE_EVENT_TRACKING) === false) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const logs = events.filter(event => event.customerId !== '').map(event => {
|
|
275
|
+
return {
|
|
276
|
+
message: event,
|
|
277
|
+
createTime: event.userTime
|
|
278
|
+
};
|
|
279
|
+
});
|
|
280
|
+
const pingEvent = yield pingMethod();
|
|
281
|
+
const newLog = [{
|
|
282
|
+
message: pingEvent,
|
|
283
|
+
createTime: pingEvent.userTime
|
|
284
|
+
}, ...logs];
|
|
285
|
+
return sendRequest('/api/event-logging/v1/log/ekyc-sdk', 'POST', {
|
|
286
|
+
body: JSON.stringify({
|
|
287
|
+
logs: newLog
|
|
288
|
+
}),
|
|
289
|
+
baseUrl: (_a = Storage.getItem(STORAGE_KEY.EVENT_TRACK_URL)) !== null && _a !== void 0 ? _a : Storage.getItem(STORAGE_KEY.API_BASE_URL)
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const initialStatus = {
|
|
295
|
+
eventId: '',
|
|
296
|
+
sessionId: '',
|
|
297
|
+
eventType: '',
|
|
298
|
+
userTime: new Date().toISOString(),
|
|
299
|
+
tenantId: '',
|
|
300
|
+
customerId: '',
|
|
301
|
+
duration: 0,
|
|
302
|
+
deviceInfo: '',
|
|
303
|
+
systemInfo: '',
|
|
304
|
+
version: '1.0.0',
|
|
305
|
+
language: '',
|
|
306
|
+
description: 'description',
|
|
307
|
+
platform: 'Web',
|
|
308
|
+
extraInfo: 'extra info'
|
|
309
|
+
};
|
|
310
|
+
const BUFFER_TINTERVAL = 3000;
|
|
311
|
+
class EventListenerService {
|
|
312
|
+
constructor(getStatusProcess, options) {
|
|
313
|
+
var _a;
|
|
314
|
+
this.getStatusProcess = getStatusProcess;
|
|
315
|
+
this.apiService = new MockApiService();
|
|
316
|
+
this.pingInterval = (_a = options === null || options === void 0 ? void 0 : options.pingInterval) !== null && _a !== void 0 ? _a : BUFFER_TINTERVAL;
|
|
317
|
+
this.statusSubject = new BehaviorSubject(initialStatus);
|
|
318
|
+
}
|
|
319
|
+
start() {
|
|
320
|
+
this.statusSubject = new BehaviorSubject(initialStatus);
|
|
321
|
+
this.statusSubject.pipe(bufferTime(this.pingInterval), filter(() => Storage.getItem(STORAGE_KEY.ENABLE_EVENT_TRACKING) === true), mergeMap(events => {
|
|
322
|
+
sendEventLogging(events, this.getStatusProcess);
|
|
323
|
+
return events;
|
|
324
|
+
})).subscribe();
|
|
325
|
+
}
|
|
326
|
+
stop() {
|
|
327
|
+
if (this.pingSubscription) {
|
|
328
|
+
this.pingSubscription.unsubscribe();
|
|
329
|
+
this.pingSubscription = undefined;
|
|
330
|
+
}
|
|
331
|
+
this.statusSubject.complete();
|
|
332
|
+
}
|
|
333
|
+
sendUserActionStatus(status) {
|
|
334
|
+
this.statusSubject.next(status);
|
|
335
|
+
return this.sendStatus(status);
|
|
336
|
+
}
|
|
337
|
+
sendStatus(status) {
|
|
338
|
+
return this.apiService.postStatus(status);
|
|
339
|
+
}
|
|
340
|
+
getStatusObservable() {
|
|
341
|
+
return this.statusSubject;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
var Feature;
|
|
346
|
+
(function (Feature) {
|
|
347
|
+
Feature["OCRFraud"] = "OCRFraud";
|
|
348
|
+
Feature["OCR"] = "OCR";
|
|
349
|
+
Feature["SelectCardTypeAndCountry"] = "SelectCardTypeAndCountry";
|
|
350
|
+
Feature["LivenessActive"] = "LivenessActive";
|
|
351
|
+
Feature["LivenessPassive"] = "LivenessPassive";
|
|
352
|
+
})(Feature || (Feature = {}));
|
|
353
|
+
var StatusEvent;
|
|
354
|
+
(function (StatusEvent) {
|
|
355
|
+
StatusEvent["TWID"] = "TWID";
|
|
356
|
+
StatusEvent["TWIDFraud"] = "TWIDFraud";
|
|
357
|
+
StatusEvent["TWIDFront"] = "TWIDFront";
|
|
358
|
+
StatusEvent["TWDriverLicenseFront"] = "TWDriverLicenseFront";
|
|
359
|
+
StatusEvent["Passport"] = "Passport";
|
|
360
|
+
StatusEvent["ResidencePermitFront"] = "ResidencePermitFront";
|
|
361
|
+
StatusEvent["ResidencePermitBack"] = "ResidencePermitBack";
|
|
362
|
+
StatusEvent["TWIDBack"] = "TWIDBack";
|
|
363
|
+
StatusEvent["TWDriverLicenseBack"] = "TWDriverLicenseBack";
|
|
364
|
+
StatusEvent["TWHealthCardFront"] = "TWHealthCardFront";
|
|
365
|
+
StatusEvent["TWDriverLicense"] = "TWDriverLicense";
|
|
366
|
+
StatusEvent["TWHealthCard"] = "TWHealthCard";
|
|
367
|
+
StatusEvent["ResidencePermit"] = "ResidencePermit";
|
|
368
|
+
StatusEvent["PassportFront"] = "PassportFront";
|
|
369
|
+
StatusEvent["OpenMouth"] = "OpenMouth";
|
|
370
|
+
StatusEvent["CloseMouth"] = "CloseMouth";
|
|
371
|
+
StatusEvent["Smile"] = "Smile";
|
|
372
|
+
StatusEvent["Scale"] = "Scale";
|
|
373
|
+
StatusEvent["Done"] = "Done";
|
|
374
|
+
StatusEvent["Passive"] = "Passive";
|
|
375
|
+
StatusEvent["SelectCardTypeAndCountry"] = "SelectCardTypeAndCountry";
|
|
376
|
+
})(StatusEvent || (StatusEvent = {}));
|
|
377
|
+
var StatusView;
|
|
378
|
+
(function (StatusView) {
|
|
379
|
+
StatusView["Info"] = "Info";
|
|
380
|
+
StatusView["Init"] = "Init";
|
|
381
|
+
StatusView["Aligning"] = "Aligning";
|
|
382
|
+
StatusView["Start"] = "Start";
|
|
383
|
+
StatusView["Up"] = "Up";
|
|
384
|
+
StatusView["Down"] = "Down";
|
|
385
|
+
StatusView["Left"] = "Left";
|
|
386
|
+
StatusView["Right"] = "Right";
|
|
387
|
+
StatusView["Running"] = "Running";
|
|
388
|
+
StatusView["Confirm"] = "Confirm";
|
|
389
|
+
StatusView["Uploading"] = "Uploading";
|
|
390
|
+
StatusView["Select"] = "Select";
|
|
391
|
+
})(StatusView || (StatusView = {}));
|
|
392
|
+
var StatusAction;
|
|
393
|
+
(function (StatusAction) {
|
|
394
|
+
StatusAction["Uploading"] = "Uploading";
|
|
395
|
+
StatusAction["Show"] = "Show";
|
|
396
|
+
StatusAction["BtnClose"] = "BtnClose";
|
|
397
|
+
StatusAction["BtnStart"] = "BtnStart";
|
|
398
|
+
StatusAction["InitError"] = "InitError";
|
|
399
|
+
StatusAction["Start"] = "Start";
|
|
400
|
+
StatusAction["Confirm"] = "Confirm";
|
|
401
|
+
StatusAction["Retry"] = "Retry";
|
|
402
|
+
})(StatusAction || (StatusAction = {}));
|
|
403
|
+
var StatusDescription;
|
|
404
|
+
(function (StatusDescription) {
|
|
405
|
+
StatusDescription["NoCard"] = "NoCard";
|
|
406
|
+
StatusDescription["WrongCardType"] = "WrongCardType";
|
|
407
|
+
StatusDescription["PositionNotMatch"] = "PositionNotMatch";
|
|
408
|
+
StatusDescription["Reflective"] = "Reflective";
|
|
409
|
+
StatusDescription["Blur"] = "Blur";
|
|
410
|
+
StatusDescription["Pass"] = "Pass";
|
|
411
|
+
StatusDescription["Error"] = "Error";
|
|
412
|
+
StatusDescription["Failed"] = "Failed";
|
|
413
|
+
StatusDescription["Timeout"] = "Timeout";
|
|
414
|
+
StatusDescription["Gray"] = "Gray";
|
|
415
|
+
StatusDescription["NeedMoreFrame"] = "NeedMoreFrame";
|
|
416
|
+
StatusDescription["NotAligned"] = "NotAligned";
|
|
417
|
+
StatusDescription["NoFace"] = "NoFace";
|
|
418
|
+
StatusDescription["FaceNotAtCenter"] = "FaceNotAtCenter";
|
|
419
|
+
StatusDescription["FaceTooSmall"] = "FaceTooSmall";
|
|
420
|
+
StatusDescription["FaceTooLarge"] = "FaceTooLarge";
|
|
421
|
+
StatusDescription["NeedFaceToCamera"] = "NeedFaceToCamera";
|
|
422
|
+
StatusDescription["FaceMasked"] = "FaceMasked";
|
|
423
|
+
StatusDescription["NeedOpenMouth"] = "NeedOpenMouth";
|
|
424
|
+
StatusDescription["NeedCloseMouth"] = "NeedCloseMouth";
|
|
425
|
+
StatusDescription["NeedSmile"] = "NeedSmile";
|
|
426
|
+
StatusDescription["NeedOpenEyes"] = "NeedOpenEyes";
|
|
427
|
+
StatusDescription["UploadingStart"] = "UploadingStart";
|
|
428
|
+
StatusDescription["UploadingEnd"] = "UploadingEnd";
|
|
429
|
+
StatusDescription["Complete"] = "Complete";
|
|
430
|
+
})(StatusDescription || (StatusDescription = {}));
|
|
431
|
+
|
|
432
|
+
class TrackingEvent {
|
|
433
|
+
constructor(params) {
|
|
434
|
+
this._feature = params.feature;
|
|
435
|
+
this._event = params.event;
|
|
436
|
+
this._view = params.view;
|
|
437
|
+
this._action = params.action;
|
|
438
|
+
this._description = params.description;
|
|
439
|
+
}
|
|
440
|
+
nonNull(data) {
|
|
441
|
+
return data !== null && data !== undefined;
|
|
442
|
+
}
|
|
443
|
+
get feature() {
|
|
444
|
+
return this._feature;
|
|
445
|
+
}
|
|
446
|
+
set feature(value) {
|
|
447
|
+
if (value && !(value in Feature)) {
|
|
448
|
+
throw new Error('Invalid feature');
|
|
449
|
+
}
|
|
450
|
+
this._feature = value;
|
|
451
|
+
}
|
|
452
|
+
get event() {
|
|
453
|
+
return this._event;
|
|
454
|
+
}
|
|
455
|
+
set event(value) {
|
|
456
|
+
if (value && !(value in StatusEvent)) {
|
|
457
|
+
throw new Error('Invalid event');
|
|
458
|
+
}
|
|
459
|
+
this._event = value;
|
|
460
|
+
}
|
|
461
|
+
get view() {
|
|
462
|
+
return this._view;
|
|
463
|
+
}
|
|
464
|
+
set view(value) {
|
|
465
|
+
if (value && !(value in StatusView)) {
|
|
466
|
+
throw new Error('Invalid view');
|
|
467
|
+
}
|
|
468
|
+
this._view = value;
|
|
469
|
+
}
|
|
470
|
+
get action() {
|
|
471
|
+
return this._action;
|
|
472
|
+
}
|
|
473
|
+
set action(value) {
|
|
474
|
+
if (value && !(value in StatusAction)) {
|
|
475
|
+
throw new Error('Invalid action');
|
|
476
|
+
}
|
|
477
|
+
this._action = value;
|
|
478
|
+
}
|
|
479
|
+
get description() {
|
|
480
|
+
return this._description;
|
|
481
|
+
}
|
|
482
|
+
set description(value) {
|
|
483
|
+
if (value && !(value in StatusDescription)) {
|
|
484
|
+
throw new Error('Invalid description');
|
|
485
|
+
}
|
|
486
|
+
this._description = value;
|
|
487
|
+
}
|
|
488
|
+
toString() {
|
|
489
|
+
let result = '';
|
|
490
|
+
if (this.nonNull(this._feature)) {
|
|
491
|
+
result += `${this._feature}:`;
|
|
492
|
+
}
|
|
493
|
+
if (this.nonNull(this._event)) {
|
|
494
|
+
result += `${this._event}:`;
|
|
495
|
+
}
|
|
496
|
+
if (this.nonNull(this._view)) {
|
|
497
|
+
result += `${this._view}:`;
|
|
498
|
+
}
|
|
499
|
+
if (this.nonNull(this._action)) {
|
|
500
|
+
result += `${this._action}:`;
|
|
501
|
+
}
|
|
502
|
+
if (this.nonNull(this._description)) {
|
|
503
|
+
result += `${this._description}`;
|
|
504
|
+
}
|
|
505
|
+
if (result.endsWith(':')) {
|
|
506
|
+
result = result.slice(0, -1); // 刪除最後一個字符
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const tokenSubject = new BehaviorSubject('');
|
|
514
|
+
tokenSubject.pipe(tap(token => {
|
|
515
|
+
if (!token) return;
|
|
516
|
+
const _jwt = decodeToken(token);
|
|
517
|
+
setAuthmeJWT(_jwt.payload);
|
|
518
|
+
})).subscribe();
|
|
519
|
+
const defaultEventName = new TrackingEvent({});
|
|
520
|
+
const [getAuthmeJWT, setAuthmeJWT] = useState();
|
|
521
|
+
const [getAccessToken, setAccessToken] = useState('', tokenSubject);
|
|
522
|
+
const [getSessionId, setSessionId] = useState('');
|
|
523
|
+
function generateStatus(params = {}) {
|
|
524
|
+
const _authmeJWT = getAuthmeJWT();
|
|
525
|
+
const {
|
|
526
|
+
eventType = defaultEventName,
|
|
527
|
+
sessionId = getSessionId(),
|
|
528
|
+
userTime = new Date().toISOString(),
|
|
529
|
+
tenantId = _authmeJWT.client_tenant,
|
|
530
|
+
customerId = _authmeJWT.client_id,
|
|
531
|
+
duration = 0,
|
|
532
|
+
deviceInfo = getDeviceInfo(),
|
|
533
|
+
systemInfo = getSystemInfo(),
|
|
534
|
+
version: version$1 = version,
|
|
535
|
+
language = '',
|
|
536
|
+
description = '',
|
|
537
|
+
platform = 'web',
|
|
538
|
+
extraInfo = ''
|
|
539
|
+
} = params;
|
|
540
|
+
return {
|
|
541
|
+
eventId: v4(),
|
|
542
|
+
eventType: eventType.toString(),
|
|
543
|
+
sessionId,
|
|
544
|
+
userTime,
|
|
545
|
+
tenantId,
|
|
546
|
+
customerId,
|
|
547
|
+
duration,
|
|
548
|
+
deviceInfo,
|
|
549
|
+
systemInfo,
|
|
550
|
+
version: version$1,
|
|
551
|
+
language,
|
|
552
|
+
description,
|
|
553
|
+
platform,
|
|
554
|
+
extraInfo
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export { AuthmeLanguage, EventListenerService, Feature, StatusAction, StatusDescription, StatusEvent, StatusView, TrackingEvent, core, generateStatus, getAccessToken, getSessionId, getTranslateInstance, sendRequest, setAccessToken, setSessionId, version };
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authme/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"core-js": "^3.6.0",
|
|
6
|
-
"@authme/util": "2.
|
|
6
|
+
"@authme/util": "2.4.2",
|
|
7
|
+
"rxjs": "7.5.7",
|
|
8
|
+
"uuid": "8.3.2"
|
|
7
9
|
},
|
|
8
10
|
"module": "./index.js",
|
|
9
11
|
"main": "./index.cjs",
|
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { EventTrackingStatus } from './status.interface';
|
|
3
|
+
declare class EventListenerService {
|
|
4
|
+
private readonly getStatusProcess;
|
|
5
|
+
private pingInterval;
|
|
6
|
+
private statusSubject;
|
|
7
|
+
private pingSubscription;
|
|
8
|
+
private apiService;
|
|
9
|
+
constructor(getStatusProcess: () => Promise<EventTrackingStatus>, options?: {
|
|
10
|
+
pingInterval?: number;
|
|
11
|
+
});
|
|
12
|
+
start(): void;
|
|
13
|
+
stop(): void;
|
|
14
|
+
sendUserActionStatus(status: EventTrackingStatus): Promise<any>;
|
|
15
|
+
private sendStatus;
|
|
16
|
+
getStatusObservable(): BehaviorSubject<EventTrackingStatus>;
|
|
17
|
+
}
|
|
18
|
+
export { EventListenerService };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EventTrackingStatus } from './status.interface';
|
|
2
|
+
export declare class MockApiService {
|
|
3
|
+
private data;
|
|
4
|
+
postStatus(status: EventTrackingStatus): Promise<EventTrackingStatus>;
|
|
5
|
+
postMutiStatus(status: EventTrackingStatus[]): Promise<EventTrackingStatus[]>;
|
|
6
|
+
getStatus(): Promise<EventTrackingStatus[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare enum Feature {
|
|
2
|
+
OCRFraud = "OCRFraud",
|
|
3
|
+
OCR = "OCR",
|
|
4
|
+
SelectCardTypeAndCountry = "SelectCardTypeAndCountry",
|
|
5
|
+
LivenessActive = "LivenessActive",
|
|
6
|
+
LivenessPassive = "LivenessPassive"
|
|
7
|
+
}
|
|
8
|
+
export declare enum StatusEvent {
|
|
9
|
+
TWID = "TWID",
|
|
10
|
+
TWIDFraud = "TWIDFraud",
|
|
11
|
+
TWIDFront = "TWIDFront",
|
|
12
|
+
TWDriverLicenseFront = "TWDriverLicenseFront",
|
|
13
|
+
Passport = "Passport",
|
|
14
|
+
ResidencePermitFront = "ResidencePermitFront",
|
|
15
|
+
ResidencePermitBack = "ResidencePermitBack",
|
|
16
|
+
TWIDBack = "TWIDBack",
|
|
17
|
+
TWDriverLicenseBack = "TWDriverLicenseBack",
|
|
18
|
+
TWHealthCardFront = "TWHealthCardFront",
|
|
19
|
+
TWDriverLicense = "TWDriverLicense",
|
|
20
|
+
TWHealthCard = "TWHealthCard",
|
|
21
|
+
ResidencePermit = "ResidencePermit",
|
|
22
|
+
PassportFront = "PassportFront",
|
|
23
|
+
OpenMouth = "OpenMouth",
|
|
24
|
+
CloseMouth = "CloseMouth",
|
|
25
|
+
Smile = "Smile",
|
|
26
|
+
Scale = "Scale",
|
|
27
|
+
Done = "Done",
|
|
28
|
+
Passive = "Passive",
|
|
29
|
+
SelectCardTypeAndCountry = "SelectCardTypeAndCountry"
|
|
30
|
+
}
|
|
31
|
+
export declare enum StatusView {
|
|
32
|
+
Info = "Info",
|
|
33
|
+
Init = "Init",
|
|
34
|
+
Aligning = "Aligning",
|
|
35
|
+
Start = "Start",
|
|
36
|
+
Up = "Up",
|
|
37
|
+
Down = "Down",
|
|
38
|
+
Left = "Left",
|
|
39
|
+
Right = "Right",
|
|
40
|
+
Running = "Running",
|
|
41
|
+
Confirm = "Confirm",
|
|
42
|
+
Uploading = "Uploading",
|
|
43
|
+
Select = "Select"
|
|
44
|
+
}
|
|
45
|
+
export declare enum StatusAction {
|
|
46
|
+
Uploading = "Uploading",
|
|
47
|
+
Show = "Show",
|
|
48
|
+
BtnClose = "BtnClose",
|
|
49
|
+
BtnStart = "BtnStart",
|
|
50
|
+
InitError = "InitError",
|
|
51
|
+
Start = "Start",
|
|
52
|
+
Confirm = "Confirm",
|
|
53
|
+
Retry = "Retry"
|
|
54
|
+
}
|
|
55
|
+
export declare enum StatusDescription {
|
|
56
|
+
NoCard = "NoCard",
|
|
57
|
+
WrongCardType = "WrongCardType",
|
|
58
|
+
PositionNotMatch = "PositionNotMatch",
|
|
59
|
+
Reflective = "Reflective",
|
|
60
|
+
Blur = "Blur",
|
|
61
|
+
Pass = "Pass",
|
|
62
|
+
Error = "Error",
|
|
63
|
+
Failed = "Failed",
|
|
64
|
+
Timeout = "Timeout",
|
|
65
|
+
Gray = "Gray",
|
|
66
|
+
NeedMoreFrame = "NeedMoreFrame",
|
|
67
|
+
NotAligned = "NotAligned",
|
|
68
|
+
NoFace = "NoFace",
|
|
69
|
+
FaceNotAtCenter = "FaceNotAtCenter",
|
|
70
|
+
FaceTooSmall = "FaceTooSmall",
|
|
71
|
+
FaceTooLarge = "FaceTooLarge",
|
|
72
|
+
NeedFaceToCamera = "NeedFaceToCamera",
|
|
73
|
+
FaceMasked = "FaceMasked",
|
|
74
|
+
NeedOpenMouth = "NeedOpenMouth",
|
|
75
|
+
NeedCloseMouth = "NeedCloseMouth",
|
|
76
|
+
NeedSmile = "NeedSmile",
|
|
77
|
+
NeedOpenEyes = "NeedOpenEyes",
|
|
78
|
+
UploadingStart = "UploadingStart",
|
|
79
|
+
UploadingEnd = "UploadingEnd",
|
|
80
|
+
Complete = "Complete"
|
|
81
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Feature, StatusAction, StatusDescription, StatusEvent, StatusView } from './status.enum';
|
|
2
|
+
import { TrackingEvent } from './tracking-event';
|
|
3
|
+
export interface EventTrackingStatus {
|
|
4
|
+
eventId: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
eventType: string;
|
|
7
|
+
userTime: string;
|
|
8
|
+
tenantId: string;
|
|
9
|
+
customerId: string;
|
|
10
|
+
duration: number;
|
|
11
|
+
deviceInfo: string;
|
|
12
|
+
systemInfo: string;
|
|
13
|
+
version: string;
|
|
14
|
+
language: string;
|
|
15
|
+
description: string;
|
|
16
|
+
platform: string;
|
|
17
|
+
extraInfo: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GenerateStatusParams {
|
|
20
|
+
eventType?: TrackingEvent;
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
userTime?: string;
|
|
23
|
+
tenantId?: string;
|
|
24
|
+
customerId?: string;
|
|
25
|
+
duration?: number;
|
|
26
|
+
deviceInfo?: string;
|
|
27
|
+
systemInfo?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
language?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
platform?: string;
|
|
32
|
+
extraInfo?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface NewEventNameDTO {
|
|
35
|
+
feature?: Feature;
|
|
36
|
+
event?: StatusEvent;
|
|
37
|
+
view?: StatusView;
|
|
38
|
+
action?: StatusAction;
|
|
39
|
+
description?: StatusDescription;
|
|
40
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EventTrackingStatus, GenerateStatusParams } from './status.interface';
|
|
2
|
+
export declare const getAccessToken: () => string, setAccessToken: (value: string) => void;
|
|
3
|
+
export declare const getSessionId: () => string, setSessionId: (value: string) => void;
|
|
4
|
+
export declare function generateStatus(params?: GenerateStatusParams): EventTrackingStatus;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Feature, StatusAction, StatusDescription, StatusEvent, StatusView } from './status.enum';
|
|
2
|
+
import { NewEventNameDTO } from './status.interface';
|
|
3
|
+
export declare class TrackingEvent {
|
|
4
|
+
private _feature?;
|
|
5
|
+
private _event?;
|
|
6
|
+
private _view?;
|
|
7
|
+
private _action?;
|
|
8
|
+
private _description?;
|
|
9
|
+
constructor(params: NewEventNameDTO);
|
|
10
|
+
nonNull(data: any): boolean;
|
|
11
|
+
get feature(): Feature | undefined;
|
|
12
|
+
set feature(value: Feature | undefined);
|
|
13
|
+
get event(): StatusEvent | undefined;
|
|
14
|
+
set event(value: StatusEvent | undefined);
|
|
15
|
+
get view(): StatusView | undefined;
|
|
16
|
+
set view(value: StatusView | undefined);
|
|
17
|
+
get action(): StatusAction | undefined;
|
|
18
|
+
set action(value: StatusAction | undefined);
|
|
19
|
+
get description(): StatusDescription | undefined;
|
|
20
|
+
set description(value: StatusDescription | undefined);
|
|
21
|
+
toString(): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './event-listener';
|
|
@@ -10,6 +10,7 @@ declare class TranslateService {
|
|
|
10
10
|
translate(key: string, args?: {
|
|
11
11
|
[key: string]: string | number;
|
|
12
12
|
}): string;
|
|
13
|
+
getCurrentLang(): AuthmeLanguage;
|
|
13
14
|
static instance: TranslateService | null;
|
|
14
15
|
}
|
|
15
16
|
declare function getTranslateInstance(): TranslateService;
|