@authme/identity-verification 2.8.0 → 2.8.1
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 +244 -140
- package/index.js +246 -142
- package/package.json +6 -6
- package/src/lib/identity-verification-feature-identity-verification.d.ts +2 -2
- package/src/lib/interface/config.interface.d.ts +2 -0
- package/src/lib/interface/result.model.d.ts +16 -13
- package/src/lib/ui/ocr-flow.d.ts +4 -0
- package/src/lib/ui/ocr.ui.d.ts +1 -3
- package/src/lib/v2/utilities/index.d.ts +13 -0
package/index.cjs
CHANGED
|
@@ -129,7 +129,9 @@ const defaultIdRecognitionConfig = {
|
|
|
129
129
|
antiFraudIMetalTagValidCountTh: false,
|
|
130
130
|
cardTypes: [],
|
|
131
131
|
cardTypeConfigs: [],
|
|
132
|
-
captureTimeout: -1
|
|
132
|
+
captureTimeout: -1,
|
|
133
|
+
resultImageFormat: 'jpg',
|
|
134
|
+
confirmPageEnabled: true
|
|
133
135
|
};
|
|
134
136
|
|
|
135
137
|
function setCorrectViewHeight() {
|
|
@@ -24477,9 +24479,14 @@ function renderConfirmUI({
|
|
|
24477
24479
|
document.body.appendChild(confirmContainerElem);
|
|
24478
24480
|
return new Promise((resolve, reject) => {
|
|
24479
24481
|
confirmContainerElem.querySelector('.confirm-btn').addEventListener('click', e => {
|
|
24480
|
-
const modifiedDetails = Object.fromEntries(Object.
|
|
24481
|
-
var _a
|
|
24482
|
-
|
|
24482
|
+
const modifiedDetails = Object.fromEntries(Object.entries(items.details).map(([column, originalValue]) => {
|
|
24483
|
+
var _a;
|
|
24484
|
+
const inputElement = confirmContainerElem.querySelector(`[name="${column}"]`);
|
|
24485
|
+
const inputValue = (_a = inputElement === null || inputElement === void 0 ? void 0 : inputElement.value) !== null && _a !== void 0 ? _a : '';
|
|
24486
|
+
return [column, {
|
|
24487
|
+
isModified: inputValue !== originalValue,
|
|
24488
|
+
value: inputValue
|
|
24489
|
+
}];
|
|
24483
24490
|
}));
|
|
24484
24491
|
sendStatusAction$1(core.StatusAction.Confirm);
|
|
24485
24492
|
confirmContainerElem.remove();
|
|
@@ -25471,6 +25478,53 @@ const blobToBase64 = image => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
25471
25478
|
reader.readAsDataURL(image);
|
|
25472
25479
|
});
|
|
25473
25480
|
});
|
|
25481
|
+
const blobToImageBase64 = image => __awaiter(void 0, void 0, void 0, function* () {
|
|
25482
|
+
return new Promise((resolve, reject) => {
|
|
25483
|
+
const reader = new FileReader();
|
|
25484
|
+
reader.readAsDataURL(image);
|
|
25485
|
+
reader.onloadend = () => resolve(reader.result);
|
|
25486
|
+
reader.onerror = reject;
|
|
25487
|
+
});
|
|
25488
|
+
});
|
|
25489
|
+
const result2ModifiedData = (result, modifiedResult) => {
|
|
25490
|
+
if (!modifiedResult) {
|
|
25491
|
+
const obj = {};
|
|
25492
|
+
for (const key in result) {
|
|
25493
|
+
obj[key] = {
|
|
25494
|
+
isModified: false,
|
|
25495
|
+
value: result[key]
|
|
25496
|
+
};
|
|
25497
|
+
}
|
|
25498
|
+
return obj;
|
|
25499
|
+
}
|
|
25500
|
+
const modifiedData = {};
|
|
25501
|
+
Object.keys(result).forEach(key => {
|
|
25502
|
+
var _a;
|
|
25503
|
+
if ((_a = modifiedResult[key]) === null || _a === void 0 ? void 0 : _a.isModified) {
|
|
25504
|
+
modifiedData[key] = {
|
|
25505
|
+
isModified: true,
|
|
25506
|
+
value: modifiedResult[key].value
|
|
25507
|
+
};
|
|
25508
|
+
} else {
|
|
25509
|
+
modifiedData[key] = {
|
|
25510
|
+
isModified: false,
|
|
25511
|
+
value: result[key]
|
|
25512
|
+
};
|
|
25513
|
+
}
|
|
25514
|
+
});
|
|
25515
|
+
return modifiedData;
|
|
25516
|
+
};
|
|
25517
|
+
const modifiedData2Result = modifiedResult => {
|
|
25518
|
+
const result = {};
|
|
25519
|
+
if (!modifiedResult) {
|
|
25520
|
+
console.error('modifiedData2Result: modifiedResult is empty');
|
|
25521
|
+
return;
|
|
25522
|
+
}
|
|
25523
|
+
Object.keys(modifiedResult).forEach(key => {
|
|
25524
|
+
result[key] = modifiedResult[key].value;
|
|
25525
|
+
});
|
|
25526
|
+
return result;
|
|
25527
|
+
};
|
|
25474
25528
|
|
|
25475
25529
|
const translateService = core.getTranslateInstance();
|
|
25476
25530
|
// TODO 處理參數
|
|
@@ -26255,7 +26309,7 @@ function startOCR(config) {
|
|
|
26255
26309
|
if (toastManualCapture) {
|
|
26256
26310
|
toastManualCapture.clear();
|
|
26257
26311
|
}
|
|
26258
|
-
return rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? rxjs.of(false) : checkConfirmImageManual(canvasSizeInfo)).pipe(rxjs.switchMap(needRetry => {
|
|
26312
|
+
return rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm || !config.ocrConfig.confirmPageEnabled ? rxjs.of(false) : checkConfirmImageManual(canvasSizeInfo)).pipe(rxjs.switchMap(needRetry => {
|
|
26259
26313
|
util.startSpinner(translateService.translate('sdk.general.uploading'));
|
|
26260
26314
|
if (needRetry) {
|
|
26261
26315
|
util.hideElement(confirmImageContainer);
|
|
@@ -26305,7 +26359,7 @@ function startOCR(config) {
|
|
|
26305
26359
|
})), rxjs.tap(() => received = true))))));
|
|
26306
26360
|
};
|
|
26307
26361
|
const autoCapture = canvasSizeInfo => {
|
|
26308
|
-
return rxjs.of(canvasSizeInfo).pipe(handleOcrSendFrame(canvasSizeInfo, image, video, config.recognition, 30, false,
|
|
26362
|
+
return rxjs.of(canvasSizeInfo).pipe(handleOcrSendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, config.ocrConfig.resultImageFormat, cardType, type), rxjs.tap(x => applyTextByResult(x.result)), rxjs.filter(({
|
|
26309
26363
|
result
|
|
26310
26364
|
}) => result.eStatus === idRecognition.EAuthMeCardOCRStatus.Pass || result.eStatus === idRecognition.EAuthMeMRZServiceStatus.Success), rxjs.take(1), rxjs.tap(() => {
|
|
26311
26365
|
if (countdownCaptureTimer && countdownCaptureTimer.end && !countdownCaptureTimer.end()) {
|
|
@@ -26323,7 +26377,7 @@ function startOCR(config) {
|
|
|
26323
26377
|
util.hideElement(scanAnimationContainer);
|
|
26324
26378
|
}), rxjs.map(() => resp))), rxjs.switchMap(({
|
|
26325
26379
|
result
|
|
26326
|
-
}) => rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? rxjs.of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(rxjs.switchMap(needRetry => {
|
|
26380
|
+
}) => rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm || !config.ocrConfig.confirmPageEnabled ? rxjs.of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(rxjs.switchMap(needRetry => {
|
|
26327
26381
|
if (countdownCaptureTimer && countdownCaptureTimer.end) {
|
|
26328
26382
|
if (needRetry && !countdownCaptureTimer.end()) {
|
|
26329
26383
|
countdownCaptureTimer = countdownTimer(captureTimeoutTimer, () => {
|
|
@@ -26443,7 +26497,8 @@ function startOCR(config) {
|
|
|
26443
26497
|
}), rxjs.switchMap(canvasSizeInfo => rxjs.from(config.init(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(rxjs.tap(x => ocrEngineConfig = x), rxjs.tap(() => __awaiter(this, void 0, void 0, function* () {
|
|
26444
26498
|
if (config.ocrConfig.needAntiFraud) return;
|
|
26445
26499
|
util.stopSpinner();
|
|
26446
|
-
})), rxjs.tap(() => eventListenerService$1.start())
|
|
26500
|
+
})), rxjs.tap(() => eventListenerService$1.start()) // TODO check useless
|
|
26501
|
+
)))).pipe(rxjs.tap(() => {
|
|
26447
26502
|
sendStatusAction$1(core.StatusAction.Uploading);
|
|
26448
26503
|
util.hideElement(videoContainer);
|
|
26449
26504
|
util.startSpinner(translateService.translate('sdk.general.uploading'));
|
|
@@ -26451,36 +26506,41 @@ function startOCR(config) {
|
|
|
26451
26506
|
setStatusEvent$1(cardClassResultMapping(config.acceptTypes[config.acceptTypes.length - 1]));
|
|
26452
26507
|
util.stopSpinner();
|
|
26453
26508
|
container.style.display = 'none';
|
|
26454
|
-
}), rxjs.concatMap(result => {
|
|
26509
|
+
}), rxjs.concatMap(result => __awaiter(this, void 0, void 0, function* () {
|
|
26455
26510
|
setStatusView(core.StatusView.Confirm);
|
|
26456
|
-
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
|
|
26465
|
-
|
|
26466
|
-
|
|
26467
|
-
|
|
26468
|
-
|
|
26469
|
-
|
|
26470
|
-
|
|
26471
|
-
|
|
26472
|
-
translate: key => translateService.translate(key)
|
|
26473
|
-
}
|
|
26474
|
-
})
|
|
26475
|
-
});
|
|
26511
|
+
let modifiedData = result2ModifiedData(result.details);
|
|
26512
|
+
if (config.ocrConfig.displayResultPage) {
|
|
26513
|
+
modifiedData = yield renderConfirmUI({
|
|
26514
|
+
cardType: config.ocrConfig.type,
|
|
26515
|
+
items: {
|
|
26516
|
+
columns: Object.keys(result.details).sort((a, b) => {
|
|
26517
|
+
const aScore = idRecognition.getRecognitionColumnOrder(a);
|
|
26518
|
+
const bScore = idRecognition.getRecognitionColumnOrder(b);
|
|
26519
|
+
return aScore - bScore || a.localeCompare(b);
|
|
26520
|
+
}),
|
|
26521
|
+
details: result.details
|
|
26522
|
+
},
|
|
26523
|
+
options: {
|
|
26524
|
+
headerIcon: config.ocrConfig.icon,
|
|
26525
|
+
translate: key => translateService.translate(key)
|
|
26526
|
+
}
|
|
26476
26527
|
});
|
|
26477
26528
|
}
|
|
26478
26529
|
flags.onConfirm = true;
|
|
26479
|
-
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26530
|
+
util.Storage.setItem('scanId', result.scanId);
|
|
26531
|
+
util.Storage.setItem('data', result.details);
|
|
26532
|
+
util.Storage.setItem('confirmedData', modifiedData2Result(modifiedData));
|
|
26533
|
+
return {
|
|
26534
|
+
scanId: result.scanId,
|
|
26535
|
+
isSuccess: true,
|
|
26536
|
+
message: '',
|
|
26537
|
+
data: result.details,
|
|
26538
|
+
modifiedData: modifiedData,
|
|
26539
|
+
backCropImage: result.backCropImage,
|
|
26540
|
+
frontCropImage: result.frontCropImage,
|
|
26541
|
+
frontImage: result.frontImage,
|
|
26542
|
+
backImage: result.backImage
|
|
26543
|
+
};
|
|
26484
26544
|
})), rxjs.takeUntil(unsubscribe$), rxjs.finalize(() => {
|
|
26485
26545
|
sendStatusDescription$1(core.StatusDescription.Complete);
|
|
26486
26546
|
util.stopSpinner();
|
|
@@ -26490,7 +26550,7 @@ function startOCR(config) {
|
|
|
26490
26550
|
const type = currentType('get', null).type;
|
|
26491
26551
|
const cardType = currentType('get', null).cardType;
|
|
26492
26552
|
const ctx = image.getContext('2d');
|
|
26493
|
-
const imageData = util.getImageData(image, ctx, video, canvasSizeInfo, false,
|
|
26553
|
+
const imageData = util.getImageData(image, ctx, video, canvasSizeInfo, false, config.ocrConfig.resultImageFormat);
|
|
26494
26554
|
const imageBlob = util.UintArrayToBlob(canvasSizeInfo.width, canvasSizeInfo.height, imageData.data);
|
|
26495
26555
|
const cancelResultObj = {
|
|
26496
26556
|
isSuccess: false,
|
|
@@ -28385,6 +28445,10 @@ class OCRModule {
|
|
|
28385
28445
|
let uploadFullFrame = false;
|
|
28386
28446
|
let fraudTimeout = DEFAULT_ANTI_FRAUD_TIMEOUT;
|
|
28387
28447
|
let shouldEncrypt = false;
|
|
28448
|
+
let frontImage = null;
|
|
28449
|
+
let backImage = null;
|
|
28450
|
+
let frontCropImage = null;
|
|
28451
|
+
let backCropImage = null;
|
|
28388
28452
|
const {
|
|
28389
28453
|
getDebugLogsLength,
|
|
28390
28454
|
modifyDeubgLog,
|
|
@@ -28850,7 +28914,7 @@ class OCRModule {
|
|
|
28850
28914
|
width: frameWidth,
|
|
28851
28915
|
height: frameHeight
|
|
28852
28916
|
});
|
|
28853
|
-
const fraudOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
28917
|
+
const fraudOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas, config.resultImageFormat);
|
|
28854
28918
|
const thicknessResult = Object.assign(Object.assign({}, antiFraudRecogitionResult), {
|
|
28855
28919
|
imageData: data
|
|
28856
28920
|
});
|
|
@@ -28977,10 +29041,10 @@ class OCRModule {
|
|
|
28977
29041
|
width: frameWidth,
|
|
28978
29042
|
height: frameHeight
|
|
28979
29043
|
});
|
|
28980
|
-
const ocrOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
29044
|
+
const ocrOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas, config.resultImageFormat);
|
|
28981
29045
|
const eClass = cardType !== null && cardType !== void 0 ? cardType : '';
|
|
28982
29046
|
if (result.eStatus === idRecognition.EAuthMeCardOCRStatus.Pass && result.imageData && !!docInfos[eClass].docId) {
|
|
28983
|
-
const resultOcrImg = util.UintArrayToBlob(result.iWidth, result.iHeight, result === null || result === void 0 ? void 0 : result.imageData, virtualCanvas);
|
|
29047
|
+
const resultOcrImg = util.UintArrayToBlob(result.iWidth, result.iHeight, result === null || result === void 0 ? void 0 : result.imageData, virtualCanvas, config.resultImageFormat);
|
|
28984
29048
|
docInfos[eClass].ocrImg = resultOcrImg;
|
|
28985
29049
|
docInfos[eClass].ocrOriginImg = ocrOriginImg;
|
|
28986
29050
|
yield _service.stop();
|
|
@@ -29000,6 +29064,11 @@ class OCRModule {
|
|
|
29000
29064
|
// downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
|
|
29001
29065
|
frameIndex++;
|
|
29002
29066
|
util.backgroundRequest(() => __awaiter(this, void 0, void 0, function* () {
|
|
29067
|
+
console.log('recognition', docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId);
|
|
29068
|
+
if (docInfos[eClass].docId === '') {
|
|
29069
|
+
console.warn('didnt find docid, retry');
|
|
29070
|
+
return false;
|
|
29071
|
+
}
|
|
29003
29072
|
const postData = {
|
|
29004
29073
|
scanDocumentId: docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId,
|
|
29005
29074
|
image: requestImg,
|
|
@@ -29050,120 +29119,131 @@ class OCRModule {
|
|
|
29050
29119
|
this.ocrService.stop();
|
|
29051
29120
|
}
|
|
29052
29121
|
const docId = docInfos[option.cardType].docId;
|
|
29053
|
-
if (docId) {
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29122
|
+
if (!docId) {
|
|
29123
|
+
console.warn('didnt find docid , retry');
|
|
29124
|
+
return false;
|
|
29125
|
+
}
|
|
29126
|
+
const ocrImg = option.imageData ? option.imageData : docInfos[option.cardType].ocrImg;
|
|
29127
|
+
const needFraudOption = config.needAntiFraud && option.type === engine.EAuthMeCardClass.TWN_IDCard_Front;
|
|
29128
|
+
let ocrOriginImg;
|
|
29129
|
+
if (option.imageData) {
|
|
29130
|
+
ocrOriginImg = option.imageData;
|
|
29131
|
+
} else {
|
|
29132
|
+
ocrOriginImg = docInfos[option.cardType].ocrOriginImg;
|
|
29133
|
+
}
|
|
29134
|
+
// const base64Image = await blobToBase64(ocrOriginImg);
|
|
29135
|
+
// console.log('confirmImage', base64Image);
|
|
29136
|
+
const requestImg = yield encryptImageBase64(ocrOriginImg);
|
|
29137
|
+
const report = yield this.ocrService.getReport();
|
|
29138
|
+
docInfos[option.cardType].docId = '';
|
|
29139
|
+
modifyDeubgLog(getDebugLogsLength() - 1, {
|
|
29140
|
+
report: report
|
|
29141
|
+
});
|
|
29142
|
+
frameIndex++;
|
|
29143
|
+
yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
29144
|
+
const postData = {
|
|
29145
|
+
scanDocumentId: docId,
|
|
29146
|
+
image: requestImg,
|
|
29147
|
+
type: idRecognition.ResourceImageType.Recognition,
|
|
29148
|
+
info: {
|
|
29149
|
+
report: report,
|
|
29150
|
+
index: frameIndex
|
|
29151
|
+
}
|
|
29152
|
+
};
|
|
29153
|
+
if (shouldEncrypt) {
|
|
29154
|
+
postData.image = yield blobToBase64(ocrOriginImg);
|
|
29155
|
+
return idRecognition.uploadFrameBase64({
|
|
29156
|
+
id: scanId,
|
|
29157
|
+
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29158
|
+
});
|
|
29058
29159
|
} else {
|
|
29059
|
-
|
|
29160
|
+
return idRecognition.uploadFrameBase64(postData);
|
|
29060
29161
|
}
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29070
|
-
|
|
29162
|
+
})
|
|
29163
|
+
// uploadFrameBase64(
|
|
29164
|
+
// docId,
|
|
29165
|
+
// requestImg,
|
|
29166
|
+
// frameIndex,
|
|
29167
|
+
// ResourceImageType.Recognition,
|
|
29168
|
+
// report
|
|
29169
|
+
// )
|
|
29170
|
+
);
|
|
29171
|
+
|
|
29172
|
+
frameIndex = 0;
|
|
29173
|
+
try {
|
|
29174
|
+
const _requestImg = yield encryptImageBase64(ocrImg);
|
|
29175
|
+
const resp = yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
29071
29176
|
const postData = {
|
|
29072
29177
|
scanDocumentId: docId,
|
|
29073
|
-
image:
|
|
29074
|
-
|
|
29178
|
+
image: _requestImg,
|
|
29179
|
+
fileType: idRecognition.RecognitionFileType.FlatImage,
|
|
29075
29180
|
info: {
|
|
29076
|
-
report: report
|
|
29077
|
-
index: frameIndex
|
|
29181
|
+
report: report
|
|
29078
29182
|
}
|
|
29079
29183
|
};
|
|
29184
|
+
let response;
|
|
29080
29185
|
if (shouldEncrypt) {
|
|
29081
|
-
postData.image = yield blobToBase64(
|
|
29082
|
-
|
|
29186
|
+
postData.image = yield blobToBase64(ocrImg);
|
|
29187
|
+
response = yield idRecognition.recognizeBase64({
|
|
29083
29188
|
id: scanId,
|
|
29084
29189
|
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29085
29190
|
});
|
|
29086
29191
|
} else {
|
|
29087
|
-
|
|
29192
|
+
response = yield idRecognition.recognizeBase64(postData);
|
|
29193
|
+
}
|
|
29194
|
+
if (response === null || response === void 0 ? void 0 : response.detectCardResult) {
|
|
29195
|
+
if (option.cardType.toLocaleLowerCase().includes('front')) {
|
|
29196
|
+
frontImage = yield blobToImageBase64(ocrOriginImg);
|
|
29197
|
+
frontCropImage = yield blobToImageBase64(ocrImg);
|
|
29198
|
+
}
|
|
29199
|
+
if (option.cardType.toLocaleLowerCase().includes('back')) {
|
|
29200
|
+
backImage = yield blobToImageBase64(ocrOriginImg);
|
|
29201
|
+
backCropImage = yield blobToImageBase64(ocrImg);
|
|
29202
|
+
}
|
|
29088
29203
|
}
|
|
29204
|
+
return response;
|
|
29089
29205
|
})
|
|
29090
|
-
//
|
|
29206
|
+
// recognizeBase64(
|
|
29091
29207
|
// docId,
|
|
29092
29208
|
// requestImg,
|
|
29093
|
-
//
|
|
29094
|
-
//
|
|
29095
|
-
// report
|
|
29209
|
+
// report,
|
|
29210
|
+
// RecognitionFileType.FlatImage
|
|
29096
29211
|
// )
|
|
29097
29212
|
);
|
|
29098
29213
|
|
|
29099
|
-
|
|
29100
|
-
|
|
29101
|
-
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
|
|
29110
|
-
|
|
29111
|
-
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
|
|
29116
|
-
|
|
29117
|
-
});
|
|
29118
|
-
} else {
|
|
29119
|
-
return idRecognition.recognizeBase64(postData);
|
|
29120
|
-
}
|
|
29121
|
-
})
|
|
29122
|
-
// recognizeBase64(
|
|
29123
|
-
// docId,
|
|
29124
|
-
// requestImg,
|
|
29125
|
-
// report,
|
|
29126
|
-
// RecognitionFileType.FlatImage
|
|
29127
|
-
// )
|
|
29128
|
-
);
|
|
29129
|
-
|
|
29130
|
-
if (resp.retry) {
|
|
29131
|
-
yield util.asyncShowPopup(translateService.translate('sdk.verify.error.blurRetake.title'), translateService.translate('sdk.verify.error.blurRetake.content'), true);
|
|
29132
|
-
throw 'recognition failed';
|
|
29214
|
+
if (resp.retry) {
|
|
29215
|
+
yield util.asyncShowPopup(translateService.translate('sdk.verify.error.blurRetake.title'), translateService.translate('sdk.verify.error.blurRetake.content'), true);
|
|
29216
|
+
throw 'recognition failed';
|
|
29217
|
+
}
|
|
29218
|
+
result = unionMerge(result, resp && resp.details || {});
|
|
29219
|
+
yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
29220
|
+
const postData = {
|
|
29221
|
+
scanDocumentId: docId,
|
|
29222
|
+
details: resp.details,
|
|
29223
|
+
fraud: needFraudOption ? this.fraudResult : null
|
|
29224
|
+
};
|
|
29225
|
+
if (shouldEncrypt) {
|
|
29226
|
+
return idRecognition.finishScanDocument({
|
|
29227
|
+
id: scanId,
|
|
29228
|
+
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29229
|
+
});
|
|
29230
|
+
} else {
|
|
29231
|
+
return idRecognition.finishScanDocument(postData);
|
|
29133
29232
|
}
|
|
29134
|
-
|
|
29135
|
-
|
|
29136
|
-
|
|
29137
|
-
|
|
29138
|
-
|
|
29139
|
-
|
|
29140
|
-
|
|
29141
|
-
if (shouldEncrypt) {
|
|
29142
|
-
return idRecognition.finishScanDocument({
|
|
29143
|
-
id: scanId,
|
|
29144
|
-
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29145
|
-
});
|
|
29146
|
-
} else {
|
|
29147
|
-
return idRecognition.finishScanDocument(postData);
|
|
29148
|
-
}
|
|
29149
|
-
})
|
|
29150
|
-
// finishScanDocument(
|
|
29151
|
-
// docId,
|
|
29152
|
-
// resp.details,
|
|
29153
|
-
// needFraudOption ? this.fraudResult : null
|
|
29154
|
-
// )
|
|
29155
|
-
);
|
|
29233
|
+
})
|
|
29234
|
+
// finishScanDocument(
|
|
29235
|
+
// docId,
|
|
29236
|
+
// resp.details,
|
|
29237
|
+
// needFraudOption ? this.fraudResult : null
|
|
29238
|
+
// )
|
|
29239
|
+
);
|
|
29156
29240
|
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
return false;
|
|
29164
|
-
}
|
|
29165
|
-
} else {
|
|
29166
|
-
console.error('didnt find docid , retry ');
|
|
29241
|
+
delete docInfos[option.cardType];
|
|
29242
|
+
return true;
|
|
29243
|
+
} catch (error) {
|
|
29244
|
+
console.log('confirmImage fail,retrying ');
|
|
29245
|
+
console.error(error);
|
|
29246
|
+
docInfos[option.cardType].docId = docId;
|
|
29167
29247
|
return false;
|
|
29168
29248
|
}
|
|
29169
29249
|
}),
|
|
@@ -29310,7 +29390,7 @@ class OCRModule {
|
|
|
29310
29390
|
width: frameWidth,
|
|
29311
29391
|
height: frameHeight
|
|
29312
29392
|
});
|
|
29313
|
-
const fraudOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
29393
|
+
const fraudOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas, config.resultImageFormat);
|
|
29314
29394
|
if (antiFraudRecogitionResult.eStatus === idRecognition.EAuthMeIDCardAntiFraudStatus.Pass || antiFraudRecogitionResult.eStatus === idRecognition.EAuthMeIDCardAntiFraudStatus.Failed) {
|
|
29315
29395
|
docInfos[type].fraudOriginImg = fraudOriginImg;
|
|
29316
29396
|
this.fraudResult = antiFraudRecogitionResult.eStatus === idRecognition.EAuthMeIDCardAntiFraudStatus.Pass;
|
|
@@ -29429,9 +29509,19 @@ class OCRModule {
|
|
|
29429
29509
|
result = util.splitResult(result);
|
|
29430
29510
|
}
|
|
29431
29511
|
yield util.waitTime(1000);
|
|
29512
|
+
// if (Object.keys(result).length === 0) {
|
|
29513
|
+
// frontCropImage = null;
|
|
29514
|
+
// backCropImage = null;
|
|
29515
|
+
// frontImage = null;
|
|
29516
|
+
// backImage = null;
|
|
29517
|
+
// }
|
|
29432
29518
|
return {
|
|
29433
29519
|
scanId: scanId,
|
|
29434
|
-
details: Object.assign({}, result)
|
|
29520
|
+
details: Object.assign({}, result),
|
|
29521
|
+
frontImage,
|
|
29522
|
+
backImage,
|
|
29523
|
+
frontCropImage,
|
|
29524
|
+
backCropImage
|
|
29435
29525
|
};
|
|
29436
29526
|
}),
|
|
29437
29527
|
onDestroy: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -29820,23 +29910,37 @@ class AuthmeIdentityVerification extends engine.AuthmeFunctionModule {
|
|
|
29820
29910
|
const ocrIdcardResultFormat = util.Storage.getItem(util.STORAGE_KEY['OCR_IDCARD_RESULT_FORMAT']);
|
|
29821
29911
|
const shouldEncrypt = util.Storage.getItem('shouldEncrypt');
|
|
29822
29912
|
const encryptDataBase64 = util.Storage.getItem('encryptDataBase64');
|
|
29913
|
+
const tmpObj = {};
|
|
29823
29914
|
if (ocrIdcardResultFormat === 'splitDateAndAddress') {
|
|
29824
29915
|
data.details = util.combineResult(data.details);
|
|
29825
29916
|
}
|
|
29826
29917
|
const postData = {
|
|
29827
|
-
scanId:
|
|
29828
|
-
details:
|
|
29918
|
+
scanId: util.Storage.getItem('scanId'),
|
|
29919
|
+
details: util.Storage.getItem('confirmedData')
|
|
29829
29920
|
};
|
|
29921
|
+
let res;
|
|
29830
29922
|
if (shouldEncrypt) {
|
|
29831
|
-
yield idRecognition.confirmScan({
|
|
29923
|
+
res = yield idRecognition.confirmScan({
|
|
29832
29924
|
id: data.scanId,
|
|
29833
29925
|
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29834
29926
|
});
|
|
29835
29927
|
} else {
|
|
29836
|
-
yield idRecognition.confirmScan(postData);
|
|
29928
|
+
res = yield idRecognition.confirmScan(postData);
|
|
29929
|
+
}
|
|
29930
|
+
for (let index = 0; index < res.confirmedFields.length; index++) {
|
|
29931
|
+
const element = res.confirmedFields[index];
|
|
29932
|
+
tmpObj[element.fieldName] = {
|
|
29933
|
+
isModified: element.isModified,
|
|
29934
|
+
value: element.value
|
|
29935
|
+
};
|
|
29837
29936
|
}
|
|
29838
29937
|
// await confirmScan(data.scanId, data.details);
|
|
29839
|
-
return
|
|
29938
|
+
return {
|
|
29939
|
+
isSuccess: true,
|
|
29940
|
+
message: '',
|
|
29941
|
+
data: util.Storage.getItem('data'),
|
|
29942
|
+
modifiedData: tmpObj
|
|
29943
|
+
};
|
|
29840
29944
|
});
|
|
29841
29945
|
}
|
|
29842
29946
|
// 考慮未來棄用 auth method ,並將將 auth 的部分,
|
|
@@ -29934,8 +30038,8 @@ class AuthmeIdentityVerification extends engine.AuthmeFunctionModule {
|
|
|
29934
30038
|
}
|
|
29935
30039
|
|
|
29936
30040
|
var name = "authme/sdk";
|
|
29937
|
-
var version$1 = "2.8.
|
|
29938
|
-
var date = "2025-
|
|
30041
|
+
var version$1 = "2.8.1";
|
|
30042
|
+
var date = "2025-02-04T09:12:52+0000";
|
|
29939
30043
|
var packageInfo = {
|
|
29940
30044
|
name: name,
|
|
29941
30045
|
version: version$1,
|
package/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import 'core-js/modules/es.string.includes.js';
|
|
|
6
6
|
import 'core-js/modules/es.promise.js';
|
|
7
7
|
import { getTranslateInstance, EventListenerService, TrackingEvent, generateStatus, StatusDescription, StatusView, StatusAction, AuthmeError, ErrorCode, Feature, StatusEvent, setRequestLoggingFunc, setAccessToken, getCustomerState } from '@authme/core';
|
|
8
8
|
import { EAuthMeFASServiceStatus, EAuthMeIDCardAntiFraudStage as EAuthMeIDCardAntiFraudStage$1, EAuthMeCardClass as EAuthMeCardClass$1, AuthmeFunctionModule, MlEngine, EngineModule, EAuthMeEngineReturnCode, AuthmeEngineModuleBase } from '@authme/engine';
|
|
9
|
-
import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardAntiFraudStage, thicknessDefaultConfig, mapCardtypeToAuthmeClass, cardTypeTitle, cardTypeConfirmTitle, cardTypeHeader,
|
|
10
|
-
import { getCssVariable, RGBToLottieColor, colorToRGB, Icon, useState, clearCanvas, getImageData, isMobile, hidePopup, showPopup, waitTime, TIME_UNIT, AuthmeError as AuthmeError$1, ErrorCode as ErrorCode$1, requestCamera, showElement, asyncOnLineShowErrorMessage, getCanvasSize, startSpinner, stopSpinner, showErrorMessage, hideElement, dataURItoBlob, checkOnlineStatus, UintArrayToBlob, isIphone14proOrProMax, cropByRatio, asyncShowErrorMessage, switchCamera, asyncShowPopup, retryPromiseWithCondition, hideErrorMessage, backgroundRequest, debugTools,
|
|
9
|
+
import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardAntiFraudStage, thicknessDefaultConfig, mapCardtypeToAuthmeClass, getRecognitionColumnOrder, cardTypeTitle, cardTypeConfirmTitle, cardTypeHeader, EAuthMeCardOCRStatus, EAuthMeMRZServiceStatus, saveExtraDoc, initScanDocumentResourceBase64, MRZService, initScan, initScanDocument, ResourceImageType, uploadFrameBase64, finishScanDocument, CardOCR, IdCardAntiFraudService, RecognitionFileType, recognizeBase64, twoWayAuthmeCardClassMap, getCardSubTypes, getCardTypes, confirmScan } from '@authme/id-recognition';
|
|
10
|
+
import { getCssVariable, RGBToLottieColor, colorToRGB, Icon, useState, clearCanvas, getImageData, isMobile, hidePopup, showPopup, waitTime, TIME_UNIT, AuthmeError as AuthmeError$1, ErrorCode as ErrorCode$1, requestCamera, showElement, asyncOnLineShowErrorMessage, getCanvasSize, startSpinner, stopSpinner, showErrorMessage, hideElement, dataURItoBlob, checkOnlineStatus, Storage, UintArrayToBlob, isIphone14proOrProMax, cropByRatio, asyncShowErrorMessage, switchCamera, asyncShowPopup, retryPromiseWithCondition, hideErrorMessage, backgroundRequest, debugTools, showErrorMessageEventName, RUN_FUNCTION_NAME, STORAGE_KEY, splitResult, combineResult, startLoadingSDK, stopLoadingSDK } from '@authme/util';
|
|
11
11
|
import { mergeMap, animationFrames, filter, tap, map, from, catchError, EMPTY, of, merge, fromEvent, concatAll, takeUntil, Subject, defer, switchMap, throttleTime, take, concatMap, throwError, finalize, Observable, interval, mapTo, firstValueFrom, shareReplay, switchMapTo, takeWhile as takeWhile$1, race } from 'rxjs';
|
|
12
12
|
import 'core-js/modules/es.regexp.to-string.js';
|
|
13
13
|
import { FasRecognitionResult, EAuthMeFASServiceStage, FasService, LivenessAPI, EAuthMeMouthStatus, LivenessResultStatus } from '@authme/liveness';
|
|
@@ -121,7 +121,9 @@ const defaultIdRecognitionConfig = {
|
|
|
121
121
|
antiFraudIMetalTagValidCountTh: false,
|
|
122
122
|
cardTypes: [],
|
|
123
123
|
cardTypeConfigs: [],
|
|
124
|
-
captureTimeout: -1
|
|
124
|
+
captureTimeout: -1,
|
|
125
|
+
resultImageFormat: 'jpg',
|
|
126
|
+
confirmPageEnabled: true
|
|
125
127
|
};
|
|
126
128
|
|
|
127
129
|
function setCorrectViewHeight() {
|
|
@@ -24469,9 +24471,14 @@ function renderConfirmUI({
|
|
|
24469
24471
|
document.body.appendChild(confirmContainerElem);
|
|
24470
24472
|
return new Promise((resolve, reject) => {
|
|
24471
24473
|
confirmContainerElem.querySelector('.confirm-btn').addEventListener('click', e => {
|
|
24472
|
-
const modifiedDetails = Object.fromEntries(Object.
|
|
24473
|
-
var _a
|
|
24474
|
-
|
|
24474
|
+
const modifiedDetails = Object.fromEntries(Object.entries(items.details).map(([column, originalValue]) => {
|
|
24475
|
+
var _a;
|
|
24476
|
+
const inputElement = confirmContainerElem.querySelector(`[name="${column}"]`);
|
|
24477
|
+
const inputValue = (_a = inputElement === null || inputElement === void 0 ? void 0 : inputElement.value) !== null && _a !== void 0 ? _a : '';
|
|
24478
|
+
return [column, {
|
|
24479
|
+
isModified: inputValue !== originalValue,
|
|
24480
|
+
value: inputValue
|
|
24481
|
+
}];
|
|
24475
24482
|
}));
|
|
24476
24483
|
sendStatusAction$1(StatusAction.Confirm);
|
|
24477
24484
|
confirmContainerElem.remove();
|
|
@@ -25463,6 +25470,53 @@ const blobToBase64 = image => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
25463
25470
|
reader.readAsDataURL(image);
|
|
25464
25471
|
});
|
|
25465
25472
|
});
|
|
25473
|
+
const blobToImageBase64 = image => __awaiter(void 0, void 0, void 0, function* () {
|
|
25474
|
+
return new Promise((resolve, reject) => {
|
|
25475
|
+
const reader = new FileReader();
|
|
25476
|
+
reader.readAsDataURL(image);
|
|
25477
|
+
reader.onloadend = () => resolve(reader.result);
|
|
25478
|
+
reader.onerror = reject;
|
|
25479
|
+
});
|
|
25480
|
+
});
|
|
25481
|
+
const result2ModifiedData = (result, modifiedResult) => {
|
|
25482
|
+
if (!modifiedResult) {
|
|
25483
|
+
const obj = {};
|
|
25484
|
+
for (const key in result) {
|
|
25485
|
+
obj[key] = {
|
|
25486
|
+
isModified: false,
|
|
25487
|
+
value: result[key]
|
|
25488
|
+
};
|
|
25489
|
+
}
|
|
25490
|
+
return obj;
|
|
25491
|
+
}
|
|
25492
|
+
const modifiedData = {};
|
|
25493
|
+
Object.keys(result).forEach(key => {
|
|
25494
|
+
var _a;
|
|
25495
|
+
if ((_a = modifiedResult[key]) === null || _a === void 0 ? void 0 : _a.isModified) {
|
|
25496
|
+
modifiedData[key] = {
|
|
25497
|
+
isModified: true,
|
|
25498
|
+
value: modifiedResult[key].value
|
|
25499
|
+
};
|
|
25500
|
+
} else {
|
|
25501
|
+
modifiedData[key] = {
|
|
25502
|
+
isModified: false,
|
|
25503
|
+
value: result[key]
|
|
25504
|
+
};
|
|
25505
|
+
}
|
|
25506
|
+
});
|
|
25507
|
+
return modifiedData;
|
|
25508
|
+
};
|
|
25509
|
+
const modifiedData2Result = modifiedResult => {
|
|
25510
|
+
const result = {};
|
|
25511
|
+
if (!modifiedResult) {
|
|
25512
|
+
console.error('modifiedData2Result: modifiedResult is empty');
|
|
25513
|
+
return;
|
|
25514
|
+
}
|
|
25515
|
+
Object.keys(modifiedResult).forEach(key => {
|
|
25516
|
+
result[key] = modifiedResult[key].value;
|
|
25517
|
+
});
|
|
25518
|
+
return result;
|
|
25519
|
+
};
|
|
25466
25520
|
|
|
25467
25521
|
const translateService = getTranslateInstance();
|
|
25468
25522
|
// TODO 處理參數
|
|
@@ -26247,7 +26301,7 @@ function startOCR(config) {
|
|
|
26247
26301
|
if (toastManualCapture) {
|
|
26248
26302
|
toastManualCapture.clear();
|
|
26249
26303
|
}
|
|
26250
|
-
return from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImageManual(canvasSizeInfo)).pipe(switchMap(needRetry => {
|
|
26304
|
+
return from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm || !config.ocrConfig.confirmPageEnabled ? of(false) : checkConfirmImageManual(canvasSizeInfo)).pipe(switchMap(needRetry => {
|
|
26251
26305
|
startSpinner(translateService.translate('sdk.general.uploading'));
|
|
26252
26306
|
if (needRetry) {
|
|
26253
26307
|
hideElement(confirmImageContainer);
|
|
@@ -26297,7 +26351,7 @@ function startOCR(config) {
|
|
|
26297
26351
|
})), tap(() => received = true))))));
|
|
26298
26352
|
};
|
|
26299
26353
|
const autoCapture = canvasSizeInfo => {
|
|
26300
|
-
return of(canvasSizeInfo).pipe(handleOcrSendFrame(canvasSizeInfo, image, video, config.recognition, 30, false,
|
|
26354
|
+
return of(canvasSizeInfo).pipe(handleOcrSendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, config.ocrConfig.resultImageFormat, cardType, type), tap(x => applyTextByResult(x.result)), filter(({
|
|
26301
26355
|
result
|
|
26302
26356
|
}) => result.eStatus === EAuthMeCardOCRStatus.Pass || result.eStatus === EAuthMeMRZServiceStatus.Success), take(1), tap(() => {
|
|
26303
26357
|
if (countdownCaptureTimer && countdownCaptureTimer.end && !countdownCaptureTimer.end()) {
|
|
@@ -26315,7 +26369,7 @@ function startOCR(config) {
|
|
|
26315
26369
|
hideElement(scanAnimationContainer);
|
|
26316
26370
|
}), map(() => resp))), switchMap(({
|
|
26317
26371
|
result
|
|
26318
|
-
}) => from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(switchMap(needRetry => {
|
|
26372
|
+
}) => from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm || !config.ocrConfig.confirmPageEnabled ? of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(switchMap(needRetry => {
|
|
26319
26373
|
if (countdownCaptureTimer && countdownCaptureTimer.end) {
|
|
26320
26374
|
if (needRetry && !countdownCaptureTimer.end()) {
|
|
26321
26375
|
countdownCaptureTimer = countdownTimer(captureTimeoutTimer, () => {
|
|
@@ -26435,7 +26489,8 @@ function startOCR(config) {
|
|
|
26435
26489
|
}), switchMap(canvasSizeInfo => from(config.init(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(tap(x => ocrEngineConfig = x), tap(() => __awaiter(this, void 0, void 0, function* () {
|
|
26436
26490
|
if (config.ocrConfig.needAntiFraud) return;
|
|
26437
26491
|
stopSpinner();
|
|
26438
|
-
})), tap(() => eventListenerService$1.start())
|
|
26492
|
+
})), tap(() => eventListenerService$1.start()) // TODO check useless
|
|
26493
|
+
)))).pipe(tap(() => {
|
|
26439
26494
|
sendStatusAction$1(StatusAction.Uploading);
|
|
26440
26495
|
hideElement(videoContainer);
|
|
26441
26496
|
startSpinner(translateService.translate('sdk.general.uploading'));
|
|
@@ -26443,36 +26498,41 @@ function startOCR(config) {
|
|
|
26443
26498
|
setStatusEvent$1(cardClassResultMapping(config.acceptTypes[config.acceptTypes.length - 1]));
|
|
26444
26499
|
stopSpinner();
|
|
26445
26500
|
container.style.display = 'none';
|
|
26446
|
-
}), concatMap(result => {
|
|
26501
|
+
}), concatMap(result => __awaiter(this, void 0, void 0, function* () {
|
|
26447
26502
|
setStatusView(StatusView.Confirm);
|
|
26448
|
-
|
|
26449
|
-
|
|
26450
|
-
|
|
26451
|
-
|
|
26452
|
-
|
|
26453
|
-
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
translate: key => translateService.translate(key)
|
|
26465
|
-
}
|
|
26466
|
-
})
|
|
26467
|
-
});
|
|
26503
|
+
let modifiedData = result2ModifiedData(result.details);
|
|
26504
|
+
if (config.ocrConfig.displayResultPage) {
|
|
26505
|
+
modifiedData = yield renderConfirmUI({
|
|
26506
|
+
cardType: config.ocrConfig.type,
|
|
26507
|
+
items: {
|
|
26508
|
+
columns: Object.keys(result.details).sort((a, b) => {
|
|
26509
|
+
const aScore = getRecognitionColumnOrder(a);
|
|
26510
|
+
const bScore = getRecognitionColumnOrder(b);
|
|
26511
|
+
return aScore - bScore || a.localeCompare(b);
|
|
26512
|
+
}),
|
|
26513
|
+
details: result.details
|
|
26514
|
+
},
|
|
26515
|
+
options: {
|
|
26516
|
+
headerIcon: config.ocrConfig.icon,
|
|
26517
|
+
translate: key => translateService.translate(key)
|
|
26518
|
+
}
|
|
26468
26519
|
});
|
|
26469
26520
|
}
|
|
26470
26521
|
flags.onConfirm = true;
|
|
26471
|
-
|
|
26472
|
-
|
|
26473
|
-
|
|
26474
|
-
|
|
26475
|
-
|
|
26522
|
+
Storage.setItem('scanId', result.scanId);
|
|
26523
|
+
Storage.setItem('data', result.details);
|
|
26524
|
+
Storage.setItem('confirmedData', modifiedData2Result(modifiedData));
|
|
26525
|
+
return {
|
|
26526
|
+
scanId: result.scanId,
|
|
26527
|
+
isSuccess: true,
|
|
26528
|
+
message: '',
|
|
26529
|
+
data: result.details,
|
|
26530
|
+
modifiedData: modifiedData,
|
|
26531
|
+
backCropImage: result.backCropImage,
|
|
26532
|
+
frontCropImage: result.frontCropImage,
|
|
26533
|
+
frontImage: result.frontImage,
|
|
26534
|
+
backImage: result.backImage
|
|
26535
|
+
};
|
|
26476
26536
|
})), takeUntil(unsubscribe$), finalize(() => {
|
|
26477
26537
|
sendStatusDescription$1(StatusDescription.Complete);
|
|
26478
26538
|
stopSpinner();
|
|
@@ -26482,7 +26542,7 @@ function startOCR(config) {
|
|
|
26482
26542
|
const type = currentType('get', null).type;
|
|
26483
26543
|
const cardType = currentType('get', null).cardType;
|
|
26484
26544
|
const ctx = image.getContext('2d');
|
|
26485
|
-
const imageData = getImageData(image, ctx, video, canvasSizeInfo, false,
|
|
26545
|
+
const imageData = getImageData(image, ctx, video, canvasSizeInfo, false, config.ocrConfig.resultImageFormat);
|
|
26486
26546
|
const imageBlob = UintArrayToBlob(canvasSizeInfo.width, canvasSizeInfo.height, imageData.data);
|
|
26487
26547
|
const cancelResultObj = {
|
|
26488
26548
|
isSuccess: false,
|
|
@@ -28377,6 +28437,10 @@ class OCRModule {
|
|
|
28377
28437
|
let uploadFullFrame = false;
|
|
28378
28438
|
let fraudTimeout = DEFAULT_ANTI_FRAUD_TIMEOUT;
|
|
28379
28439
|
let shouldEncrypt = false;
|
|
28440
|
+
let frontImage = null;
|
|
28441
|
+
let backImage = null;
|
|
28442
|
+
let frontCropImage = null;
|
|
28443
|
+
let backCropImage = null;
|
|
28380
28444
|
const {
|
|
28381
28445
|
getDebugLogsLength,
|
|
28382
28446
|
modifyDeubgLog,
|
|
@@ -28842,7 +28906,7 @@ class OCRModule {
|
|
|
28842
28906
|
width: frameWidth,
|
|
28843
28907
|
height: frameHeight
|
|
28844
28908
|
});
|
|
28845
|
-
const fraudOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
28909
|
+
const fraudOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas, config.resultImageFormat);
|
|
28846
28910
|
const thicknessResult = Object.assign(Object.assign({}, antiFraudRecogitionResult), {
|
|
28847
28911
|
imageData: data
|
|
28848
28912
|
});
|
|
@@ -28969,10 +29033,10 @@ class OCRModule {
|
|
|
28969
29033
|
width: frameWidth,
|
|
28970
29034
|
height: frameHeight
|
|
28971
29035
|
});
|
|
28972
|
-
const ocrOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
29036
|
+
const ocrOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas, config.resultImageFormat);
|
|
28973
29037
|
const eClass = cardType !== null && cardType !== void 0 ? cardType : '';
|
|
28974
29038
|
if (result.eStatus === EAuthMeCardOCRStatus.Pass && result.imageData && !!docInfos[eClass].docId) {
|
|
28975
|
-
const resultOcrImg = UintArrayToBlob(result.iWidth, result.iHeight, result === null || result === void 0 ? void 0 : result.imageData, virtualCanvas);
|
|
29039
|
+
const resultOcrImg = UintArrayToBlob(result.iWidth, result.iHeight, result === null || result === void 0 ? void 0 : result.imageData, virtualCanvas, config.resultImageFormat);
|
|
28976
29040
|
docInfos[eClass].ocrImg = resultOcrImg;
|
|
28977
29041
|
docInfos[eClass].ocrOriginImg = ocrOriginImg;
|
|
28978
29042
|
yield _service.stop();
|
|
@@ -28992,6 +29056,11 @@ class OCRModule {
|
|
|
28992
29056
|
// downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
|
|
28993
29057
|
frameIndex++;
|
|
28994
29058
|
backgroundRequest(() => __awaiter(this, void 0, void 0, function* () {
|
|
29059
|
+
console.log('recognition', docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId);
|
|
29060
|
+
if (docInfos[eClass].docId === '') {
|
|
29061
|
+
console.warn('didnt find docid, retry');
|
|
29062
|
+
return false;
|
|
29063
|
+
}
|
|
28995
29064
|
const postData = {
|
|
28996
29065
|
scanDocumentId: docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId,
|
|
28997
29066
|
image: requestImg,
|
|
@@ -29042,120 +29111,131 @@ class OCRModule {
|
|
|
29042
29111
|
this.ocrService.stop();
|
|
29043
29112
|
}
|
|
29044
29113
|
const docId = docInfos[option.cardType].docId;
|
|
29045
|
-
if (docId) {
|
|
29046
|
-
|
|
29047
|
-
|
|
29048
|
-
|
|
29049
|
-
|
|
29114
|
+
if (!docId) {
|
|
29115
|
+
console.warn('didnt find docid , retry');
|
|
29116
|
+
return false;
|
|
29117
|
+
}
|
|
29118
|
+
const ocrImg = option.imageData ? option.imageData : docInfos[option.cardType].ocrImg;
|
|
29119
|
+
const needFraudOption = config.needAntiFraud && option.type === EAuthMeCardClass$1.TWN_IDCard_Front;
|
|
29120
|
+
let ocrOriginImg;
|
|
29121
|
+
if (option.imageData) {
|
|
29122
|
+
ocrOriginImg = option.imageData;
|
|
29123
|
+
} else {
|
|
29124
|
+
ocrOriginImg = docInfos[option.cardType].ocrOriginImg;
|
|
29125
|
+
}
|
|
29126
|
+
// const base64Image = await blobToBase64(ocrOriginImg);
|
|
29127
|
+
// console.log('confirmImage', base64Image);
|
|
29128
|
+
const requestImg = yield encryptImageBase64(ocrOriginImg);
|
|
29129
|
+
const report = yield this.ocrService.getReport();
|
|
29130
|
+
docInfos[option.cardType].docId = '';
|
|
29131
|
+
modifyDeubgLog(getDebugLogsLength() - 1, {
|
|
29132
|
+
report: report
|
|
29133
|
+
});
|
|
29134
|
+
frameIndex++;
|
|
29135
|
+
yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
29136
|
+
const postData = {
|
|
29137
|
+
scanDocumentId: docId,
|
|
29138
|
+
image: requestImg,
|
|
29139
|
+
type: ResourceImageType.Recognition,
|
|
29140
|
+
info: {
|
|
29141
|
+
report: report,
|
|
29142
|
+
index: frameIndex
|
|
29143
|
+
}
|
|
29144
|
+
};
|
|
29145
|
+
if (shouldEncrypt) {
|
|
29146
|
+
postData.image = yield blobToBase64(ocrOriginImg);
|
|
29147
|
+
return uploadFrameBase64({
|
|
29148
|
+
id: scanId,
|
|
29149
|
+
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29150
|
+
});
|
|
29050
29151
|
} else {
|
|
29051
|
-
|
|
29152
|
+
return uploadFrameBase64(postData);
|
|
29052
29153
|
}
|
|
29053
|
-
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29154
|
+
})
|
|
29155
|
+
// uploadFrameBase64(
|
|
29156
|
+
// docId,
|
|
29157
|
+
// requestImg,
|
|
29158
|
+
// frameIndex,
|
|
29159
|
+
// ResourceImageType.Recognition,
|
|
29160
|
+
// report
|
|
29161
|
+
// )
|
|
29162
|
+
);
|
|
29163
|
+
|
|
29164
|
+
frameIndex = 0;
|
|
29165
|
+
try {
|
|
29166
|
+
const _requestImg = yield encryptImageBase64(ocrImg);
|
|
29167
|
+
const resp = yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
29063
29168
|
const postData = {
|
|
29064
29169
|
scanDocumentId: docId,
|
|
29065
|
-
image:
|
|
29066
|
-
|
|
29170
|
+
image: _requestImg,
|
|
29171
|
+
fileType: RecognitionFileType.FlatImage,
|
|
29067
29172
|
info: {
|
|
29068
|
-
report: report
|
|
29069
|
-
index: frameIndex
|
|
29173
|
+
report: report
|
|
29070
29174
|
}
|
|
29071
29175
|
};
|
|
29176
|
+
let response;
|
|
29072
29177
|
if (shouldEncrypt) {
|
|
29073
|
-
postData.image = yield blobToBase64(
|
|
29074
|
-
|
|
29178
|
+
postData.image = yield blobToBase64(ocrImg);
|
|
29179
|
+
response = yield recognizeBase64({
|
|
29075
29180
|
id: scanId,
|
|
29076
29181
|
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29077
29182
|
});
|
|
29078
29183
|
} else {
|
|
29079
|
-
|
|
29184
|
+
response = yield recognizeBase64(postData);
|
|
29185
|
+
}
|
|
29186
|
+
if (response === null || response === void 0 ? void 0 : response.detectCardResult) {
|
|
29187
|
+
if (option.cardType.toLocaleLowerCase().includes('front')) {
|
|
29188
|
+
frontImage = yield blobToImageBase64(ocrOriginImg);
|
|
29189
|
+
frontCropImage = yield blobToImageBase64(ocrImg);
|
|
29190
|
+
}
|
|
29191
|
+
if (option.cardType.toLocaleLowerCase().includes('back')) {
|
|
29192
|
+
backImage = yield blobToImageBase64(ocrOriginImg);
|
|
29193
|
+
backCropImage = yield blobToImageBase64(ocrImg);
|
|
29194
|
+
}
|
|
29080
29195
|
}
|
|
29196
|
+
return response;
|
|
29081
29197
|
})
|
|
29082
|
-
//
|
|
29198
|
+
// recognizeBase64(
|
|
29083
29199
|
// docId,
|
|
29084
29200
|
// requestImg,
|
|
29085
|
-
//
|
|
29086
|
-
//
|
|
29087
|
-
// report
|
|
29201
|
+
// report,
|
|
29202
|
+
// RecognitionFileType.FlatImage
|
|
29088
29203
|
// )
|
|
29089
29204
|
);
|
|
29090
29205
|
|
|
29091
|
-
|
|
29092
|
-
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
|
|
29096
|
-
|
|
29097
|
-
|
|
29098
|
-
|
|
29099
|
-
|
|
29100
|
-
|
|
29101
|
-
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
});
|
|
29110
|
-
} else {
|
|
29111
|
-
return recognizeBase64(postData);
|
|
29112
|
-
}
|
|
29113
|
-
})
|
|
29114
|
-
// recognizeBase64(
|
|
29115
|
-
// docId,
|
|
29116
|
-
// requestImg,
|
|
29117
|
-
// report,
|
|
29118
|
-
// RecognitionFileType.FlatImage
|
|
29119
|
-
// )
|
|
29120
|
-
);
|
|
29121
|
-
|
|
29122
|
-
if (resp.retry) {
|
|
29123
|
-
yield asyncShowPopup(translateService.translate('sdk.verify.error.blurRetake.title'), translateService.translate('sdk.verify.error.blurRetake.content'), true);
|
|
29124
|
-
throw 'recognition failed';
|
|
29206
|
+
if (resp.retry) {
|
|
29207
|
+
yield asyncShowPopup(translateService.translate('sdk.verify.error.blurRetake.title'), translateService.translate('sdk.verify.error.blurRetake.content'), true);
|
|
29208
|
+
throw 'recognition failed';
|
|
29209
|
+
}
|
|
29210
|
+
result = unionMerge(result, resp && resp.details || {});
|
|
29211
|
+
yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
29212
|
+
const postData = {
|
|
29213
|
+
scanDocumentId: docId,
|
|
29214
|
+
details: resp.details,
|
|
29215
|
+
fraud: needFraudOption ? this.fraudResult : null
|
|
29216
|
+
};
|
|
29217
|
+
if (shouldEncrypt) {
|
|
29218
|
+
return finishScanDocument({
|
|
29219
|
+
id: scanId,
|
|
29220
|
+
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29221
|
+
});
|
|
29222
|
+
} else {
|
|
29223
|
+
return finishScanDocument(postData);
|
|
29125
29224
|
}
|
|
29126
|
-
|
|
29127
|
-
|
|
29128
|
-
|
|
29129
|
-
|
|
29130
|
-
|
|
29131
|
-
|
|
29132
|
-
|
|
29133
|
-
if (shouldEncrypt) {
|
|
29134
|
-
return finishScanDocument({
|
|
29135
|
-
id: scanId,
|
|
29136
|
-
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29137
|
-
});
|
|
29138
|
-
} else {
|
|
29139
|
-
return finishScanDocument(postData);
|
|
29140
|
-
}
|
|
29141
|
-
})
|
|
29142
|
-
// finishScanDocument(
|
|
29143
|
-
// docId,
|
|
29144
|
-
// resp.details,
|
|
29145
|
-
// needFraudOption ? this.fraudResult : null
|
|
29146
|
-
// )
|
|
29147
|
-
);
|
|
29225
|
+
})
|
|
29226
|
+
// finishScanDocument(
|
|
29227
|
+
// docId,
|
|
29228
|
+
// resp.details,
|
|
29229
|
+
// needFraudOption ? this.fraudResult : null
|
|
29230
|
+
// )
|
|
29231
|
+
);
|
|
29148
29232
|
|
|
29149
|
-
|
|
29150
|
-
|
|
29151
|
-
|
|
29152
|
-
|
|
29153
|
-
|
|
29154
|
-
|
|
29155
|
-
return false;
|
|
29156
|
-
}
|
|
29157
|
-
} else {
|
|
29158
|
-
console.error('didnt find docid , retry ');
|
|
29233
|
+
delete docInfos[option.cardType];
|
|
29234
|
+
return true;
|
|
29235
|
+
} catch (error) {
|
|
29236
|
+
console.log('confirmImage fail,retrying ');
|
|
29237
|
+
console.error(error);
|
|
29238
|
+
docInfos[option.cardType].docId = docId;
|
|
29159
29239
|
return false;
|
|
29160
29240
|
}
|
|
29161
29241
|
}),
|
|
@@ -29302,7 +29382,7 @@ class OCRModule {
|
|
|
29302
29382
|
width: frameWidth,
|
|
29303
29383
|
height: frameHeight
|
|
29304
29384
|
});
|
|
29305
|
-
const fraudOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
29385
|
+
const fraudOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas, config.resultImageFormat);
|
|
29306
29386
|
if (antiFraudRecogitionResult.eStatus === EAuthMeIDCardAntiFraudStatus.Pass || antiFraudRecogitionResult.eStatus === EAuthMeIDCardAntiFraudStatus.Failed) {
|
|
29307
29387
|
docInfos[type].fraudOriginImg = fraudOriginImg;
|
|
29308
29388
|
this.fraudResult = antiFraudRecogitionResult.eStatus === EAuthMeIDCardAntiFraudStatus.Pass;
|
|
@@ -29421,9 +29501,19 @@ class OCRModule {
|
|
|
29421
29501
|
result = splitResult(result);
|
|
29422
29502
|
}
|
|
29423
29503
|
yield waitTime(1000);
|
|
29504
|
+
// if (Object.keys(result).length === 0) {
|
|
29505
|
+
// frontCropImage = null;
|
|
29506
|
+
// backCropImage = null;
|
|
29507
|
+
// frontImage = null;
|
|
29508
|
+
// backImage = null;
|
|
29509
|
+
// }
|
|
29424
29510
|
return {
|
|
29425
29511
|
scanId: scanId,
|
|
29426
|
-
details: Object.assign({}, result)
|
|
29512
|
+
details: Object.assign({}, result),
|
|
29513
|
+
frontImage,
|
|
29514
|
+
backImage,
|
|
29515
|
+
frontCropImage,
|
|
29516
|
+
backCropImage
|
|
29427
29517
|
};
|
|
29428
29518
|
}),
|
|
29429
29519
|
onDestroy: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -29812,23 +29902,37 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
|
|
|
29812
29902
|
const ocrIdcardResultFormat = Storage.getItem(STORAGE_KEY['OCR_IDCARD_RESULT_FORMAT']);
|
|
29813
29903
|
const shouldEncrypt = Storage.getItem('shouldEncrypt');
|
|
29814
29904
|
const encryptDataBase64 = Storage.getItem('encryptDataBase64');
|
|
29905
|
+
const tmpObj = {};
|
|
29815
29906
|
if (ocrIdcardResultFormat === 'splitDateAndAddress') {
|
|
29816
29907
|
data.details = combineResult(data.details);
|
|
29817
29908
|
}
|
|
29818
29909
|
const postData = {
|
|
29819
|
-
scanId:
|
|
29820
|
-
details:
|
|
29910
|
+
scanId: Storage.getItem('scanId'),
|
|
29911
|
+
details: Storage.getItem('confirmedData')
|
|
29821
29912
|
};
|
|
29913
|
+
let res;
|
|
29822
29914
|
if (shouldEncrypt) {
|
|
29823
|
-
yield confirmScan({
|
|
29915
|
+
res = yield confirmScan({
|
|
29824
29916
|
id: data.scanId,
|
|
29825
29917
|
encryptedBase64String: yield encryptDataBase64(postData)
|
|
29826
29918
|
});
|
|
29827
29919
|
} else {
|
|
29828
|
-
yield confirmScan(postData);
|
|
29920
|
+
res = yield confirmScan(postData);
|
|
29921
|
+
}
|
|
29922
|
+
for (let index = 0; index < res.confirmedFields.length; index++) {
|
|
29923
|
+
const element = res.confirmedFields[index];
|
|
29924
|
+
tmpObj[element.fieldName] = {
|
|
29925
|
+
isModified: element.isModified,
|
|
29926
|
+
value: element.value
|
|
29927
|
+
};
|
|
29829
29928
|
}
|
|
29830
29929
|
// await confirmScan(data.scanId, data.details);
|
|
29831
|
-
return
|
|
29930
|
+
return {
|
|
29931
|
+
isSuccess: true,
|
|
29932
|
+
message: '',
|
|
29933
|
+
data: Storage.getItem('data'),
|
|
29934
|
+
modifiedData: tmpObj
|
|
29935
|
+
};
|
|
29832
29936
|
});
|
|
29833
29937
|
}
|
|
29834
29938
|
// 考慮未來棄用 auth method ,並將將 auth 的部分,
|
|
@@ -29926,8 +30030,8 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
|
|
|
29926
30030
|
}
|
|
29927
30031
|
|
|
29928
30032
|
var name = "authme/sdk";
|
|
29929
|
-
var version$1 = "2.8.
|
|
29930
|
-
var date = "2025-
|
|
30033
|
+
var version$1 = "2.8.1";
|
|
30034
|
+
var date = "2025-02-04T09:12:52+0000";
|
|
29931
30035
|
var packageInfo = {
|
|
29932
30036
|
name: name,
|
|
29933
30037
|
version: version$1,
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authme/identity-verification",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"core-js": "^3.6.0",
|
|
6
6
|
"lottie-web": "^5.9.2",
|
|
7
7
|
"rxjs": "^7.4.0",
|
|
8
|
-
"@authme/core": "2.8.
|
|
9
|
-
"@authme/engine": "2.8.
|
|
10
|
-
"@authme/id-recognition": "2.8.
|
|
11
|
-
"@authme/util": "2.8.
|
|
12
|
-
"@authme/liveness": "2.8.
|
|
8
|
+
"@authme/core": "2.8.1",
|
|
9
|
+
"@authme/engine": "2.8.1",
|
|
10
|
+
"@authme/id-recognition": "2.8.1",
|
|
11
|
+
"@authme/util": "2.8.1",
|
|
12
|
+
"@authme/liveness": "2.8.1"
|
|
13
13
|
},
|
|
14
14
|
"module": "./index.js",
|
|
15
15
|
"main": "./index.cjs",
|
|
@@ -20,11 +20,11 @@ export declare class AuthmeIdentityVerification extends AuthmeFunctionModule {
|
|
|
20
20
|
extraDocument(userConfig?: Partial<ExtraDocumentConfig>): Promise<AuthmeExtraDocumentResult>;
|
|
21
21
|
IdRecognition(userConfig: IdRecognitionConfig): Promise<AuthmeOCRResult>;
|
|
22
22
|
confirmOCRResult(data: {
|
|
23
|
-
scanId: string;
|
|
23
|
+
scanId: string | undefined;
|
|
24
24
|
details: {
|
|
25
25
|
[key: string]: string;
|
|
26
26
|
};
|
|
27
|
-
}): Promise<
|
|
27
|
+
}): Promise<AuthmeOCRResult>;
|
|
28
28
|
auth(authParams: {
|
|
29
29
|
cert: string;
|
|
30
30
|
authToken: string;
|
|
@@ -58,6 +58,8 @@ export interface IdRecognitionConfig {
|
|
|
58
58
|
cardTypes?: string[];
|
|
59
59
|
cardTypeConfigs?: object[];
|
|
60
60
|
captureTimeout?: number;
|
|
61
|
+
resultImageFormat?: 'jpg' | 'png';
|
|
62
|
+
confirmPageEnabled?: boolean;
|
|
61
63
|
}
|
|
62
64
|
export interface GetCardTypeAndCountryConfig {
|
|
63
65
|
supportCountries: CountryCode[];
|
|
@@ -8,22 +8,25 @@ export declare type AuthmeLivenessResult = {
|
|
|
8
8
|
message: string;
|
|
9
9
|
cause?: any;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
isSuccess:
|
|
11
|
+
export interface AuthmeOCRResult {
|
|
12
|
+
isSuccess: boolean;
|
|
13
13
|
message: string;
|
|
14
|
-
|
|
14
|
+
data: any;
|
|
15
|
+
code?: string | number;
|
|
15
16
|
cause?: any;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
scanId?: string;
|
|
18
|
+
frontImage?: string | null;
|
|
19
|
+
backImage?: string | null;
|
|
20
|
+
frontCropImage?: string | null;
|
|
21
|
+
backCropImage?: string | null;
|
|
22
|
+
modifiedData?: AuthmeOCRModifiedData;
|
|
23
|
+
}
|
|
24
|
+
export interface AuthmeOCRModifiedData {
|
|
25
|
+
[key: string]: {
|
|
26
|
+
isModified: boolean;
|
|
27
|
+
value: string;
|
|
25
28
|
};
|
|
26
|
-
}
|
|
29
|
+
}
|
|
27
30
|
export interface AuthmeResult {
|
|
28
31
|
isSuccess: boolean;
|
|
29
32
|
message: string;
|
package/src/lib/ui/ocr-flow.d.ts
CHANGED
|
@@ -105,6 +105,10 @@ export declare function startOCR(config: {
|
|
|
105
105
|
details: {
|
|
106
106
|
[key: string]: string;
|
|
107
107
|
};
|
|
108
|
+
frontImage?: string | null;
|
|
109
|
+
backImage?: string | null;
|
|
110
|
+
frontCropImage?: string | null;
|
|
111
|
+
backCropImage?: string | null;
|
|
108
112
|
}>;
|
|
109
113
|
onDestroy: () => Promise<void>;
|
|
110
114
|
getCardMatchROI?: () => Promise<Point[]>;
|
package/src/lib/ui/ocr.ui.d.ts
CHANGED
|
@@ -97,9 +97,7 @@ export declare function renderConfirmUI({ cardType, items, options: { headerIcon
|
|
|
97
97
|
headerIcon?: string;
|
|
98
98
|
translate?: (str: string) => string;
|
|
99
99
|
};
|
|
100
|
-
}): Promise<
|
|
101
|
-
[column: string]: string;
|
|
102
|
-
}>;
|
|
100
|
+
}): Promise<any>;
|
|
103
101
|
declare type BorderType = 'cornered' | 'bordered';
|
|
104
102
|
export declare const renderOCRMask: (params: {
|
|
105
103
|
cardPoints: Point[];
|
|
@@ -7,3 +7,16 @@ export declare const countdownTimer: (time: number, doSomething?: any) => {
|
|
|
7
7
|
end: () => boolean;
|
|
8
8
|
};
|
|
9
9
|
export declare const blobToBase64: (image: Blob) => Promise<string>;
|
|
10
|
+
export declare const blobToImageBase64: (image: Blob) => Promise<any>;
|
|
11
|
+
export declare const result2ModifiedData: (result: any, modifiedResult?: {
|
|
12
|
+
[key: string]: {
|
|
13
|
+
isModified: boolean;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
}) => any;
|
|
17
|
+
export declare const modifiedData2Result: (modifiedResult: {
|
|
18
|
+
[key: string]: {
|
|
19
|
+
isModified: boolean;
|
|
20
|
+
value: string;
|
|
21
|
+
};
|
|
22
|
+
}) => any;
|