@bytexbyte/berifyme-react-sdk 1.0.11 → 1.0.12
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.
|
@@ -57,14 +57,14 @@ import theme from '../components/theme';
|
|
|
57
57
|
import TryAgainInModal from '../components/TryAgainInModal';
|
|
58
58
|
import VerifyNewUser from '../components/VerifyWithPhoneNumber/NewUser';
|
|
59
59
|
import VerifyUser from '../components/VerifyWithPhoneNumber/User';
|
|
60
|
-
import { PageStatus } from '../enum';
|
|
60
|
+
import { getPageStatusString, PageStatus } from '../enum';
|
|
61
61
|
import { environmentDomains } from '../lib/environmentDomains';
|
|
62
62
|
import { incode } from '../vender/incode/incode';
|
|
63
63
|
import Modal from './MainModal';
|
|
64
64
|
import QrcodeExpired from '../components/QrcodeExpired';
|
|
65
65
|
import SessionInterrupted from '../components/SessionInterrupted';
|
|
66
66
|
var HomeModal = function (_a) {
|
|
67
|
-
var apiKeyId = _a.apiKeyId, secretKey = _a.secretKey, redirectUrl = _a.redirectUrl, _b = _a.initialPhoneNumber, initialPhoneNumber = _b === void 0 ? '' : _b, environment = _a.environment, forceQrcode = _a.forceQrcode;
|
|
67
|
+
var apiKeyId = _a.apiKeyId, secretKey = _a.secretKey, redirectUrl = _a.redirectUrl, _b = _a.initialPhoneNumber, initialPhoneNumber = _b === void 0 ? '' : _b, environment = _a.environment, forceQrcode = _a.forceQrcode, onUpdate = _a.onUpdate;
|
|
68
68
|
var _c = useState(window.innerWidth > window.innerHeight), isLandscape = _c[0], setIsLandscape = _c[1];
|
|
69
69
|
var _d = useState(), desktopRedirectUrlId = _d[0], setDesktopRedirectUrlId = _d[1];
|
|
70
70
|
var _e = useState(false), useQrcode = _e[0], setUseQrcode = _e[1];
|
|
@@ -236,7 +236,6 @@ var HomeModal = function (_a) {
|
|
|
236
236
|
setAuthIdSelectedIdType('');
|
|
237
237
|
}, [error]);
|
|
238
238
|
useEffect(function () {
|
|
239
|
-
console.log('change page to: ', pageStatus);
|
|
240
239
|
if (useQrcode) {
|
|
241
240
|
setModalHeight('80vh');
|
|
242
241
|
}
|
|
@@ -291,11 +290,21 @@ var HomeModal = function (_a) {
|
|
|
291
290
|
else {
|
|
292
291
|
setModalHeight('80vh');
|
|
293
292
|
}
|
|
293
|
+
// 於首頁傳送change page資訊至外部的方法
|
|
294
|
+
var detail = {
|
|
295
|
+
page: { pageName: getPageStatusString(pageStatus) },
|
|
296
|
+
};
|
|
297
|
+
// 廣播給Listener使用
|
|
298
|
+
var event = new CustomEvent('berifyme:page', { detail: detail });
|
|
299
|
+
window.dispatchEvent(event);
|
|
300
|
+
// 使用callback
|
|
301
|
+
if (onUpdate)
|
|
302
|
+
onUpdate({ detail: detail });
|
|
294
303
|
}, [pageStatus, useQrcode, isLandscape]);
|
|
295
304
|
useEffect(function () {
|
|
296
305
|
var checkOrientation = function () {
|
|
297
306
|
setIsLandscape(window.innerWidth > window.innerHeight);
|
|
298
|
-
console.log('
|
|
307
|
+
console.log('checkOrientation Landscape: ', window.innerWidth > window.innerHeight ? 'true' : 'false');
|
|
299
308
|
};
|
|
300
309
|
window.addEventListener('resize', checkOrientation);
|
|
301
310
|
checkOrientation();
|
package/dist/enum/index.js
CHANGED
|
@@ -24,3 +24,55 @@ export var PageStatus;
|
|
|
24
24
|
PageStatus[PageStatus["ClearOnboardingAllSet"] = 7] = "ClearOnboardingAllSet";
|
|
25
25
|
PageStatus[PageStatus["AllSet"] = 10] = "AllSet";
|
|
26
26
|
})(PageStatus || (PageStatus = {}));
|
|
27
|
+
export var getPageStatusString = function (status) {
|
|
28
|
+
switch (status) {
|
|
29
|
+
case PageStatus.SessionInterrupted:
|
|
30
|
+
return "SessionInterrupted";
|
|
31
|
+
case PageStatus.QRCodeExpired:
|
|
32
|
+
return "QRCodeExpired";
|
|
33
|
+
case PageStatus.Loading:
|
|
34
|
+
return "Loading";
|
|
35
|
+
case PageStatus.SendSns:
|
|
36
|
+
return "AuthStart";
|
|
37
|
+
case PageStatus.VerifyNewUser:
|
|
38
|
+
return "VerifyNewUser";
|
|
39
|
+
case PageStatus.Vender:
|
|
40
|
+
return "Vender";
|
|
41
|
+
case PageStatus.IdOrPassport:
|
|
42
|
+
return "BerifymeChooseIdOrPassport";
|
|
43
|
+
case PageStatus.VerifyUser:
|
|
44
|
+
return "VerifyUser";
|
|
45
|
+
case PageStatus.AuthIdOnboarding:
|
|
46
|
+
return "BerifymeOnboarding";
|
|
47
|
+
case PageStatus.ClearOnboarding:
|
|
48
|
+
return "ClearOnboarding";
|
|
49
|
+
case PageStatus.IncodeOnBoarding:
|
|
50
|
+
return "IncodeOnBoarding";
|
|
51
|
+
// case PageStatus.SumsubOnBoarding:
|
|
52
|
+
// return "SumsubOnBoarding";
|
|
53
|
+
// case PageStatus.VeriffOnBoarding:
|
|
54
|
+
// return "VeriffOnBoarding";
|
|
55
|
+
// case PageStatus.YotiOnBoarding:
|
|
56
|
+
// return "YotiOnBoarding";
|
|
57
|
+
case PageStatus.AuthidLogin:
|
|
58
|
+
return "BerifymeLogin";
|
|
59
|
+
case PageStatus.ClearLogin:
|
|
60
|
+
return "ClearLogin";
|
|
61
|
+
case PageStatus.IncodeLogin:
|
|
62
|
+
return "IncodeLogin";
|
|
63
|
+
case PageStatus.ClearLoginAllSet:
|
|
64
|
+
return "ClearLoginVerifySuccess";
|
|
65
|
+
case PageStatus.ClearOnboardingAllSet:
|
|
66
|
+
return "ClearOnboardingVerifySuccess";
|
|
67
|
+
// case PageStatus.SumsubLogin:
|
|
68
|
+
// return "SumsubLogin";
|
|
69
|
+
// case PageStatus.VeriffLogin:
|
|
70
|
+
// return "VeriffLogin";
|
|
71
|
+
// case PageStatus.YotiLogin:
|
|
72
|
+
// return "YotiLogin";
|
|
73
|
+
case PageStatus.AllSet:
|
|
74
|
+
return "VerifySuccess";
|
|
75
|
+
default:
|
|
76
|
+
return "UnknownStatus";
|
|
77
|
+
}
|
|
78
|
+
};
|
package/dist/event.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// event.ts
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
// 定義事件名稱
|
|
4
|
+
export var BERIFYME_PAGE_EVENT = 'berifyme:page';
|
|
5
|
+
// 創建事件管理器
|
|
6
|
+
var eventEmitter = new EventEmitter();
|
|
7
|
+
// 將事件管理器導出
|
|
8
|
+
export var berifymeEventEmitter = {
|
|
9
|
+
emit: function (eventType, detail) {
|
|
10
|
+
eventEmitter.emit(eventType, detail);
|
|
11
|
+
},
|
|
12
|
+
addListener: function (eventType, callback) {
|
|
13
|
+
eventEmitter.addListener(eventType, callback);
|
|
14
|
+
},
|
|
15
|
+
removeListener: function (eventType, callback) {
|
|
16
|
+
eventEmitter.removeListener(eventType, callback);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '../../index.css';
|
|
3
|
-
import { Environment } from '../enum';
|
|
3
|
+
import { Environment, UpdateData } from '../enum';
|
|
4
4
|
declare const HomeModal: React.FC<{
|
|
5
5
|
apiKeyId: string;
|
|
6
6
|
secretKey: string;
|
|
@@ -8,5 +8,8 @@ declare const HomeModal: React.FC<{
|
|
|
8
8
|
initialPhoneNumber?: string;
|
|
9
9
|
environment: Environment;
|
|
10
10
|
forceQrcode?: boolean;
|
|
11
|
+
onUpdate?: ({ detail }: {
|
|
12
|
+
detail: UpdateData;
|
|
13
|
+
}) => void;
|
|
11
14
|
}>;
|
|
12
15
|
export default HomeModal;
|
|
@@ -3,6 +3,12 @@ export declare enum Environment {
|
|
|
3
3
|
Staging = "staging",
|
|
4
4
|
Idv = "idv"
|
|
5
5
|
}
|
|
6
|
+
export type UpdateData = {
|
|
7
|
+
page?: {
|
|
8
|
+
pageName: string;
|
|
9
|
+
};
|
|
10
|
+
message?: string;
|
|
11
|
+
};
|
|
6
12
|
export declare enum PageStatus {
|
|
7
13
|
SessionInterrupted = -3,
|
|
8
14
|
QRCodeExpired = -2,
|
|
@@ -22,3 +28,4 @@ export declare enum PageStatus {
|
|
|
22
28
|
ClearOnboardingAllSet = 7,
|
|
23
29
|
AllSet = 10
|
|
24
30
|
}
|
|
31
|
+
export declare const getPageStatusString: (status: number) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const BERIFYME_PAGE_EVENT = "berifyme:page";
|
|
2
|
+
export interface BerifymePageEventDetail {
|
|
3
|
+
pageName: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const berifymeEventEmitter: {
|
|
6
|
+
emit(eventType: string, detail: BerifymePageEventDetail): void;
|
|
7
|
+
addListener(eventType: string, callback: (detail: BerifymePageEventDetail) => void): void;
|
|
8
|
+
removeListener(eventType: string, callback: (detail: BerifymePageEventDetail) => void): void;
|
|
9
|
+
};
|
package/dist/types/index.d.ts
CHANGED