@bytexbyte/berifyme-react-sdk 1.0.0

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.
Files changed (129) hide show
  1. package/README.md +20 -0
  2. package/dist/BerifymeModal/MainModal.js +29 -0
  3. package/dist/BerifymeModal/index.js +331 -0
  4. package/dist/api/api.js +1337 -0
  5. package/dist/api/client.js +21 -0
  6. package/dist/api/index.js +96 -0
  7. package/dist/common.js +216 -0
  8. package/dist/components/AllSet/index.js +169 -0
  9. package/dist/components/AuthenticationLogs.js +148 -0
  10. package/dist/components/Clear.js +107 -0
  11. package/dist/components/Footer/index.js +11 -0
  12. package/dist/components/Layout.js +9 -0
  13. package/dist/components/Login/authid/authid.js +196 -0
  14. package/dist/components/Login/authid/index.js +13 -0
  15. package/dist/components/Login/clear.js +35 -0
  16. package/dist/components/Login/clearAllSet.js +96 -0
  17. package/dist/components/Login/incode/Login.js +129 -0
  18. package/dist/components/Login/incode/index.js +16 -0
  19. package/dist/components/OnBoarding/authId/authIdSelectType.js +82 -0
  20. package/dist/components/OnBoarding/authId/idOrPassport.js +30 -0
  21. package/dist/components/OnBoarding/authId/index.js +323 -0
  22. package/dist/components/OnBoarding/clear/clearAllSet.js +118 -0
  23. package/dist/components/OnBoarding/clear/index.js +36 -0
  24. package/dist/components/OnBoarding/incode/BackId.js +25 -0
  25. package/dist/components/OnBoarding/incode/FinishOnboarding.js +26 -0
  26. package/dist/components/OnBoarding/incode/FrontId.js +27 -0
  27. package/dist/components/OnBoarding/incode/Passport.js +27 -0
  28. package/dist/components/OnBoarding/incode/ProcessFace.js +22 -0
  29. package/dist/components/OnBoarding/incode/ProcessId.js +22 -0
  30. package/dist/components/OnBoarding/incode/SelectType.js +68 -0
  31. package/dist/components/OnBoarding/incode/Selfie.js +25 -0
  32. package/dist/components/OnBoarding/incode/Steps.js +7 -0
  33. package/dist/components/OnBoarding/incode/UserConsent.js +30 -0
  34. package/dist/components/OnBoarding/incode/index.js +234 -0
  35. package/dist/components/OnBoarding/vender/grid/authIdGrid.js +94 -0
  36. package/dist/components/OnBoarding/vender/grid/clearGrid.js +14 -0
  37. package/dist/components/OnBoarding/vender/grid/incodeGrid.js +14 -0
  38. package/dist/components/OnBoarding/vender/grid/index.js +118 -0
  39. package/dist/components/OnBoarding/vender/grid/sumsubGrid.js +14 -0
  40. package/dist/components/OnBoarding/vender/grid/veriffGrid.js +14 -0
  41. package/dist/components/OnBoarding/vender/grid/yotiGrid.js +14 -0
  42. package/dist/components/OnBoarding/vender/index.js +123 -0
  43. package/dist/components/RedirectToMobile/index.js +139 -0
  44. package/dist/components/ScreenRotation.js +11 -0
  45. package/dist/components/SendSns/index.js +341 -0
  46. package/dist/components/SendSns/style.css +1 -0
  47. package/dist/components/TryAgain.js +16 -0
  48. package/dist/components/TryAgainInModal.js +15 -0
  49. package/dist/components/VerifyWithPhoneNumber/NewUser/index.js +189 -0
  50. package/dist/components/VerifyWithPhoneNumber/User/index.js +322 -0
  51. package/dist/components/createDeveloperLog.js +60 -0
  52. package/dist/components/phoneNumberProcesser.js +32 -0
  53. package/dist/components/speedTest/SpeedProvider.js +57 -0
  54. package/dist/components/theme.js +120 -0
  55. package/dist/enum/index.js +24 -0
  56. package/dist/index.js +7 -0
  57. package/dist/lib/environmentDomains.js +12 -0
  58. package/dist/lib/webauthb.js +158 -0
  59. package/dist/state.js +23 -0
  60. package/dist/theme.js +120 -0
  61. package/dist/types/BerifymeModal/MainModal.d.ts +7 -0
  62. package/dist/types/BerifymeModal/index.d.ts +12 -0
  63. package/dist/types/api/api.d.ts +606 -0
  64. package/dist/types/api/client.d.ts +2 -0
  65. package/dist/types/api/index.d.ts +16 -0
  66. package/dist/types/common.d.ts +3 -0
  67. package/dist/types/components/AllSet/index.d.ts +8 -0
  68. package/dist/types/components/AuthenticationLogs.d.ts +19 -0
  69. package/dist/types/components/Clear.d.ts +9 -0
  70. package/dist/types/components/Footer/index.d.ts +3 -0
  71. package/dist/types/components/Layout.d.ts +5 -0
  72. package/dist/types/components/Login/authid/authid.d.ts +11 -0
  73. package/dist/types/components/Login/authid/index.d.ts +9 -0
  74. package/dist/types/components/Login/clear.d.ts +7 -0
  75. package/dist/types/components/Login/clearAllSet.d.ts +6 -0
  76. package/dist/types/components/Login/incode/Login.d.ts +13 -0
  77. package/dist/types/components/Login/incode/index.d.ts +9 -0
  78. package/dist/types/components/OnBoarding/authId/authIdSelectType.d.ts +6 -0
  79. package/dist/types/components/OnBoarding/authId/idOrPassport.d.ts +7 -0
  80. package/dist/types/components/OnBoarding/authId/index.d.ts +11 -0
  81. package/dist/types/components/OnBoarding/clear/clearAllSet.d.ts +6 -0
  82. package/dist/types/components/OnBoarding/clear/index.d.ts +8 -0
  83. package/dist/types/components/OnBoarding/incode/BackId.d.ts +11 -0
  84. package/dist/types/components/OnBoarding/incode/FinishOnboarding.d.ts +11 -0
  85. package/dist/types/components/OnBoarding/incode/FrontId.d.ts +10 -0
  86. package/dist/types/components/OnBoarding/incode/Passport.d.ts +10 -0
  87. package/dist/types/components/OnBoarding/incode/ProcessFace.d.ts +11 -0
  88. package/dist/types/components/OnBoarding/incode/ProcessId.d.ts +11 -0
  89. package/dist/types/components/OnBoarding/incode/SelectType.d.ts +6 -0
  90. package/dist/types/components/OnBoarding/incode/Selfie.d.ts +11 -0
  91. package/dist/types/components/OnBoarding/incode/Steps.d.ts +7 -0
  92. package/dist/types/components/OnBoarding/incode/UserConsent.d.ts +8 -0
  93. package/dist/types/components/OnBoarding/incode/index.d.ts +9 -0
  94. package/dist/types/components/OnBoarding/vender/grid/authIdGrid.d.ts +8 -0
  95. package/dist/types/components/OnBoarding/vender/grid/clearGrid.d.ts +5 -0
  96. package/dist/types/components/OnBoarding/vender/grid/incodeGrid.d.ts +5 -0
  97. package/dist/types/components/OnBoarding/vender/grid/index.d.ts +10 -0
  98. package/dist/types/components/OnBoarding/vender/grid/sumsubGrid.d.ts +5 -0
  99. package/dist/types/components/OnBoarding/vender/grid/veriffGrid.d.ts +5 -0
  100. package/dist/types/components/OnBoarding/vender/grid/yotiGrid.d.ts +5 -0
  101. package/dist/types/components/OnBoarding/vender/index.d.ts +9 -0
  102. package/dist/types/components/RedirectToMobile/index.d.ts +7 -0
  103. package/dist/types/components/ScreenRotation.d.ts +3 -0
  104. package/dist/types/components/SendSns/index.d.ts +16 -0
  105. package/dist/types/components/TryAgain.d.ts +6 -0
  106. package/dist/types/components/TryAgainInModal.d.ts +6 -0
  107. package/dist/types/components/VerifyWithPhoneNumber/NewUser/index.d.ts +11 -0
  108. package/dist/types/components/VerifyWithPhoneNumber/User/index.d.ts +13 -0
  109. package/dist/types/components/createDeveloperLog.d.ts +11 -0
  110. package/dist/types/components/phoneNumberProcesser.d.ts +6 -0
  111. package/dist/types/components/speedTest/SpeedProvider.d.ts +9 -0
  112. package/dist/types/components/theme.d.ts +9 -0
  113. package/dist/types/enum/index.d.ts +22 -0
  114. package/dist/types/index.d.ts +12 -0
  115. package/dist/types/lib/environmentDomains.d.ts +7 -0
  116. package/dist/types/lib/webauthb.d.ts +18 -0
  117. package/dist/types/state.d.ts +11 -0
  118. package/dist/types/theme.d.ts +9 -0
  119. package/dist/types/vender/incode/incode.d.ts +8 -0
  120. package/dist/vender/incode/incode.js +13 -0
  121. package/index.css +52 -0
  122. package/package.json +49 -0
  123. package/public/US-UK_Add_to_Apple_Wallet_RGB_101421.svg +259 -0
  124. package/public/berify-title.webp +0 -0
  125. package/public/clearme.svg +39 -0
  126. package/public/idme.svg +13 -0
  127. package/public/incode.svg +9 -0
  128. package/public/scan.svg +8 -0
  129. package/public/trackablehealth-one-logo-1024x229.jpg +0 -0
