@bytexbyte/berifyme-react-sdk 1.0.10 → 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.
- package/dist/BerifymeModal/index.js +13 -4
- package/dist/api/api.js +8 -2
- package/dist/components/Login/clearAllSet.js +2 -2
- package/dist/components/OnBoarding/clear/clearAllSet.js +2 -2
- package/dist/enum/index.js +52 -0
- package/dist/event.js +18 -0
- package/dist/types/BerifymeModal/index.d.ts +4 -1
- package/dist/types/api/api.d.ts +7 -1
- package/dist/types/enum/index.d.ts +7 -0
- package/dist/types/event.d.ts +9 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -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/api/api.js
CHANGED
|
@@ -513,14 +513,20 @@ function sendPhoneNumberCode(_a) {
|
|
|
513
513
|
});
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
|
+
export var VerificationStatus;
|
|
517
|
+
(function (VerificationStatus) {
|
|
518
|
+
VerificationStatus["PENDING"] = "PENDING";
|
|
519
|
+
VerificationStatus["ONBOARDING"] = "ONBOARDING";
|
|
520
|
+
VerificationStatus["LOGIN"] = "LOGIN";
|
|
521
|
+
})(VerificationStatus || (VerificationStatus = {}));
|
|
516
522
|
function getUserBySessionId(_a) {
|
|
517
523
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
518
524
|
var url, res;
|
|
519
|
-
var sessionId = _b.sessionId, token = _b.token;
|
|
525
|
+
var sessionId = _b.sessionId, verificationStatus = _b.verificationStatus, token = _b.token;
|
|
520
526
|
return __generator(this, function (_c) {
|
|
521
527
|
switch (_c.label) {
|
|
522
528
|
case 0:
|
|
523
|
-
url = "".concat(config.backendDomain, "/api/user/getUserByClearSessionId?id=").concat(sessionId).concat(token ? "&token=".concat(token) : '');
|
|
529
|
+
url = "".concat(config.backendDomain, "/api/user/getUserByClearSessionId?id=").concat(sessionId, "&verificationStatus=").concat(verificationStatus).concat(token ? "&token=".concat(token) : '');
|
|
524
530
|
console.log('UrlString: ', url);
|
|
525
531
|
return [4 /*yield*/, axios.get(url)];
|
|
526
532
|
case 1:
|
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import React from "react";
|
|
38
38
|
import { useEffect, useState } from "react";
|
|
39
|
-
import berifymeApi from "../../api/api";
|
|
39
|
+
import berifymeApi, { VerificationStatus } from "../../api/api";
|
|
40
40
|
import { Box, CircularProgress } from "@mui/material";
|
|
41
41
|
import AllSet from "../../components/AllSet";
|
|
42
42
|
import TryAgain from "../TryAgain";
|
|
@@ -51,7 +51,7 @@ var ClearLoginAllSet = function (_a) {
|
|
|
51
51
|
var sessionId = _b.sessionId, token = _b.token;
|
|
52
52
|
return __generator(this, function (_c) {
|
|
53
53
|
switch (_c.label) {
|
|
54
|
-
case 0: return [4 /*yield*/, berifymeApi.user.getUserBySessionId({ sessionId: sessionId, token: token })];
|
|
54
|
+
case 0: return [4 /*yield*/, berifymeApi.user.getUserBySessionId({ sessionId: sessionId, verificationStatus: VerificationStatus.LOGIN, token: token })];
|
|
55
55
|
case 1:
|
|
56
56
|
res = _c.sent();
|
|
57
57
|
createDeveloperLog({
|
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import React from "react";
|
|
38
38
|
import { useEffect, useState } from "react";
|
|
39
|
-
import berifymeApi from "../../../api/api";
|
|
39
|
+
import berifymeApi, { VerificationStatus } from "../../../api/api";
|
|
40
40
|
import { Box, CircularProgress } from "@mui/material";
|
|
41
41
|
import AllSet from "../../AllSet";
|
|
42
42
|
import TryAgain from "../../TryAgain";
|
|
@@ -67,7 +67,7 @@ var ClearOnboardingAllSet = function (_a) {
|
|
|
67
67
|
setError(approveRes.error);
|
|
68
68
|
return [2 /*return*/];
|
|
69
69
|
}
|
|
70
|
-
return [4 /*yield*/, berifymeApi.user.getUserBySessionId({ sessionId: sessionId, token: token })];
|
|
70
|
+
return [4 /*yield*/, berifymeApi.user.getUserBySessionId({ sessionId: sessionId, verificationStatus: VerificationStatus.ONBOARDING, token: token })];
|
|
71
71
|
case 2:
|
|
72
72
|
res = _c.sent();
|
|
73
73
|
createDeveloperLog({
|
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;
|
package/dist/types/api/api.d.ts
CHANGED
|
@@ -260,8 +260,14 @@ declare function sendPhoneNumberCode({ phoneNumber, token }: {
|
|
|
260
260
|
success: boolean;
|
|
261
261
|
error?: string;
|
|
262
262
|
}>;
|
|
263
|
-
declare
|
|
263
|
+
export declare enum VerificationStatus {
|
|
264
|
+
PENDING = "PENDING",
|
|
265
|
+
ONBOARDING = "ONBOARDING",
|
|
266
|
+
LOGIN = "LOGIN"
|
|
267
|
+
}
|
|
268
|
+
declare function getUserBySessionId({ sessionId, verificationStatus, token }: {
|
|
264
269
|
sessionId: string;
|
|
270
|
+
verificationStatus: VerificationStatus;
|
|
265
271
|
token?: string;
|
|
266
272
|
}): Promise<{
|
|
267
273
|
user?: UserWithAgeAndFullName;
|
|
@@ -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