@authme/util 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 +339 -59
- package/index.js +331 -59
- package/package.json +3 -1
- package/src/lib/authme-error.d.ts +2 -1
- package/src/lib/common/client-info.service.d.ts +2 -0
- package/src/lib/common/index.d.ts +6 -0
- package/src/lib/common/jwt-decode.service.d.ts +19 -0
- package/src/lib/common/state.service.d.ts +4 -0
- package/src/lib/storage/storage.d.ts +7 -0
package/index.cjs
CHANGED
|
@@ -11,15 +11,19 @@ require('core-js/modules/es.typed-array.sort.js');
|
|
|
11
11
|
require('core-js/modules/es.typed-array.to-locale-string.js');
|
|
12
12
|
require('core-js/modules/es.promise.js');
|
|
13
13
|
require('core-js/modules/es.regexp.exec.js');
|
|
14
|
+
require('core-js/modules/es.regexp.to-string.js');
|
|
14
15
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
16
|
+
require('core-js/modules/es.object.assign.js');
|
|
17
|
+
require('core-js/modules/es.number.parse-int.js');
|
|
18
|
+
var jwt_decode = require('jwt-decode');
|
|
19
|
+
require('core-js/modules/es.string.match.js');
|
|
20
|
+
require('core-js/modules/es.string.replace.js');
|
|
15
21
|
require('core-js/modules/web.url-search-params.js');
|
|
16
22
|
require('core-js/modules/es.string.search.js');
|
|
17
|
-
require('
|
|
23
|
+
var Lottie = require('lottie-web');
|
|
18
24
|
require('core-js/modules/es.array.sort.js');
|
|
19
25
|
require('core-js/modules/es.array.includes.js');
|
|
20
26
|
require('core-js/modules/es.string.includes.js');
|
|
21
|
-
var lottie = require('lottie-web');
|
|
22
|
-
require('core-js/modules/es.string.replace.js');
|
|
23
27
|
require('core-js/modules/es.parse-int.js');
|
|
24
28
|
require('core-js/modules/es.string.trim.js');
|
|
25
29
|
require('core-js/modules/es.string.starts-with.js');
|
|
@@ -27,23 +31,33 @@ require('core-js/modules/es.symbol.description.js');
|
|
|
27
31
|
|
|
28
32
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
29
33
|
|
|
30
|
-
var
|
|
34
|
+
var jwt_decode__default = /*#__PURE__*/_interopDefaultLegacy(jwt_decode);
|
|
35
|
+
var Lottie__default = /*#__PURE__*/_interopDefaultLegacy(Lottie);
|
|
31
36
|
|
|
32
37
|
const GLOBAL_KEY = '_AuthmeConfig';
|
|
38
|
+
const _storage = {};
|
|
39
|
+
exports.STORAGE_KEY = void 0;
|
|
40
|
+
(function (STORAGE_KEY) {
|
|
41
|
+
STORAGE_KEY["LOADING_LOTTIE"] = "loadingLottie";
|
|
42
|
+
STORAGE_KEY["OCR_IDCARD_RESULT_FORMAT"] = "ocrIdcardResultFormat";
|
|
43
|
+
STORAGE_KEY["ENABLE_EVENT_TRACKING"] = "enableEventTracking";
|
|
44
|
+
STORAGE_KEY["EVENT_TRACK_URL"] = "eventTrackUrl";
|
|
45
|
+
STORAGE_KEY["API_BASE_URL"] = "apiBaseUrl";
|
|
46
|
+
})(exports.STORAGE_KEY || (exports.STORAGE_KEY = {}));
|
|
33
47
|
function getItem(key) {
|
|
34
|
-
return
|
|
48
|
+
return _storage[GLOBAL_KEY][key];
|
|
35
49
|
}
|
|
36
50
|
function setItem(key, val) {
|
|
37
|
-
if (!
|
|
38
|
-
|
|
51
|
+
if (!_storage[GLOBAL_KEY]) {
|
|
52
|
+
_storage[GLOBAL_KEY] = {};
|
|
39
53
|
}
|
|
40
|
-
return
|
|
54
|
+
return _storage[GLOBAL_KEY][key] = val;
|
|
41
55
|
}
|
|
42
56
|
function removeItem(key) {
|
|
43
|
-
return delete
|
|
57
|
+
return delete _storage[GLOBAL_KEY][key];
|
|
44
58
|
}
|
|
45
59
|
function clear() {
|
|
46
|
-
|
|
60
|
+
_storage[GLOBAL_KEY] = {};
|
|
47
61
|
}
|
|
48
62
|
const Storage = {
|
|
49
63
|
getItem,
|
|
@@ -67,6 +81,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
67
81
|
PERFORMANCE OF THIS SOFTWARE.
|
|
68
82
|
***************************************************************************** */
|
|
69
83
|
|
|
84
|
+
function __rest(s, e) {
|
|
85
|
+
var t = {};
|
|
86
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
87
|
+
t[p] = s[p];
|
|
88
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
89
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
90
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
91
|
+
t[p[i]] = s[p[i]];
|
|
92
|
+
}
|
|
93
|
+
return t;
|
|
94
|
+
}
|
|
95
|
+
|
|
70
96
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
71
97
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
72
98
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -113,6 +139,187 @@ function __asyncValues(o) {
|
|
|
113
139
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
114
140
|
}
|
|
115
141
|
|
|
142
|
+
class AuthmeError {
|
|
143
|
+
constructor(code, cause = null) {
|
|
144
|
+
this._cause = null;
|
|
145
|
+
this._code = null;
|
|
146
|
+
this._code = code;
|
|
147
|
+
this._cause = cause;
|
|
148
|
+
}
|
|
149
|
+
get message() {
|
|
150
|
+
return '[Authme SDK Error] Code: ' + this.code;
|
|
151
|
+
}
|
|
152
|
+
setCode(code) {
|
|
153
|
+
this._code = code;
|
|
154
|
+
}
|
|
155
|
+
get code() {
|
|
156
|
+
return this._code;
|
|
157
|
+
}
|
|
158
|
+
get cause() {
|
|
159
|
+
return this._cause;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.ErrorCode = void 0;
|
|
163
|
+
(function (ErrorCode) {
|
|
164
|
+
// 1XX for engine
|
|
165
|
+
ErrorCode[ErrorCode["BROWSER_NOT_SUPPORT"] = 100] = "BROWSER_NOT_SUPPORT";
|
|
166
|
+
ErrorCode[ErrorCode["ENGINE_INIT_ERROR"] = 101] = "ENGINE_INIT_ERROR";
|
|
167
|
+
ErrorCode[ErrorCode["ENGINE_MODULE_IS_INITIALIZING"] = 102] = "ENGINE_MODULE_IS_INITIALIZING";
|
|
168
|
+
ErrorCode[ErrorCode["ENGINE_MODULE_INIT_ERROR"] = 103] = "ENGINE_MODULE_INIT_ERROR";
|
|
169
|
+
ErrorCode[ErrorCode["RECOGNITION_NOT_AVAILABLE"] = 104] = "RECOGNITION_NOT_AVAILABLE";
|
|
170
|
+
ErrorCode[ErrorCode["RECOGNITION_ERROR"] = 105] = "RECOGNITION_ERROR";
|
|
171
|
+
ErrorCode[ErrorCode["INVALID_AUTH_ERROR"] = 106] = "INVALID_AUTH_ERROR";
|
|
172
|
+
ErrorCode[ErrorCode["SCREEN_RESOLUTION_TOO_LOW"] = 107] = "SCREEN_RESOLUTION_TOO_LOW";
|
|
173
|
+
ErrorCode[ErrorCode["SCREEN_SIZE_CHANGED"] = 108] = "SCREEN_SIZE_CHANGED";
|
|
174
|
+
// 2 for LIVENESS
|
|
175
|
+
ErrorCode[ErrorCode["LIVENESS_NOT_PASSED"] = 201] = "LIVENESS_NOT_PASSED";
|
|
176
|
+
// 3 for ID-Recognition
|
|
177
|
+
ErrorCode[ErrorCode["ID_RECOGNITION_CONFIRM_INFO_ERROR"] = 301] = "ID_RECOGNITION_CONFIRM_INFO_ERROR";
|
|
178
|
+
ErrorCode[ErrorCode["ID_RECOGNITION_TIMEOUT"] = 302] = "ID_RECOGNITION_TIMEOUT";
|
|
179
|
+
// 4 for Anti-fraud
|
|
180
|
+
ErrorCode[ErrorCode["ID_RECOGNITION_ANTI_FRAUD_NOT_PASSED"] = 401] = "ID_RECOGNITION_ANTI_FRAUD_NOT_PASSED";
|
|
181
|
+
// 9 for common
|
|
182
|
+
ErrorCode[ErrorCode["SDK_INTERNAL_ERROR"] = 900] = "SDK_INTERNAL_ERROR";
|
|
183
|
+
ErrorCode[ErrorCode["NETWORK_ERROR"] = 901] = "NETWORK_ERROR";
|
|
184
|
+
ErrorCode[ErrorCode["HTTP_ERROR_RESPONSE"] = 902] = "HTTP_ERROR_RESPONSE";
|
|
185
|
+
ErrorCode[ErrorCode["USER_CANCEL"] = 903] = "USER_CANCEL";
|
|
186
|
+
ErrorCode[ErrorCode["CAMERA_NOT_SUPPORT"] = 904] = "CAMERA_NOT_SUPPORT";
|
|
187
|
+
ErrorCode[ErrorCode["SERVER_ERROR"] = 905] = "SERVER_ERROR";
|
|
188
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
189
|
+
|
|
190
|
+
function decodeToken(token) {
|
|
191
|
+
const decoded = jwt_decode__default["default"](token);
|
|
192
|
+
const {
|
|
193
|
+
exp,
|
|
194
|
+
iat
|
|
195
|
+
} = decoded;
|
|
196
|
+
return {
|
|
197
|
+
payload: decoded,
|
|
198
|
+
exp: typeof exp === 'number' ? exp : 0,
|
|
199
|
+
iat: typeof iat === 'number' ? iat : 0
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function getDeviceInfo() {
|
|
204
|
+
const userAgent = window.navigator.userAgent;
|
|
205
|
+
const deviceType = getDeviceType(userAgent);
|
|
206
|
+
const browserType = getBrowserType(userAgent);
|
|
207
|
+
return `${deviceType} (${browserType})`;
|
|
208
|
+
}
|
|
209
|
+
function getDeviceType(userAgent) {
|
|
210
|
+
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
|
|
211
|
+
return 'iPad/iPhone';
|
|
212
|
+
} else if (userAgent.match(/Android/i)) {
|
|
213
|
+
return 'Android';
|
|
214
|
+
} else if (userAgent.match(/Windows Phone/i)) {
|
|
215
|
+
return 'Windows Phone';
|
|
216
|
+
} else if (userAgent.match(/Windows NT/i)) {
|
|
217
|
+
return 'Windows PC';
|
|
218
|
+
} else if (userAgent.match(/Mac OS/i)) {
|
|
219
|
+
return 'Mac';
|
|
220
|
+
} else if (userAgent.match(/Linux/i)) {
|
|
221
|
+
return 'Linux';
|
|
222
|
+
} else {
|
|
223
|
+
return 'Unknown Device';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function getBrowserType(userAgent) {
|
|
227
|
+
if (userAgent.match(/Chrome/i)) {
|
|
228
|
+
return 'Chrome';
|
|
229
|
+
} else if (userAgent.match(/Firefox/i)) {
|
|
230
|
+
return 'Firefox';
|
|
231
|
+
} else if (userAgent.match(/Edge/i)) {
|
|
232
|
+
return 'Edge';
|
|
233
|
+
} else if (userAgent.match(/Safari/i)) {
|
|
234
|
+
return 'Safari';
|
|
235
|
+
} else if (userAgent.match(/MSIE/i) || userAgent.match(/Trident/i)) {
|
|
236
|
+
return 'IE';
|
|
237
|
+
} else {
|
|
238
|
+
return 'Unknown Browser';
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function getSystemInfo() {
|
|
242
|
+
const userAgent = window.navigator.userAgent;
|
|
243
|
+
const os = getOs(userAgent);
|
|
244
|
+
const osVersion = getOsVersion(userAgent);
|
|
245
|
+
return `${os} (${osVersion})`;
|
|
246
|
+
}
|
|
247
|
+
function getOs(userAgent) {
|
|
248
|
+
if (userAgent.match(/Windows NT 10/i)) {
|
|
249
|
+
return 'Windows 10';
|
|
250
|
+
} else if (userAgent.match(/Windows NT 6.3/i)) {
|
|
251
|
+
return 'Windows 8.1';
|
|
252
|
+
} else if (userAgent.match(/Windows NT 6.2/i)) {
|
|
253
|
+
return 'Windows 8';
|
|
254
|
+
} else if (userAgent.match(/Windows NT 6.1/i)) {
|
|
255
|
+
return 'Windows 7';
|
|
256
|
+
} else if (userAgent.match(/Windows NT 6.0/i)) {
|
|
257
|
+
return 'Windows Vista';
|
|
258
|
+
} else if (userAgent.match(/Windows NT 5.1/i)) {
|
|
259
|
+
return 'Windows XP';
|
|
260
|
+
} else if (userAgent.match(/Windows NT 5.0/i)) {
|
|
261
|
+
return 'Windows 2000';
|
|
262
|
+
} else if (userAgent.match(/Mac/i)) {
|
|
263
|
+
return 'Mac OS';
|
|
264
|
+
} else if (userAgent.match(/Linux/i)) {
|
|
265
|
+
return 'Linux';
|
|
266
|
+
} else {
|
|
267
|
+
return 'Unknown OS';
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function getOsVersion(userAgent) {
|
|
271
|
+
if (userAgent.match(/Windows NT/i)) {
|
|
272
|
+
const matches = userAgent.match(/Windows NT ([\d\\.]+)/i);
|
|
273
|
+
if (matches) {
|
|
274
|
+
return matches[1];
|
|
275
|
+
} else {
|
|
276
|
+
return '';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (userAgent.match(/Mac/i)) {
|
|
280
|
+
const matches = userAgent.match(/Mac OS X ([\d_.]+)/i);
|
|
281
|
+
if (matches) {
|
|
282
|
+
return matches[1].replace(/_/g, '.');
|
|
283
|
+
} else {
|
|
284
|
+
return '';
|
|
285
|
+
}
|
|
286
|
+
} else if (userAgent.match(/Android/i)) {
|
|
287
|
+
const matches = userAgent.match(/Android ([\d.]+)/i);
|
|
288
|
+
if (matches) {
|
|
289
|
+
return matches[1];
|
|
290
|
+
} else {
|
|
291
|
+
return '';
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
return '';
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
class State {
|
|
299
|
+
constructor(initialValue = null) {
|
|
300
|
+
this._value = initialValue;
|
|
301
|
+
}
|
|
302
|
+
getValue() {
|
|
303
|
+
return this._value;
|
|
304
|
+
}
|
|
305
|
+
setValue(newValue) {
|
|
306
|
+
this._value = newValue;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function useState(initialValue = null, subscription) {
|
|
310
|
+
const state = new State(initialValue);
|
|
311
|
+
function getValue() {
|
|
312
|
+
return state.getValue();
|
|
313
|
+
}
|
|
314
|
+
function setValue(newValue) {
|
|
315
|
+
if (subscription && newValue !== state.getValue()) {
|
|
316
|
+
subscription.next(newValue);
|
|
317
|
+
}
|
|
318
|
+
state.setValue(newValue);
|
|
319
|
+
}
|
|
320
|
+
return [getValue, setValue];
|
|
321
|
+
}
|
|
322
|
+
|
|
116
323
|
function dataURItoBlob(dataURI) {
|
|
117
324
|
// convert base64/URLEncoded data component to raw binary data held in a string
|
|
118
325
|
const byteString = atob(dataURI.split(',')[1]);
|
|
@@ -164,7 +371,9 @@ function retryPromiseWithCondition(promiseFactory, conditionFactory) {
|
|
|
164
371
|
const res = yield promiseFactory();
|
|
165
372
|
return res;
|
|
166
373
|
} catch (e) {
|
|
167
|
-
|
|
374
|
+
if ((e === null || e === void 0 ? void 0 : e._code) === exports.ErrorCode.SERVER_ERROR) {
|
|
375
|
+
throw e;
|
|
376
|
+
}
|
|
168
377
|
const retry = yield conditionFactory(e);
|
|
169
378
|
if (retry) {
|
|
170
379
|
return retryPromiseWithCondition(promiseFactory, conditionFactory);
|
|
@@ -187,53 +396,87 @@ function isMobile() {
|
|
|
187
396
|
return !!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4)) || /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
|
|
188
397
|
}(navigator.userAgent || navigator.vendor || window.opera);
|
|
189
398
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
399
|
+
function splitResult(result) {
|
|
400
|
+
if (result.address) {
|
|
401
|
+
const originAddress = result.address;
|
|
402
|
+
const address1Index = checkCity(originAddress);
|
|
403
|
+
result.address1 = address1Index === -1 ? '' : originAddress.slice(0, 3);
|
|
404
|
+
const address2 = address1Index === -1 ? originAddress : originAddress.slice(3);
|
|
405
|
+
const address2Index = checkZone(address2);
|
|
406
|
+
result.address2 = address2Index === -1 ? '' : address2.slice(0, address2Index + 1);
|
|
407
|
+
result.address3 = address2Index === -1 ? address2 : address2.slice(address2Index + 1);
|
|
197
408
|
}
|
|
198
|
-
|
|
199
|
-
|
|
409
|
+
if (result.dateOfBirth) {
|
|
410
|
+
const splitDateOfBirth = result.dateOfBirth.split('-');
|
|
411
|
+
const dateOfBirthY = (+splitDateOfBirth[0] - 1911).toString();
|
|
412
|
+
result.dateOfBirthY = dateOfBirthY.length < 3 ? '0' + dateOfBirthY : dateOfBirthY;
|
|
413
|
+
result.dateOfBirthM = splitDateOfBirth[1];
|
|
414
|
+
result.dateOfBirthD = splitDateOfBirth[2];
|
|
200
415
|
}
|
|
201
|
-
|
|
202
|
-
|
|
416
|
+
if (result.dateOfIssue) {
|
|
417
|
+
const splitDateOfIssue = result.dateOfIssue.split('-');
|
|
418
|
+
const dateOfIssueY = (+splitDateOfIssue[0] - 1911).toString();
|
|
419
|
+
result.dateOfIssueY = dateOfIssueY.length < 3 ? '0' + dateOfIssueY : dateOfIssueY;
|
|
420
|
+
result.dateOfIssueM = splitDateOfIssue[1];
|
|
421
|
+
result.dateOfIssueD = splitDateOfIssue[2];
|
|
203
422
|
}
|
|
204
|
-
|
|
205
|
-
|
|
423
|
+
return result;
|
|
424
|
+
}
|
|
425
|
+
function checkCity(address) {
|
|
426
|
+
const citys = ['臺北市', '臺中市', '基隆市', '臺南市', '高雄市', '新北市', '宜蘭縣', '桃園市', '嘉義市', '新竹縣', '苗栗縣', '南投縣', '彰化縣', '新竹市', '雲林縣', '嘉義縣', '屏東縣', '花蓮縣', '臺東縣', '金門縣', '澎湖縣', '連江縣', '臺中縣', '臺南縣', '高雄縣'];
|
|
427
|
+
for (const city of citys) {
|
|
428
|
+
if (address.indexOf(city) !== -1) {
|
|
429
|
+
return address.indexOf(city);
|
|
430
|
+
}
|
|
206
431
|
}
|
|
207
|
-
|
|
208
|
-
|
|
432
|
+
return -1;
|
|
433
|
+
}
|
|
434
|
+
function checkZone(address) {
|
|
435
|
+
const zones = ['鄉', '鎮', '市', '區'];
|
|
436
|
+
for (const zone of zones) {
|
|
437
|
+
if (address.indexOf(zone) !== -1) {
|
|
438
|
+
return address.indexOf(zone);
|
|
439
|
+
}
|
|
209
440
|
}
|
|
441
|
+
return -1;
|
|
210
442
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
443
|
+
function notEmpty(value) {
|
|
444
|
+
return typeof value !== 'undefined' && value !== null && value !== '';
|
|
445
|
+
}
|
|
446
|
+
function combineResult(result) {
|
|
447
|
+
const {
|
|
448
|
+
address1,
|
|
449
|
+
address2,
|
|
450
|
+
address3,
|
|
451
|
+
dateOfBirthY,
|
|
452
|
+
dateOfBirthM,
|
|
453
|
+
dateOfBirthD,
|
|
454
|
+
dateOfIssueY,
|
|
455
|
+
dateOfIssueM,
|
|
456
|
+
dateOfIssueD
|
|
457
|
+
} = result,
|
|
458
|
+
others = __rest(result, ["address1", "address2", "address3", "dateOfBirthY", "dateOfBirthM", "dateOfBirthD", "dateOfIssueY", "dateOfIssueM", "dateOfIssueD"]);
|
|
459
|
+
// 由於呼叫函數的情境包含 confirmOCRResult,
|
|
460
|
+
// confirmOCRResult 並不會知道目前是什麼卡片類型,
|
|
461
|
+
// 所以會以分割出的欄位來判斷是否進行欄位合併與覆寫。
|
|
462
|
+
const newResult = Object.assign({}, others);
|
|
463
|
+
if ([address1, address2, address3].every(notEmpty)) {
|
|
464
|
+
newResult.address = `${address1}${address2}${address3}`;
|
|
465
|
+
}
|
|
466
|
+
if ([dateOfBirthY, dateOfBirthM, dateOfBirthD].every(notEmpty)) {
|
|
467
|
+
newResult.dateOfBirth = `${1911 + Number.parseInt(dateOfBirthY || '0')}-${dateOfBirthM}-${dateOfBirthD}`;
|
|
468
|
+
}
|
|
469
|
+
if ([dateOfIssueY, dateOfIssueM, dateOfIssueD].every(notEmpty)) {
|
|
470
|
+
newResult.dateOfIssue = `${1911 + Number.parseInt(dateOfIssueY || '0')}-${dateOfIssueM}-${dateOfIssueD}`;
|
|
471
|
+
}
|
|
472
|
+
return newResult;
|
|
473
|
+
}
|
|
474
|
+
const isIphone14proOrProMax = () => {
|
|
475
|
+
const isIphone = () => {
|
|
476
|
+
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
477
|
+
};
|
|
478
|
+
return isIphone() && (screen.width === 430 && screen.height === 932 || screen.width === 393 && screen.height === 852);
|
|
479
|
+
};
|
|
237
480
|
|
|
238
481
|
function debugLog(message, ...others) {
|
|
239
482
|
if (new URLSearchParams(location.search).get('authme-debug') === 'true') {
|
|
@@ -345,13 +588,37 @@ function cropByRatio(width, height, ratio) {
|
|
|
345
588
|
}
|
|
346
589
|
|
|
347
590
|
function startSpinner(text) {
|
|
591
|
+
const loadingLottie = Storage.getItem(exports.STORAGE_KEY.LOADING_LOTTIE);
|
|
348
592
|
const body = document.querySelector('.authme-container');
|
|
593
|
+
if (loadingLottie) {
|
|
594
|
+
const loadingSDKOuter = document.createElement('div');
|
|
595
|
+
const loadingSDKContent = document.createElement('div');
|
|
596
|
+
const loadingSDKText = document.createElement('div');
|
|
597
|
+
loadingSDKOuter.classList.add('authme-loading-sdk-outer');
|
|
598
|
+
loadingSDKContent.classList.add('authme-loading-sdk-content');
|
|
599
|
+
loadingSDKOuter.appendChild(loadingSDKContent);
|
|
600
|
+
Lottie__default["default"].loadAnimation({
|
|
601
|
+
container: loadingSDKContent,
|
|
602
|
+
renderer: 'svg',
|
|
603
|
+
loop: true,
|
|
604
|
+
autoplay: true,
|
|
605
|
+
name: 'spinner-loading',
|
|
606
|
+
animationData: loadingLottie
|
|
607
|
+
});
|
|
608
|
+
body === null || body === void 0 ? void 0 : body.appendChild(loadingSDKOuter);
|
|
609
|
+
if (text) {
|
|
610
|
+
loadingSDKText.classList.add('authme-loading-sdk-text');
|
|
611
|
+
loadingSDKText.textContent = text;
|
|
612
|
+
loadingSDKContent.appendChild(loadingSDKText);
|
|
613
|
+
}
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
349
616
|
const spinnerOuter = document.createElement('div');
|
|
350
|
-
spinnerOuter.className = 'loading-outer';
|
|
351
617
|
const spinner = document.createElement('div');
|
|
352
|
-
spinner.className = 'loading';
|
|
353
618
|
const spinnerText = document.createElement('div');
|
|
354
619
|
spinnerOuter.appendChild(spinner);
|
|
620
|
+
spinnerOuter.className = 'loading-outer';
|
|
621
|
+
spinner.className = 'loading';
|
|
355
622
|
if (text) {
|
|
356
623
|
spinnerText.className = 'loading-text';
|
|
357
624
|
spinnerText.textContent = text;
|
|
@@ -360,8 +627,12 @@ function startSpinner(text) {
|
|
|
360
627
|
body === null || body === void 0 ? void 0 : body.appendChild(spinnerOuter);
|
|
361
628
|
}
|
|
362
629
|
function stopSpinner() {
|
|
630
|
+
const loadingLottie = Storage.getItem(exports.STORAGE_KEY.LOADING_LOTTIE);
|
|
363
631
|
const body = document.querySelector('.authme-container');
|
|
364
|
-
|
|
632
|
+
if (loadingLottie) {
|
|
633
|
+
Lottie__default["default"].destroy('spinner-loading');
|
|
634
|
+
}
|
|
635
|
+
const spinner = loadingLottie ? document.querySelector('.authme-loading-sdk-outer') : document.querySelector('.loading-outer');
|
|
365
636
|
if (spinner) {
|
|
366
637
|
body === null || body === void 0 ? void 0 : body.removeChild(spinner);
|
|
367
638
|
}
|
|
@@ -1654,25 +1925,27 @@ const sdk_loading = () => ({
|
|
|
1654
1925
|
});
|
|
1655
1926
|
|
|
1656
1927
|
function startLoadingSDK(text) {
|
|
1928
|
+
const loadingLottie = Storage.getItem(exports.STORAGE_KEY.LOADING_LOTTIE);
|
|
1657
1929
|
const body = document.body;
|
|
1658
1930
|
const loadingSDKOuter = document.createElement('div');
|
|
1659
1931
|
const loadingSDKContent = document.createElement('div');
|
|
1660
1932
|
loadingSDKOuter.classList.add('authme-loading-sdk-outer');
|
|
1661
1933
|
loadingSDKContent.classList.add('authme-loading-sdk-content');
|
|
1662
1934
|
loadingSDKOuter.appendChild(loadingSDKContent);
|
|
1663
|
-
|
|
1935
|
+
Lottie__default["default"].loadAnimation({
|
|
1664
1936
|
container: loadingSDKContent,
|
|
1665
1937
|
renderer: 'svg',
|
|
1666
1938
|
loop: true,
|
|
1667
1939
|
autoplay: true,
|
|
1668
|
-
name: '
|
|
1669
|
-
animationData: sdk_loading()
|
|
1940
|
+
name: 'init-sdk-loading',
|
|
1941
|
+
animationData: loadingLottie ? loadingLottie : sdk_loading()
|
|
1670
1942
|
});
|
|
1671
1943
|
body === null || body === void 0 ? void 0 : body.appendChild(loadingSDKOuter);
|
|
1672
1944
|
}
|
|
1673
1945
|
function stopLoadingSDK() {
|
|
1674
1946
|
const body = document.body;
|
|
1675
1947
|
const loadingSDKOuter = document.querySelector('.authme-loading-sdk-outer');
|
|
1948
|
+
Lottie__default["default"].destroy('init-sdk-loading');
|
|
1676
1949
|
if (loadingSDKOuter) {
|
|
1677
1950
|
body === null || body === void 0 ? void 0 : body.removeChild(loadingSDKOuter);
|
|
1678
1951
|
}
|
|
@@ -1714,7 +1987,7 @@ function RGBToLottieColor(color) {
|
|
|
1714
1987
|
}
|
|
1715
1988
|
|
|
1716
1989
|
var name = "@authme/util";
|
|
1717
|
-
var version$1 = "2.
|
|
1990
|
+
var version$1 = "2.4.2";
|
|
1718
1991
|
var peerDependencies = {
|
|
1719
1992
|
"core-js": "^3.6.0"
|
|
1720
1993
|
};
|
|
@@ -1741,17 +2014,22 @@ exports.checkOnlineStatus = checkOnlineStatus;
|
|
|
1741
2014
|
exports.clearCanvas = clearCanvas;
|
|
1742
2015
|
exports.colorStringToRGB = colorStringToRGB;
|
|
1743
2016
|
exports.colorToRGB = colorToRGB;
|
|
2017
|
+
exports.combineResult = combineResult;
|
|
1744
2018
|
exports.cropByRatio = cropByRatio;
|
|
1745
2019
|
exports.dataURItoBlob = dataURItoBlob;
|
|
1746
2020
|
exports.debugLog = debugLog;
|
|
2021
|
+
exports.decodeToken = decodeToken;
|
|
1747
2022
|
exports.getCanvasSize = getCanvasSize;
|
|
1748
2023
|
exports.getCssVariable = getCssVariable;
|
|
2024
|
+
exports.getDeviceInfo = getDeviceInfo;
|
|
1749
2025
|
exports.getImageData = getImageData;
|
|
2026
|
+
exports.getSystemInfo = getSystemInfo;
|
|
1750
2027
|
exports.getUserAgent = getUserAgent;
|
|
1751
2028
|
exports.hexToRGB = hexToRGB;
|
|
1752
2029
|
exports.hideElement = hideElement;
|
|
1753
2030
|
exports.hideErrorMessage = hideErrorMessage;
|
|
1754
2031
|
exports.hidePopup = hidePopup;
|
|
2032
|
+
exports.isIphone14proOrProMax = isIphone14proOrProMax;
|
|
1755
2033
|
exports.isMobile = isMobile;
|
|
1756
2034
|
exports.isMobileOrTablet = isMobileOrTablet;
|
|
1757
2035
|
exports.requestCamera = requestCamera;
|
|
@@ -1760,10 +2038,12 @@ exports.retryPromiseWithCondition = retryPromiseWithCondition;
|
|
|
1760
2038
|
exports.showElement = showElement;
|
|
1761
2039
|
exports.showErrorMessage = showErrorMessage;
|
|
1762
2040
|
exports.showPopup = showPopup;
|
|
2041
|
+
exports.splitResult = splitResult;
|
|
1763
2042
|
exports.startLoadingSDK = startLoadingSDK;
|
|
1764
2043
|
exports.startSpinner = startSpinner;
|
|
1765
2044
|
exports.stopLoadingSDK = stopLoadingSDK;
|
|
1766
2045
|
exports.stopSpinner = stopSpinner;
|
|
2046
|
+
exports.useState = useState;
|
|
1767
2047
|
exports.version = version;
|
|
1768
2048
|
exports.videoConstraintsFactory = videoConstraintsFactory;
|
|
1769
2049
|
exports.waitTime = waitTime;
|
package/index.js
CHANGED
|
@@ -7,35 +7,48 @@ import 'core-js/modules/es.typed-array.sort.js';
|
|
|
7
7
|
import 'core-js/modules/es.typed-array.to-locale-string.js';
|
|
8
8
|
import 'core-js/modules/es.promise.js';
|
|
9
9
|
import 'core-js/modules/es.regexp.exec.js';
|
|
10
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
|
10
11
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
12
|
+
import 'core-js/modules/es.object.assign.js';
|
|
13
|
+
import 'core-js/modules/es.number.parse-int.js';
|
|
14
|
+
import jwt_decode from 'jwt-decode';
|
|
15
|
+
import 'core-js/modules/es.string.match.js';
|
|
16
|
+
import 'core-js/modules/es.string.replace.js';
|
|
11
17
|
import 'core-js/modules/web.url-search-params.js';
|
|
12
18
|
import 'core-js/modules/es.string.search.js';
|
|
13
|
-
import '
|
|
19
|
+
import Lottie from 'lottie-web';
|
|
14
20
|
import 'core-js/modules/es.array.sort.js';
|
|
15
21
|
import 'core-js/modules/es.array.includes.js';
|
|
16
22
|
import 'core-js/modules/es.string.includes.js';
|
|
17
|
-
import lottie from 'lottie-web';
|
|
18
|
-
import 'core-js/modules/es.string.replace.js';
|
|
19
23
|
import 'core-js/modules/es.parse-int.js';
|
|
20
24
|
import 'core-js/modules/es.string.trim.js';
|
|
21
25
|
import 'core-js/modules/es.string.starts-with.js';
|
|
22
26
|
import 'core-js/modules/es.symbol.description.js';
|
|
23
27
|
|
|
24
28
|
const GLOBAL_KEY = '_AuthmeConfig';
|
|
29
|
+
const _storage = {};
|
|
30
|
+
var STORAGE_KEY;
|
|
31
|
+
(function (STORAGE_KEY) {
|
|
32
|
+
STORAGE_KEY["LOADING_LOTTIE"] = "loadingLottie";
|
|
33
|
+
STORAGE_KEY["OCR_IDCARD_RESULT_FORMAT"] = "ocrIdcardResultFormat";
|
|
34
|
+
STORAGE_KEY["ENABLE_EVENT_TRACKING"] = "enableEventTracking";
|
|
35
|
+
STORAGE_KEY["EVENT_TRACK_URL"] = "eventTrackUrl";
|
|
36
|
+
STORAGE_KEY["API_BASE_URL"] = "apiBaseUrl";
|
|
37
|
+
})(STORAGE_KEY || (STORAGE_KEY = {}));
|
|
25
38
|
function getItem(key) {
|
|
26
|
-
return
|
|
39
|
+
return _storage[GLOBAL_KEY][key];
|
|
27
40
|
}
|
|
28
41
|
function setItem(key, val) {
|
|
29
|
-
if (!
|
|
30
|
-
|
|
42
|
+
if (!_storage[GLOBAL_KEY]) {
|
|
43
|
+
_storage[GLOBAL_KEY] = {};
|
|
31
44
|
}
|
|
32
|
-
return
|
|
45
|
+
return _storage[GLOBAL_KEY][key] = val;
|
|
33
46
|
}
|
|
34
47
|
function removeItem(key) {
|
|
35
|
-
return delete
|
|
48
|
+
return delete _storage[GLOBAL_KEY][key];
|
|
36
49
|
}
|
|
37
50
|
function clear() {
|
|
38
|
-
|
|
51
|
+
_storage[GLOBAL_KEY] = {};
|
|
39
52
|
}
|
|
40
53
|
const Storage = {
|
|
41
54
|
getItem,
|
|
@@ -59,6 +72,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
59
72
|
PERFORMANCE OF THIS SOFTWARE.
|
|
60
73
|
***************************************************************************** */
|
|
61
74
|
|
|
75
|
+
function __rest(s, e) {
|
|
76
|
+
var t = {};
|
|
77
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
78
|
+
t[p] = s[p];
|
|
79
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
80
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
81
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
82
|
+
t[p[i]] = s[p[i]];
|
|
83
|
+
}
|
|
84
|
+
return t;
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
63
88
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
64
89
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -105,6 +130,187 @@ function __asyncValues(o) {
|
|
|
105
130
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
106
131
|
}
|
|
107
132
|
|
|
133
|
+
class AuthmeError {
|
|
134
|
+
constructor(code, cause = null) {
|
|
135
|
+
this._cause = null;
|
|
136
|
+
this._code = null;
|
|
137
|
+
this._code = code;
|
|
138
|
+
this._cause = cause;
|
|
139
|
+
}
|
|
140
|
+
get message() {
|
|
141
|
+
return '[Authme SDK Error] Code: ' + this.code;
|
|
142
|
+
}
|
|
143
|
+
setCode(code) {
|
|
144
|
+
this._code = code;
|
|
145
|
+
}
|
|
146
|
+
get code() {
|
|
147
|
+
return this._code;
|
|
148
|
+
}
|
|
149
|
+
get cause() {
|
|
150
|
+
return this._cause;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
var ErrorCode;
|
|
154
|
+
(function (ErrorCode) {
|
|
155
|
+
// 1XX for engine
|
|
156
|
+
ErrorCode[ErrorCode["BROWSER_NOT_SUPPORT"] = 100] = "BROWSER_NOT_SUPPORT";
|
|
157
|
+
ErrorCode[ErrorCode["ENGINE_INIT_ERROR"] = 101] = "ENGINE_INIT_ERROR";
|
|
158
|
+
ErrorCode[ErrorCode["ENGINE_MODULE_IS_INITIALIZING"] = 102] = "ENGINE_MODULE_IS_INITIALIZING";
|
|
159
|
+
ErrorCode[ErrorCode["ENGINE_MODULE_INIT_ERROR"] = 103] = "ENGINE_MODULE_INIT_ERROR";
|
|
160
|
+
ErrorCode[ErrorCode["RECOGNITION_NOT_AVAILABLE"] = 104] = "RECOGNITION_NOT_AVAILABLE";
|
|
161
|
+
ErrorCode[ErrorCode["RECOGNITION_ERROR"] = 105] = "RECOGNITION_ERROR";
|
|
162
|
+
ErrorCode[ErrorCode["INVALID_AUTH_ERROR"] = 106] = "INVALID_AUTH_ERROR";
|
|
163
|
+
ErrorCode[ErrorCode["SCREEN_RESOLUTION_TOO_LOW"] = 107] = "SCREEN_RESOLUTION_TOO_LOW";
|
|
164
|
+
ErrorCode[ErrorCode["SCREEN_SIZE_CHANGED"] = 108] = "SCREEN_SIZE_CHANGED";
|
|
165
|
+
// 2 for LIVENESS
|
|
166
|
+
ErrorCode[ErrorCode["LIVENESS_NOT_PASSED"] = 201] = "LIVENESS_NOT_PASSED";
|
|
167
|
+
// 3 for ID-Recognition
|
|
168
|
+
ErrorCode[ErrorCode["ID_RECOGNITION_CONFIRM_INFO_ERROR"] = 301] = "ID_RECOGNITION_CONFIRM_INFO_ERROR";
|
|
169
|
+
ErrorCode[ErrorCode["ID_RECOGNITION_TIMEOUT"] = 302] = "ID_RECOGNITION_TIMEOUT";
|
|
170
|
+
// 4 for Anti-fraud
|
|
171
|
+
ErrorCode[ErrorCode["ID_RECOGNITION_ANTI_FRAUD_NOT_PASSED"] = 401] = "ID_RECOGNITION_ANTI_FRAUD_NOT_PASSED";
|
|
172
|
+
// 9 for common
|
|
173
|
+
ErrorCode[ErrorCode["SDK_INTERNAL_ERROR"] = 900] = "SDK_INTERNAL_ERROR";
|
|
174
|
+
ErrorCode[ErrorCode["NETWORK_ERROR"] = 901] = "NETWORK_ERROR";
|
|
175
|
+
ErrorCode[ErrorCode["HTTP_ERROR_RESPONSE"] = 902] = "HTTP_ERROR_RESPONSE";
|
|
176
|
+
ErrorCode[ErrorCode["USER_CANCEL"] = 903] = "USER_CANCEL";
|
|
177
|
+
ErrorCode[ErrorCode["CAMERA_NOT_SUPPORT"] = 904] = "CAMERA_NOT_SUPPORT";
|
|
178
|
+
ErrorCode[ErrorCode["SERVER_ERROR"] = 905] = "SERVER_ERROR";
|
|
179
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
180
|
+
|
|
181
|
+
function decodeToken(token) {
|
|
182
|
+
const decoded = jwt_decode(token);
|
|
183
|
+
const {
|
|
184
|
+
exp,
|
|
185
|
+
iat
|
|
186
|
+
} = decoded;
|
|
187
|
+
return {
|
|
188
|
+
payload: decoded,
|
|
189
|
+
exp: typeof exp === 'number' ? exp : 0,
|
|
190
|
+
iat: typeof iat === 'number' ? iat : 0
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function getDeviceInfo() {
|
|
195
|
+
const userAgent = window.navigator.userAgent;
|
|
196
|
+
const deviceType = getDeviceType(userAgent);
|
|
197
|
+
const browserType = getBrowserType(userAgent);
|
|
198
|
+
return `${deviceType} (${browserType})`;
|
|
199
|
+
}
|
|
200
|
+
function getDeviceType(userAgent) {
|
|
201
|
+
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
|
|
202
|
+
return 'iPad/iPhone';
|
|
203
|
+
} else if (userAgent.match(/Android/i)) {
|
|
204
|
+
return 'Android';
|
|
205
|
+
} else if (userAgent.match(/Windows Phone/i)) {
|
|
206
|
+
return 'Windows Phone';
|
|
207
|
+
} else if (userAgent.match(/Windows NT/i)) {
|
|
208
|
+
return 'Windows PC';
|
|
209
|
+
} else if (userAgent.match(/Mac OS/i)) {
|
|
210
|
+
return 'Mac';
|
|
211
|
+
} else if (userAgent.match(/Linux/i)) {
|
|
212
|
+
return 'Linux';
|
|
213
|
+
} else {
|
|
214
|
+
return 'Unknown Device';
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function getBrowserType(userAgent) {
|
|
218
|
+
if (userAgent.match(/Chrome/i)) {
|
|
219
|
+
return 'Chrome';
|
|
220
|
+
} else if (userAgent.match(/Firefox/i)) {
|
|
221
|
+
return 'Firefox';
|
|
222
|
+
} else if (userAgent.match(/Edge/i)) {
|
|
223
|
+
return 'Edge';
|
|
224
|
+
} else if (userAgent.match(/Safari/i)) {
|
|
225
|
+
return 'Safari';
|
|
226
|
+
} else if (userAgent.match(/MSIE/i) || userAgent.match(/Trident/i)) {
|
|
227
|
+
return 'IE';
|
|
228
|
+
} else {
|
|
229
|
+
return 'Unknown Browser';
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function getSystemInfo() {
|
|
233
|
+
const userAgent = window.navigator.userAgent;
|
|
234
|
+
const os = getOs(userAgent);
|
|
235
|
+
const osVersion = getOsVersion(userAgent);
|
|
236
|
+
return `${os} (${osVersion})`;
|
|
237
|
+
}
|
|
238
|
+
function getOs(userAgent) {
|
|
239
|
+
if (userAgent.match(/Windows NT 10/i)) {
|
|
240
|
+
return 'Windows 10';
|
|
241
|
+
} else if (userAgent.match(/Windows NT 6.3/i)) {
|
|
242
|
+
return 'Windows 8.1';
|
|
243
|
+
} else if (userAgent.match(/Windows NT 6.2/i)) {
|
|
244
|
+
return 'Windows 8';
|
|
245
|
+
} else if (userAgent.match(/Windows NT 6.1/i)) {
|
|
246
|
+
return 'Windows 7';
|
|
247
|
+
} else if (userAgent.match(/Windows NT 6.0/i)) {
|
|
248
|
+
return 'Windows Vista';
|
|
249
|
+
} else if (userAgent.match(/Windows NT 5.1/i)) {
|
|
250
|
+
return 'Windows XP';
|
|
251
|
+
} else if (userAgent.match(/Windows NT 5.0/i)) {
|
|
252
|
+
return 'Windows 2000';
|
|
253
|
+
} else if (userAgent.match(/Mac/i)) {
|
|
254
|
+
return 'Mac OS';
|
|
255
|
+
} else if (userAgent.match(/Linux/i)) {
|
|
256
|
+
return 'Linux';
|
|
257
|
+
} else {
|
|
258
|
+
return 'Unknown OS';
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function getOsVersion(userAgent) {
|
|
262
|
+
if (userAgent.match(/Windows NT/i)) {
|
|
263
|
+
const matches = userAgent.match(/Windows NT ([\d\\.]+)/i);
|
|
264
|
+
if (matches) {
|
|
265
|
+
return matches[1];
|
|
266
|
+
} else {
|
|
267
|
+
return '';
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (userAgent.match(/Mac/i)) {
|
|
271
|
+
const matches = userAgent.match(/Mac OS X ([\d_.]+)/i);
|
|
272
|
+
if (matches) {
|
|
273
|
+
return matches[1].replace(/_/g, '.');
|
|
274
|
+
} else {
|
|
275
|
+
return '';
|
|
276
|
+
}
|
|
277
|
+
} else if (userAgent.match(/Android/i)) {
|
|
278
|
+
const matches = userAgent.match(/Android ([\d.]+)/i);
|
|
279
|
+
if (matches) {
|
|
280
|
+
return matches[1];
|
|
281
|
+
} else {
|
|
282
|
+
return '';
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
return '';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
class State {
|
|
290
|
+
constructor(initialValue = null) {
|
|
291
|
+
this._value = initialValue;
|
|
292
|
+
}
|
|
293
|
+
getValue() {
|
|
294
|
+
return this._value;
|
|
295
|
+
}
|
|
296
|
+
setValue(newValue) {
|
|
297
|
+
this._value = newValue;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function useState(initialValue = null, subscription) {
|
|
301
|
+
const state = new State(initialValue);
|
|
302
|
+
function getValue() {
|
|
303
|
+
return state.getValue();
|
|
304
|
+
}
|
|
305
|
+
function setValue(newValue) {
|
|
306
|
+
if (subscription && newValue !== state.getValue()) {
|
|
307
|
+
subscription.next(newValue);
|
|
308
|
+
}
|
|
309
|
+
state.setValue(newValue);
|
|
310
|
+
}
|
|
311
|
+
return [getValue, setValue];
|
|
312
|
+
}
|
|
313
|
+
|
|
108
314
|
function dataURItoBlob(dataURI) {
|
|
109
315
|
// convert base64/URLEncoded data component to raw binary data held in a string
|
|
110
316
|
const byteString = atob(dataURI.split(',')[1]);
|
|
@@ -156,7 +362,9 @@ function retryPromiseWithCondition(promiseFactory, conditionFactory) {
|
|
|
156
362
|
const res = yield promiseFactory();
|
|
157
363
|
return res;
|
|
158
364
|
} catch (e) {
|
|
159
|
-
|
|
365
|
+
if ((e === null || e === void 0 ? void 0 : e._code) === ErrorCode.SERVER_ERROR) {
|
|
366
|
+
throw e;
|
|
367
|
+
}
|
|
160
368
|
const retry = yield conditionFactory(e);
|
|
161
369
|
if (retry) {
|
|
162
370
|
return retryPromiseWithCondition(promiseFactory, conditionFactory);
|
|
@@ -179,53 +387,87 @@ function isMobile() {
|
|
|
179
387
|
return !!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4)) || /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
|
|
180
388
|
}(navigator.userAgent || navigator.vendor || window.opera);
|
|
181
389
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
390
|
+
function splitResult(result) {
|
|
391
|
+
if (result.address) {
|
|
392
|
+
const originAddress = result.address;
|
|
393
|
+
const address1Index = checkCity(originAddress);
|
|
394
|
+
result.address1 = address1Index === -1 ? '' : originAddress.slice(0, 3);
|
|
395
|
+
const address2 = address1Index === -1 ? originAddress : originAddress.slice(3);
|
|
396
|
+
const address2Index = checkZone(address2);
|
|
397
|
+
result.address2 = address2Index === -1 ? '' : address2.slice(0, address2Index + 1);
|
|
398
|
+
result.address3 = address2Index === -1 ? address2 : address2.slice(address2Index + 1);
|
|
189
399
|
}
|
|
190
|
-
|
|
191
|
-
|
|
400
|
+
if (result.dateOfBirth) {
|
|
401
|
+
const splitDateOfBirth = result.dateOfBirth.split('-');
|
|
402
|
+
const dateOfBirthY = (+splitDateOfBirth[0] - 1911).toString();
|
|
403
|
+
result.dateOfBirthY = dateOfBirthY.length < 3 ? '0' + dateOfBirthY : dateOfBirthY;
|
|
404
|
+
result.dateOfBirthM = splitDateOfBirth[1];
|
|
405
|
+
result.dateOfBirthD = splitDateOfBirth[2];
|
|
192
406
|
}
|
|
193
|
-
|
|
194
|
-
|
|
407
|
+
if (result.dateOfIssue) {
|
|
408
|
+
const splitDateOfIssue = result.dateOfIssue.split('-');
|
|
409
|
+
const dateOfIssueY = (+splitDateOfIssue[0] - 1911).toString();
|
|
410
|
+
result.dateOfIssueY = dateOfIssueY.length < 3 ? '0' + dateOfIssueY : dateOfIssueY;
|
|
411
|
+
result.dateOfIssueM = splitDateOfIssue[1];
|
|
412
|
+
result.dateOfIssueD = splitDateOfIssue[2];
|
|
195
413
|
}
|
|
196
|
-
|
|
197
|
-
|
|
414
|
+
return result;
|
|
415
|
+
}
|
|
416
|
+
function checkCity(address) {
|
|
417
|
+
const citys = ['臺北市', '臺中市', '基隆市', '臺南市', '高雄市', '新北市', '宜蘭縣', '桃園市', '嘉義市', '新竹縣', '苗栗縣', '南投縣', '彰化縣', '新竹市', '雲林縣', '嘉義縣', '屏東縣', '花蓮縣', '臺東縣', '金門縣', '澎湖縣', '連江縣', '臺中縣', '臺南縣', '高雄縣'];
|
|
418
|
+
for (const city of citys) {
|
|
419
|
+
if (address.indexOf(city) !== -1) {
|
|
420
|
+
return address.indexOf(city);
|
|
421
|
+
}
|
|
198
422
|
}
|
|
199
|
-
|
|
200
|
-
|
|
423
|
+
return -1;
|
|
424
|
+
}
|
|
425
|
+
function checkZone(address) {
|
|
426
|
+
const zones = ['鄉', '鎮', '市', '區'];
|
|
427
|
+
for (const zone of zones) {
|
|
428
|
+
if (address.indexOf(zone) !== -1) {
|
|
429
|
+
return address.indexOf(zone);
|
|
430
|
+
}
|
|
201
431
|
}
|
|
432
|
+
return -1;
|
|
202
433
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
434
|
+
function notEmpty(value) {
|
|
435
|
+
return typeof value !== 'undefined' && value !== null && value !== '';
|
|
436
|
+
}
|
|
437
|
+
function combineResult(result) {
|
|
438
|
+
const {
|
|
439
|
+
address1,
|
|
440
|
+
address2,
|
|
441
|
+
address3,
|
|
442
|
+
dateOfBirthY,
|
|
443
|
+
dateOfBirthM,
|
|
444
|
+
dateOfBirthD,
|
|
445
|
+
dateOfIssueY,
|
|
446
|
+
dateOfIssueM,
|
|
447
|
+
dateOfIssueD
|
|
448
|
+
} = result,
|
|
449
|
+
others = __rest(result, ["address1", "address2", "address3", "dateOfBirthY", "dateOfBirthM", "dateOfBirthD", "dateOfIssueY", "dateOfIssueM", "dateOfIssueD"]);
|
|
450
|
+
// 由於呼叫函數的情境包含 confirmOCRResult,
|
|
451
|
+
// confirmOCRResult 並不會知道目前是什麼卡片類型,
|
|
452
|
+
// 所以會以分割出的欄位來判斷是否進行欄位合併與覆寫。
|
|
453
|
+
const newResult = Object.assign({}, others);
|
|
454
|
+
if ([address1, address2, address3].every(notEmpty)) {
|
|
455
|
+
newResult.address = `${address1}${address2}${address3}`;
|
|
456
|
+
}
|
|
457
|
+
if ([dateOfBirthY, dateOfBirthM, dateOfBirthD].every(notEmpty)) {
|
|
458
|
+
newResult.dateOfBirth = `${1911 + Number.parseInt(dateOfBirthY || '0')}-${dateOfBirthM}-${dateOfBirthD}`;
|
|
459
|
+
}
|
|
460
|
+
if ([dateOfIssueY, dateOfIssueM, dateOfIssueD].every(notEmpty)) {
|
|
461
|
+
newResult.dateOfIssue = `${1911 + Number.parseInt(dateOfIssueY || '0')}-${dateOfIssueM}-${dateOfIssueD}`;
|
|
462
|
+
}
|
|
463
|
+
return newResult;
|
|
464
|
+
}
|
|
465
|
+
const isIphone14proOrProMax = () => {
|
|
466
|
+
const isIphone = () => {
|
|
467
|
+
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
468
|
+
};
|
|
469
|
+
return isIphone() && (screen.width === 430 && screen.height === 932 || screen.width === 393 && screen.height === 852);
|
|
470
|
+
};
|
|
229
471
|
|
|
230
472
|
function debugLog(message, ...others) {
|
|
231
473
|
if (new URLSearchParams(location.search).get('authme-debug') === 'true') {
|
|
@@ -337,13 +579,37 @@ function cropByRatio(width, height, ratio) {
|
|
|
337
579
|
}
|
|
338
580
|
|
|
339
581
|
function startSpinner(text) {
|
|
582
|
+
const loadingLottie = Storage.getItem(STORAGE_KEY.LOADING_LOTTIE);
|
|
340
583
|
const body = document.querySelector('.authme-container');
|
|
584
|
+
if (loadingLottie) {
|
|
585
|
+
const loadingSDKOuter = document.createElement('div');
|
|
586
|
+
const loadingSDKContent = document.createElement('div');
|
|
587
|
+
const loadingSDKText = document.createElement('div');
|
|
588
|
+
loadingSDKOuter.classList.add('authme-loading-sdk-outer');
|
|
589
|
+
loadingSDKContent.classList.add('authme-loading-sdk-content');
|
|
590
|
+
loadingSDKOuter.appendChild(loadingSDKContent);
|
|
591
|
+
Lottie.loadAnimation({
|
|
592
|
+
container: loadingSDKContent,
|
|
593
|
+
renderer: 'svg',
|
|
594
|
+
loop: true,
|
|
595
|
+
autoplay: true,
|
|
596
|
+
name: 'spinner-loading',
|
|
597
|
+
animationData: loadingLottie
|
|
598
|
+
});
|
|
599
|
+
body === null || body === void 0 ? void 0 : body.appendChild(loadingSDKOuter);
|
|
600
|
+
if (text) {
|
|
601
|
+
loadingSDKText.classList.add('authme-loading-sdk-text');
|
|
602
|
+
loadingSDKText.textContent = text;
|
|
603
|
+
loadingSDKContent.appendChild(loadingSDKText);
|
|
604
|
+
}
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
341
607
|
const spinnerOuter = document.createElement('div');
|
|
342
|
-
spinnerOuter.className = 'loading-outer';
|
|
343
608
|
const spinner = document.createElement('div');
|
|
344
|
-
spinner.className = 'loading';
|
|
345
609
|
const spinnerText = document.createElement('div');
|
|
346
610
|
spinnerOuter.appendChild(spinner);
|
|
611
|
+
spinnerOuter.className = 'loading-outer';
|
|
612
|
+
spinner.className = 'loading';
|
|
347
613
|
if (text) {
|
|
348
614
|
spinnerText.className = 'loading-text';
|
|
349
615
|
spinnerText.textContent = text;
|
|
@@ -352,8 +618,12 @@ function startSpinner(text) {
|
|
|
352
618
|
body === null || body === void 0 ? void 0 : body.appendChild(spinnerOuter);
|
|
353
619
|
}
|
|
354
620
|
function stopSpinner() {
|
|
621
|
+
const loadingLottie = Storage.getItem(STORAGE_KEY.LOADING_LOTTIE);
|
|
355
622
|
const body = document.querySelector('.authme-container');
|
|
356
|
-
|
|
623
|
+
if (loadingLottie) {
|
|
624
|
+
Lottie.destroy('spinner-loading');
|
|
625
|
+
}
|
|
626
|
+
const spinner = loadingLottie ? document.querySelector('.authme-loading-sdk-outer') : document.querySelector('.loading-outer');
|
|
357
627
|
if (spinner) {
|
|
358
628
|
body === null || body === void 0 ? void 0 : body.removeChild(spinner);
|
|
359
629
|
}
|
|
@@ -1646,25 +1916,27 @@ const sdk_loading = () => ({
|
|
|
1646
1916
|
});
|
|
1647
1917
|
|
|
1648
1918
|
function startLoadingSDK(text) {
|
|
1919
|
+
const loadingLottie = Storage.getItem(STORAGE_KEY.LOADING_LOTTIE);
|
|
1649
1920
|
const body = document.body;
|
|
1650
1921
|
const loadingSDKOuter = document.createElement('div');
|
|
1651
1922
|
const loadingSDKContent = document.createElement('div');
|
|
1652
1923
|
loadingSDKOuter.classList.add('authme-loading-sdk-outer');
|
|
1653
1924
|
loadingSDKContent.classList.add('authme-loading-sdk-content');
|
|
1654
1925
|
loadingSDKOuter.appendChild(loadingSDKContent);
|
|
1655
|
-
|
|
1926
|
+
Lottie.loadAnimation({
|
|
1656
1927
|
container: loadingSDKContent,
|
|
1657
1928
|
renderer: 'svg',
|
|
1658
1929
|
loop: true,
|
|
1659
1930
|
autoplay: true,
|
|
1660
|
-
name: '
|
|
1661
|
-
animationData: sdk_loading()
|
|
1931
|
+
name: 'init-sdk-loading',
|
|
1932
|
+
animationData: loadingLottie ? loadingLottie : sdk_loading()
|
|
1662
1933
|
});
|
|
1663
1934
|
body === null || body === void 0 ? void 0 : body.appendChild(loadingSDKOuter);
|
|
1664
1935
|
}
|
|
1665
1936
|
function stopLoadingSDK() {
|
|
1666
1937
|
const body = document.body;
|
|
1667
1938
|
const loadingSDKOuter = document.querySelector('.authme-loading-sdk-outer');
|
|
1939
|
+
Lottie.destroy('init-sdk-loading');
|
|
1668
1940
|
if (loadingSDKOuter) {
|
|
1669
1941
|
body === null || body === void 0 ? void 0 : body.removeChild(loadingSDKOuter);
|
|
1670
1942
|
}
|
|
@@ -1706,7 +1978,7 @@ function RGBToLottieColor(color) {
|
|
|
1706
1978
|
}
|
|
1707
1979
|
|
|
1708
1980
|
var name = "@authme/util";
|
|
1709
|
-
var version$1 = "2.
|
|
1981
|
+
var version$1 = "2.4.2";
|
|
1710
1982
|
var peerDependencies = {
|
|
1711
1983
|
"core-js": "^3.6.0"
|
|
1712
1984
|
};
|
|
@@ -1722,4 +1994,4 @@ const version = packageInfo.version;
|
|
|
1722
1994
|
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
1723
1995
|
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
1724
1996
|
|
|
1725
|
-
export { AuthmeError, ErrorCode, Icon, RGBToLottieColor, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, cropByRatio, dataURItoBlob, debugLog, getCanvasSize, getCssVariable, getImageData, getUserAgent, hexToRGB, hideElement, hideErrorMessage, hidePopup, isMobile, isMobileOrTablet, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showPopup, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, version, videoConstraintsFactory, waitTime };
|
|
1997
|
+
export { AuthmeError, ErrorCode, Icon, RGBToLottieColor, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, decodeToken, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, getUserAgent, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, useState, version, videoConstraintsFactory, waitTime };
|
package/package.json
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export * from './jwt-decode.service';
|
|
2
|
+
export * from './client-info.service';
|
|
3
|
+
export { useState } from './state.service';
|
|
1
4
|
export declare function dataURItoBlob(dataURI: string): Blob;
|
|
2
5
|
export declare function UintArrayToBlob(width: number, height: number, data: Uint8Array | Uint8ClampedArray, canvasEle?: HTMLCanvasElement, imageFormat?: 'jpg' | 'png'): Blob;
|
|
3
6
|
export declare function waitTime(ms: number): Promise<void>;
|
|
@@ -5,3 +8,6 @@ export declare function retryPromiseWithCondition<T>(promiseFactory: () => Promi
|
|
|
5
8
|
export declare function getUserAgent(): string;
|
|
6
9
|
export declare function isMobileOrTablet(): boolean;
|
|
7
10
|
export declare function isMobile(): boolean;
|
|
11
|
+
export declare function splitResult(result: any): any;
|
|
12
|
+
export declare function combineResult(result: any): any;
|
|
13
|
+
export declare const isIphone14proOrProMax: () => boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JwtPayload } from 'jwt-decode';
|
|
2
|
+
declare type TokenData<T> = {
|
|
3
|
+
payload: T;
|
|
4
|
+
exp: number;
|
|
5
|
+
iat: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function decodeToken<T extends JwtPayload>(token: string): TokenData<T>;
|
|
8
|
+
export declare type AuthmeJWT = {
|
|
9
|
+
aud: string;
|
|
10
|
+
client_id: string;
|
|
11
|
+
client_tenant: string;
|
|
12
|
+
exp: number;
|
|
13
|
+
iat: number;
|
|
14
|
+
iss: string;
|
|
15
|
+
jti: string;
|
|
16
|
+
nbf: number;
|
|
17
|
+
scope: Array<string>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export declare enum STORAGE_KEY {
|
|
2
|
+
LOADING_LOTTIE = "loadingLottie",
|
|
3
|
+
OCR_IDCARD_RESULT_FORMAT = "ocrIdcardResultFormat",
|
|
4
|
+
ENABLE_EVENT_TRACKING = "enableEventTracking",
|
|
5
|
+
EVENT_TRACK_URL = "eventTrackUrl",
|
|
6
|
+
API_BASE_URL = "apiBaseUrl"
|
|
7
|
+
}
|
|
1
8
|
declare function getItem(key: string): any;
|
|
2
9
|
declare function setItem(key: string, val: any): void;
|
|
3
10
|
declare function removeItem(key: string): boolean;
|