@@ -0,0 +1,21 @@
1
+ import axios from 'axios';
2
+ var apiClient = axios.create({
3
+ baseURL: 'https://staging-backend.berify.me', // 替換為你的 API 基礎 URL
4
+ headers: {
5
+ 'Content-Type': 'application/json',
6
+ },
7
+ });
8
+ // 你可以添加攔截器來處理請求和響應
9
+ apiClient.interceptors.request.use(function (config) {
10
+ // 例如,添加授權標頭
11
+ var token = localStorage.getItem('token');
12
+ if (token) {
13
+ config.headers.Authorization = "Bearer ".concat(token);
14
+ }
15
+ return config;
16
+ });
17
+ apiClient.interceptors.response.use(function (response) { return response; }, function (error) {
18
+ // 處理錯誤
19
+ return Promise.reject(error);
20
+ });
21
+ export default apiClient;
@@ -0,0 +1,96 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import apiClient from './client';
38
+ export var getExampleData = function () { return __awaiter(void 0, void 0, void 0, function () {
39
+ var response, error_1;
40
+ return __generator(this, function (_a) {
41
+ switch (_a.label) {
42
+ case 0:
43
+ _a.trys.push([0, 2, , 3]);
44
+ return [4 /*yield*/, apiClient.get('/example-endpoint')];
45
+ case 1:
46
+ response = _a.sent();
47
+ return [2 /*return*/, response.data];
48
+ case 2:
49
+ error_1 = _a.sent();
50
+ console.error('API call failed:', error_1);
51
+ throw error_1;
52
+ case 3: return [2 /*return*/];
53
+ }
54
+ });
55
+ }); };
56
+ export var createTokenData = function (body) { return __awaiter(void 0, void 0, void 0, function () {
57
+ var response, error_2;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0:
61
+ _a.trys.push([0, 2, , 3]);
62
+ return [4 /*yield*/, apiClient.post('/api/thirdParty/createToken', body)];
63
+ case 1:
64
+ response = _a.sent();
65
+ return [2 /*return*/, response.data];
66
+ case 2:
67
+ error_2 = _a.sent();
68
+ console.error('API call failed:', error_2);
69
+ throw error_2;
70
+ case 3: return [2 /*return*/];
71
+ }
72
+ });
73
+ }); };
74
+ export var getUserDataByTokenData = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
75
+ var customHeaders, response, error_3;
76
+ var header = _b.header, params = _b.params;
77
+ return __generator(this, function (_c) {
78
+ switch (_c.label) {
79
+ case 0:
80
+ _c.trys.push([0, 2, , 3]);
81
+ customHeaders = {
82
+ 'api-key-id': header.apiKeyId,
83
+ 'secret-key': header.secretKey,
84
+ };
85
+ return [4 /*yield*/, apiClient.get("/api/user/getUserByToken?token=".concat(params.token, "&fields=").concat(params.fields), { headers: customHeaders })];
86
+ case 1:
87
+ response = _c.sent();
88
+ return [2 /*return*/, response.data];
89
+ case 2:
90
+ error_3 = _c.sent();
91
+ console.error('API call failed:', error_3);
92
+ throw error_3;
93
+ case 3: return [2 /*return*/];
94
+ }
95
+ });
96
+ }); };
package/dist/common.js ADDED
@@ -0,0 +1,216 @@
1
+ export var delay = function (n) {
2
+ return new Promise(function (resolve) {
3
+ setTimeout(resolve, Math.max(0, n));
4
+ });
5
+ };
6
+ export var countryCodesToName = {
7
+ 'AF': 'Afghanistan',
8
+ 'AL': 'Albania',
9
+ 'DZ': 'Algeria',
10
+ 'AS': 'American Samoa',
11
+ 'AD': 'Andorra',
12
+ 'AO': 'Angola',
13
+ 'AI': 'Anguilla',
14
+ 'AQ': 'Antarctica',
15
+ 'AG': 'Antigua and Barbuda',
16
+ 'AR': 'Argentina',
17
+ 'AM': 'Armenia',
18
+ 'AW': 'Aruba',
19
+ 'AU': 'Australia',
20
+ 'AT': 'Austria',
21
+ 'AZ': 'Azerbaijan',
22
+ 'BS': 'Bahamas',
23
+ 'BH': 'Bahrain',
24
+ 'BD': 'Bangladesh',
25
+ 'BB': 'Barbados',
26
+ 'BY': 'Belarus',
27
+ 'BE': 'Belgium',
28
+ 'BZ': 'Belize',
29
+ 'BJ': 'Benin',
30
+ 'BM': 'Bermuda',
31
+ 'BT': 'Bhutan',
32
+ 'BO': 'Bolivia',
33
+ 'BA': 'Bosnia and Herzegovina',
34
+ 'BW': 'Botswana',
35
+ 'BR': 'Brazil',
36
+ 'BN': 'Brunei Darussalam',
37
+ 'BG': 'Bulgaria',
38
+ 'BF': 'Burkina Faso',
39
+ 'BI': 'Burundi',
40
+ 'KH': 'Cambodia',
41
+ 'CM': 'Cameroon',
42
+ 'CA': 'Canada',
43
+ 'CV': 'Cape Verde',
44
+ 'KY': 'Cayman Islands',
45
+ 'CF': 'Central African Republic',
46
+ 'TD': 'Chad',
47
+ 'CL': 'Chile',
48
+ 'CN': 'China',
49
+ 'CO': 'Colombia',
50
+ 'KM': 'Comoros',
51
+ 'CG': 'Congo',
52
+ 'CD': 'Congo, Democratic Republic of the',
53
+ 'CR': 'Costa Rica',
54
+ 'CI': 'Cote d\'Ivoire',
55
+ 'HR': 'Croatia',
56
+ 'CU': 'Cuba',
57
+ 'CY': 'Cyprus',
58
+ 'CZ': 'Czech Republic',
59
+ 'DK': 'Denmark',
60
+ 'DJ': 'Djibouti',
61
+ 'DM': 'Dominica',
62
+ 'DO': 'Dominican Republic',
63
+ 'EC': 'Ecuador',
64
+ 'EG': 'Egypt',
65
+ 'SV': 'El Salvador',
66
+ 'GQ': 'Equatorial Guinea',
67
+ 'ER': 'Eritrea',
68
+ 'EE': 'Estonia',
69
+ 'ET': 'Ethiopia',
70
+ 'FJ': 'Fiji',
71
+ 'FI': 'Finland',
72
+ 'FR': 'France',
73
+ 'GA': 'Gabon',
74
+ 'GM': 'Gambia',
75
+ 'GE': 'Georgia',
76
+ 'DE': 'Germany',
77
+ 'GH': 'Ghana',
78
+ 'GR': 'Greece',
79
+ 'GL': 'Greenland',
80
+ 'GD': 'Grenada',
81
+ 'GU': 'Guam',
82
+ 'GT': 'Guatemala',
83
+ 'GN': 'Guinea',
84
+ 'GW': 'Guinea-Bissau',
85
+ 'GY': 'Guyana',
86
+ 'HT': 'Haiti',
87
+ 'HN': 'Honduras',
88
+ 'HK': 'Hong Kong',
89
+ 'HU': 'Hungary',
90
+ 'IS': 'Iceland',
91
+ 'IN': 'India',
92
+ 'ID': 'Indonesia',
93
+ 'IR': 'Iran',
94
+ 'IQ': 'Iraq',
95
+ 'IE': 'Ireland',
96
+ 'IL': 'Israel',
97
+ 'IT': 'Italy',
98
+ 'JM': 'Jamaica',
99
+ 'JP': 'Japan',
100
+ 'JO': 'Jordan',
101
+ 'KZ': 'Kazakhstan',
102
+ 'KE': 'Kenya',
103
+ 'KI': 'Kiribati',
104
+ 'KP': 'Korea (North)',
105
+ 'KR': 'Korea (South)',
106
+ 'KW': 'Kuwait',
107
+ 'KG': 'Kyrgyzstan',
108
+ 'LA': 'Lao PDR',
109
+ 'LV': 'Latvia',
110
+ 'LB': 'Lebanon',
111
+ 'LS': 'Lesotho',
112
+ 'LR': 'Liberia',
113
+ 'LY': 'Libya',
114
+ 'LI': 'Liechtenstein',
115
+ 'LT': 'Lithuania',
116
+ 'LU': 'Luxembourg',
117
+ 'MO': 'Macao',
118
+ 'MK': 'Macedonia',
119
+ 'MG': 'Madagascar',
120
+ 'MW': 'Malawi',
121
+ 'MY': 'Malaysia',
122
+ 'MV': 'Maldives',
123
+ 'ML': 'Mali',
124
+ 'MT': 'Malta',
125
+ 'MH': 'Marshall Islands',
126
+ 'MR': 'Mauritania',
127
+ 'MU': 'Mauritius',
128
+ 'MX': 'Mexico',
129
+ 'FM': 'Micronesia',
130
+ 'MD': 'Moldova',
131
+ 'MC': 'Monaco',
132
+ 'MN': 'Mongolia',
133
+ 'ME': 'Montenegro',
134
+ 'MA': 'Morocco',
135
+ 'MZ': 'Mozambique',
136
+ 'MM': 'Myanmar',
137
+ 'NA': 'Namibia',
138
+ 'NR': 'Nauru',
139
+ 'NP': 'Nepal',
140
+ 'NL': 'Netherlands',
141
+ 'NZ': 'New Zealand',
142
+ 'NI': 'Nicaragua',
143
+ 'NE': 'Niger',
144
+ 'NG': 'Nigeria',
145
+ 'NU': 'Niue',
146
+ 'NF': 'Norfolk Island',
147
+ 'MP': 'Northern Mariana Islands',
148
+ 'NO': 'Norway',
149
+ 'OM': 'Oman',
150
+ 'PK': 'Pakistan',
151
+ 'PW': 'Palau',
152
+ 'PS': 'Palestine',
153
+ 'PA': 'Panama',
154
+ 'PG': 'Papua New Guinea',
155
+ 'PY': 'Paraguay',
156
+ 'PE': 'Peru',
157
+ 'PH': 'Philippines',
158
+ 'PL': 'Poland',
159
+ 'PT': 'Portugal',
160
+ 'PR': 'Puerto Rico',
161
+ 'QA': 'Qatar',
162
+ 'RO': 'Romania',
163
+ 'RU': 'Russian Federation',
164
+ 'RW': 'Rwanda',
165
+ 'WS': 'Samoa',
166
+ 'SM': 'San Marino',
167
+ 'ST': 'Sao Tome and Principe',
168
+ 'SA': 'Saudi Arabia',
169
+ 'SN': 'Senegal',
170
+ 'RS': 'Serbia',
171
+ 'SC': 'Seychelles',
172
+ 'SL': 'Sierra Leone',
173
+ 'SG': 'Singapore',
174
+ 'SK': 'Slovakia',
175
+ 'SI': 'Slovenia',
176
+ 'SB': 'Solomon Islands',
177
+ 'SO': 'Somalia',
178
+ 'ZA': 'South Africa',
179
+ 'ES': 'Spain',
180
+ 'LK': 'Sri Lanka',
181
+ 'SD': 'Sudan',
182
+ 'SR': 'Suriname',
183
+ 'SZ': 'Swaziland',
184
+ 'SE': 'Sweden',
185
+ 'CH': 'Switzerland',
186
+ 'SY': 'Syrian Arab Republic',
187
+ 'TW': 'Taiwan',
188
+ 'TJ': 'Tajikistan',
189
+ 'TZ': 'Tanzania',
190
+ 'TH': 'Thailand',
191
+ 'TL': 'Timor-Leste',
192
+ 'TG': 'Togo',
193
+ 'TO': 'Tonga',
194
+ 'TT': 'Trinidad and Tobago',
195
+ 'TN': 'Tunisia',
196
+ 'TR': 'Turkey',
197
+ 'TM': 'Turkmenistan',
198
+ 'TV': 'Tuvalu',
199
+ 'UG': 'Uganda',
200
+ 'UA': 'Ukraine',
201
+ 'AE': 'United Arab Emirates',
202
+ 'GB': 'United Kingdom',
203
+ 'US': 'United States',
204
+ 'UY': 'Uruguay',
205
+ 'UZ': 'Uzbekistan',
206
+ 'VU': 'Vanuatu',
207
+ 'VE': 'Venezuela',
208
+ 'VN': 'Viet Nam',
209
+ 'YE': 'Yemen',
210
+ 'ZM': 'Zambia',
211
+ 'ZW': 'Zimbabwe'
212
+ };
213
+ export function getCountryNameByCode(code) {
214
+ var countryName = countryCodesToName[code.toUpperCase()];
215
+ return countryName || code.toUpperCase();
216
+ }
@@ -0,0 +1,169 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import React from "react";
38
+ import { Button, Stack, Typography } from "@mui/material";
39
+ import theme from "../theme";
40
+ import GppGoodOutlinedIcon from '@mui/icons-material/GppGoodOutlined';
41
+ import { useSpeedTest } from "../speedTest/SpeedProvider";
42
+ import berifymeApi from "../../api/api";
43
+ import { useEffect, useState } from "react";
44
+ import TryAgain from "../TryAgain";
45
+ import { v4 as uuidv4 } from 'uuid';
46
+ import { createDeveloperLog } from "../createDeveloperLog";
47
+ var createDeviceId = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
48
+ var newDeviceId;
49
+ var userId = _b.userId;
50
+ return __generator(this, function (_c) {
51
+ switch (_c.label) {
52
+ case 0:
53
+ newDeviceId = uuidv4();
54
+ if (!newDeviceId)
55
+ return [2 /*return*/];
56
+ localStorage.setItem('deviceId', newDeviceId); // 保存到 LocalStorage
57
+ return [4 /*yield*/, berifymeApi.user.uploadDeviceId({ id: userId, deviceId: newDeviceId })];
58
+ case 1:
59
+ _c.sent();
60
+ return [2 /*return*/];
61
+ }
62
+ });
63
+ }); };
64
+ var AllSet = function (_a) {
65
+ var user = _a.user, token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId;
66
+ var _b = useState(''), error = _b[0], setError = _b[1];
67
+ var _c = useState(), desktopStatusMessage = _c[0], setDesktopStatusMessage = _c[1];
68
+ var checkOldDeviceId = function () { return __awaiter(void 0, void 0, void 0, function () {
69
+ var deviceId, deviceUser;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0:
73
+ if (!user)
74
+ return [2 /*return*/]; //沒有user也不用拿deviceId了
75
+ if (!user.phoneNumber)
76
+ return [2 /*return*/]; //沒有phoneNumber也不用拿deviceId了
77
+ if (!token)
78
+ return [2 /*return*/];
79
+ deviceId = localStorage.getItem('deviceId');
80
+ if (!deviceId) return [3 /*break*/, 4];
81
+ return [4 /*yield*/, berifymeApi.user.checkDeviceId({ phoneNumber: user.phoneNumber, deviceId: deviceId, token: token })];
82
+ case 1:
83
+ deviceUser = _a.sent();
84
+ if (!deviceUser.error) return [3 /*break*/, 3];
85
+ return [4 /*yield*/, createDeviceId({ userId: user.id })];
86
+ case 2:
87
+ _a.sent();
88
+ _a.label = 3;
89
+ case 3: return [3 /*break*/, 6];
90
+ case 4: //未註冊過, 註冊
91
+ return [4 /*yield*/, createDeviceId({ userId: user.id })];
92
+ case 5:
93
+ _a.sent();
94
+ _a.label = 6;
95
+ case 6: return [2 /*return*/];
96
+ }
97
+ });
98
+ }); };
99
+ useEffect(function () {
100
+ checkOldDeviceId();
101
+ }, [user === null || user === void 0 ? void 0 : user.phoneNumber]);
102
+ var checkAndIssueToken = function () {
103
+ // if (user) {
104
+ // berifymeApi.blockchain.checkAndIssueToken({ userId: user.id });
105
+ // }
106
+ };
107
+ var startSpeedTest = useSpeedTest().startSpeedTest;
108
+ useEffect(function () {
109
+ startSpeedTest();
110
+ checkAndIssueToken();
111
+ }, []);
112
+ var handleButtonClick = function () { return __awaiter(void 0, void 0, void 0, function () {
113
+ var res;
114
+ return __generator(this, function (_a) {
115
+ switch (_a.label) {
116
+ case 0:
117
+ if (!user)
118
+ return [2 /*return*/];
119
+ if (!token)
120
+ return [2 /*return*/];
121
+ return [4 /*yield*/, berifymeApi.thirdParty.getRedirectUrl({ userId: user.id, token: token })];
122
+ case 1:
123
+ res = _a.sent();
124
+ createDeveloperLog({
125
+ userId: user === null || user === void 0 ? void 0 : user.id,
126
+ source: 'FRONTEND',
127
+ action: 'getRedirectUrl',
128
+ sessionToken: token,
129
+ });
130
+ if (!res.redirectUrl) {
131
+ setError('Oops! Something went wrong...');
132
+ return [2 /*return*/];
133
+ }
134
+ if (desktopRedirectUrlId === undefined) {
135
+ window.location.href = res.redirectUrl;
136
+ }
137
+ else {
138
+ if (res.heartbeatStopped)
139
+ setDesktopStatusMessage('Session interrupted. Please retry.');
140
+ else
141
+ setDesktopStatusMessage('ID verification successful. Continue on your PC.');
142
+ }
143
+ return [2 /*return*/];
144
+ }
145
+ });
146
+ }); };
147
+ return (React.createElement(React.Fragment, null, error ?
148
+ React.createElement(TryAgain, { message: error }) :
149
+ React.createElement(React.Fragment, null, desktopStatusMessage ?
150
+ React.createElement(Stack, { height: 1, justifyContent: "center", alignItems: "center" },
151
+ React.createElement(Stack, { alignItems: "center", spacing: 2 },
152
+ React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
153
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, desktopStatusMessage)))
154
+ :
155
+ React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
156
+ React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
157
+ React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
158
+ React.createElement(Typography, { variant: "h2", fontWeight: 700 },
159
+ "You\u2019re Berified,",
160
+ React.createElement("br", null), user === null || user === void 0 ? void 0 :
161
+ user.fullName),
162
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Thank you for securely verifying your identity through Berify.me \uD83C\uDF89")),
163
+ React.createElement(Stack, { spacing: 2, alignItems: 'center' },
164
+ React.createElement(Button, { variant: "contained", onClick: function () { handleButtonClick(); }, sx: { minWidth: 160 } }, "Continue")),
165
+ React.createElement(Stack, { direction: 'row', spacing: 2, textAlign: 'center', justifyContent: 'center', color: theme.palette.text.secondary },
166
+ React.createElement(GppGoodOutlinedIcon, null),
167
+ React.createElement(Typography, { variant: "body1" }, "Securely powered by Berify.me"))))));
168
+ };
169
+ export default AllSet;
@@ -0,0 +1,148 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import berifymeApi from "../api/api";
38
+ export var createAuthenticationLog = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
39
+ var userAgent, os, osVersion, device, androidVersionMatch, iosVersionMatch, browser;
40
+ var userId = _b.userId, vender = _b.vender, token = _b.token, transactionId = _b.transactionId, incodeSessionId = _b.incodeSessionId, clearSessionId = _b.clearSessionId, isPass = _b.isPass, actionType = _b.actionType;
41
+ return __generator(this, function (_c) {
42
+ switch (_c.label) {
43
+ case 0:
44
+ userAgent = navigator.userAgent || navigator.vendor || window.opera;
45
+ os = "Unknown";
46
+ osVersion = null;
47
+ device = null;
48
+ // 判断操作系统
49
+ if (/android/i.test(userAgent)) {
50
+ os = "Android";
51
+ androidVersionMatch = userAgent.match(/Android\s+([\d.]+)/);
52
+ if (androidVersionMatch && androidVersionMatch.length > 1) {
53
+ osVersion = androidVersionMatch[1];
54
+ }
55
+ }
56
+ else if (/iPad|iPhone|iPod/.test(userAgent) && !("MSStream" in window)) {
57
+ os = "iOS";
58
+ iosVersionMatch = userAgent.match(/OS (\d+_\d+)/);
59
+ if (iosVersionMatch && iosVersionMatch.length > 1) {
60
+ osVersion = iosVersionMatch[1].replace('_', '.');
61
+ }
62
+ }
63
+ else if (/Win/.test(userAgent)) {
64
+ os = "Windows";
65
+ }
66
+ else if (/Mac/.test(userAgent)) {
67
+ os = "MacOS";
68
+ }
69
+ else if (/Linux/.test(userAgent)) {
70
+ os = "Linux";
71
+ }
72
+ // 判断设备类型
73
+ if (/iPhone/.test(userAgent)) {
74
+ device = "iPhone";
75
+ }
76
+ else if (/iPad/.test(userAgent)) {
77
+ device = "iPad";
78
+ }
79
+ else if (/Android/.test(userAgent)) {
80
+ device = "Android Device";
81
+ }
82
+ else if (/Windows/.test(userAgent)) {
83
+ device = "Windows PC";
84
+ }
85
+ else if (/Macintosh/.test(userAgent)) {
86
+ device = "Mac";
87
+ }
88
+ else {
89
+ device = "Unknown Device";
90
+ }
91
+ browser = userAgent;
92
+ console.log({
93
+ actionType: actionType,
94
+ userId: userId,
95
+ vender: vender,
96
+ token: token,
97
+ userAgent: userAgent,
98
+ os: os,
99
+ osVersion: osVersion,
100
+ browser: browser,
101
+ device: device,
102
+ transactionId: transactionId,
103
+ incodeSessionId: incodeSessionId,
104
+ clearSessionId: clearSessionId,
105
+ isPass: isPass
106
+ });
107
+ return [4 /*yield*/, berifymeApi.AuthenticationLogs.createAuthenticationLogs({
108
+ actionType: actionType,
109
+ userId: userId,
110
+ vender: vender,
111
+ token: token,
112
+ os: osVersion ? "".concat(os, " ").concat(osVersion) : os,
113
+ browser: browser,
114
+ device: device,
115
+ transactionId: transactionId,
116
+ incodeSessionId: incodeSessionId,
117
+ clearSessionId: clearSessionId,
118
+ isPass: isPass,
119
+ })];
120
+ case 1:
121
+ _c.sent();
122
+ return [2 /*return*/];
123
+ }
124
+ });
125
+ }); };
126
+ export var updateAuthenticationLog = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
127
+ var isPass = _b.isPass, transactionId = _b.transactionId, incodeSessionId = _b.incodeSessionId, clearSessionId = _b.clearSessionId;
128
+ return __generator(this, function (_c) {
129
+ switch (_c.label) {
130
+ case 0:
131
+ console.log({
132
+ isPass: isPass,
133
+ transactionId: transactionId,
134
+ incodeSessionId: incodeSessionId,
135
+ clearSessionId: clearSessionId,
136
+ });
137
+ return [4 /*yield*/, berifymeApi.AuthenticationLogs.updateAuthenticationLogs({
138
+ isPass: isPass,
139
+ transactionId: transactionId,
140
+ incodeSessionId: incodeSessionId,
141
+ clearSessionId: clearSessionId
142
+ })];
143
+ case 1:
144
+ _c.sent();
145
+ return [2 /*return*/];
146
+ }
147
+ });
148
+ }); };