@bytexbyte/berifyme-react-sdk 1.0.11 → 1.0.13
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/components/Login/authid/authid.js +16 -16
- package/dist/components/OnBoarding/authId/index.js +6 -22
- 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/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();
|
|
@@ -134,22 +134,22 @@ var AuthID = function (_a) {
|
|
|
134
134
|
});
|
|
135
135
|
goRedirect();
|
|
136
136
|
}
|
|
137
|
-
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}));
|
|
137
|
+
// WebSDK不需要這段, 不會被WebView使用 (window as any).ReactNativeWebView.postMessage(JSON.stringify({
|
|
138
|
+
// event: 'onSuccess', user: {
|
|
139
|
+
// id: result.userId,
|
|
140
|
+
// isActive: null,
|
|
141
|
+
// email: null,
|
|
142
|
+
// phoneNumber: phone,
|
|
143
|
+
// authIDAccountNumber: null,
|
|
144
|
+
// incodeId: null,
|
|
145
|
+
// clearId: null,
|
|
146
|
+
// idmeId: null,
|
|
147
|
+
// fullName,
|
|
148
|
+
// age: null,
|
|
149
|
+
// birthDate: birthDateFromAuthId?.replaceAll('-', '/'),
|
|
150
|
+
// transactionId,
|
|
151
|
+
// }
|
|
152
|
+
// }));
|
|
153
153
|
return [2 /*return*/];
|
|
154
154
|
case 3:
|
|
155
155
|
setError(result.error);
|
|
@@ -210,12 +210,12 @@ var AuthID = function (_a) {
|
|
|
210
210
|
setUrl('');
|
|
211
211
|
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
212
212
|
var document, documentType;
|
|
213
|
-
var _a, _b, _c, _d, _e, _f
|
|
214
|
-
return __generator(this, function (
|
|
215
|
-
switch (
|
|
213
|
+
var _a, _b, _c, _d, _e, _f;
|
|
214
|
+
return __generator(this, function (_g) {
|
|
215
|
+
switch (_g.label) {
|
|
216
216
|
case 0: return [4 /*yield*/, berifymeApi.authID.getDocumentDetails({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId, sessionToken: token })];
|
|
217
217
|
case 1:
|
|
218
|
-
document =
|
|
218
|
+
document = _g.sent();
|
|
219
219
|
createDeveloperLog({
|
|
220
220
|
userId: userId,
|
|
221
221
|
source: 'FRONTEND',
|
|
@@ -246,7 +246,7 @@ var AuthID = function (_a) {
|
|
|
246
246
|
documentType: (documentType === null || documentType === void 0 ? void 0 : documentType.includes('Passport')) ? 'Passport' : 'ID'
|
|
247
247
|
})];
|
|
248
248
|
case 2:
|
|
249
|
-
|
|
249
|
+
_g.sent();
|
|
250
250
|
createDeveloperLog({
|
|
251
251
|
userId: userId,
|
|
252
252
|
source: 'FRONTEND',
|
|
@@ -262,23 +262,7 @@ var AuthID = function (_a) {
|
|
|
262
262
|
updateAuthenticationLog({ isPass: true, transactionId: operationId, token: token });
|
|
263
263
|
goToAllSet();
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
event: 'onSuccess', user: {
|
|
267
|
-
id: userId,
|
|
268
|
-
fullName: (_g = document.details.find(function (item) { return item.Key === 'NameOfHolder'; })) === null || _g === void 0 ? void 0 : _g.Value,
|
|
269
|
-
phoneNumber: document.phone,
|
|
270
|
-
isActive: null,
|
|
271
|
-
email: null,
|
|
272
|
-
authIDAccountNumber: null,
|
|
273
|
-
incodeId: null,
|
|
274
|
-
clearId: null,
|
|
275
|
-
idmeId: null,
|
|
276
|
-
age: null,
|
|
277
|
-
birthDate: null,
|
|
278
|
-
transactionId: operationId,
|
|
279
|
-
},
|
|
280
|
-
}));
|
|
281
|
-
_h.label = 3;
|
|
265
|
+
_g.label = 3;
|
|
282
266
|
case 3: return [2 /*return*/];
|
|
283
267
|
}
|
|
284
268
|
});
|
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