@authme/identity-verification 2.8.52 → 2.8.55
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.js +57 -18
- package/index.esm.js +57 -18
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -29332,7 +29332,7 @@ const modal = arg => {
|
|
|
29332
29332
|
domTitle.innerText = arg.title;
|
|
29333
29333
|
domSubtitle.innerText = arg.subtitle;
|
|
29334
29334
|
domImage.src = arg.image;
|
|
29335
|
-
domContent.
|
|
29335
|
+
domContent.textContent = arg.content;
|
|
29336
29336
|
domClose.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.1943 6.41714C19.6393 5.97216 19.6393 5.2507 19.1943 4.80571C18.7493 4.36073 18.0278 4.36073 17.5829 4.80571L12 10.3886L6.41714 4.80572C5.97216 4.36073 5.2507 4.36073 4.80571 4.80571C4.36073 5.2507 4.36073 5.97216 4.80571 6.41714L10.3886 12L4.80571 17.5829C4.36073 18.0278 4.36073 18.7493 4.80571 19.1943C5.2507 19.6393 5.97216 19.6393 6.41714 19.1943L12 13.6114L17.5829 19.1943C18.0278 19.6393 18.7493 19.6393 19.1943 19.1943C19.6393 18.7493 19.6393 18.0278 19.1943 17.5829L13.6114 12L19.1943 6.41714Z" fill="${uiThemeConfig.nonEkycCloseButton.contentColor}" fill-opacity="${uiThemeConfig.nonEkycCloseButton.contentOpacity}" /></svg>`;
|
|
29337
29337
|
domConfirm.innerText = arg.confirm;
|
|
29338
29338
|
domClose.addEventListener('click', async () => {
|
|
@@ -31561,7 +31561,7 @@ const toast = arg => {
|
|
|
31561
31561
|
} else {
|
|
31562
31562
|
toast.style.opacity = '1';
|
|
31563
31563
|
}
|
|
31564
|
-
toast.
|
|
31564
|
+
toast.textContent = message;
|
|
31565
31565
|
document.body.appendChild(toast);
|
|
31566
31566
|
timer = setTimeout(() => {
|
|
31567
31567
|
clearStatus = true;
|
|
@@ -31810,7 +31810,7 @@ const popupView = arg => {
|
|
|
31810
31810
|
}
|
|
31811
31811
|
if (arg.cancel) {
|
|
31812
31812
|
util.uiThemeSmallButton(domCancel, uiThemeConfig.smallerMinorButton);
|
|
31813
|
-
domCancel.
|
|
31813
|
+
domCancel.textContent = arg.cancel;
|
|
31814
31814
|
domCancel.addEventListener('click', async () => {
|
|
31815
31815
|
if (arg.onCancel) {
|
|
31816
31816
|
arg.onCancel();
|
|
@@ -31824,9 +31824,9 @@ const popupView = arg => {
|
|
|
31824
31824
|
}
|
|
31825
31825
|
removePopview();
|
|
31826
31826
|
});
|
|
31827
|
-
domTitle.
|
|
31828
|
-
domContent.
|
|
31829
|
-
domConfirm.
|
|
31827
|
+
domTitle.textContent = arg.title;
|
|
31828
|
+
domContent.textContent = arg.content;
|
|
31829
|
+
domConfirm.textContent = arg.confirm;
|
|
31830
31830
|
domPopupViewContainer.appendChild(domTitleContainer);
|
|
31831
31831
|
domTitleContainer.appendChild(domTitle);
|
|
31832
31832
|
domPopupViewContainer.appendChild(domContentContainer);
|
|
@@ -34998,12 +34998,14 @@ class MRZModule {
|
|
|
34998
34998
|
let uploadFullFrame = false;
|
|
34999
34999
|
let pubKey = '';
|
|
35000
35000
|
let latestTField = null;
|
|
35001
|
+
let currentCardType = null;
|
|
35001
35002
|
const virtualCanvas = document.createElement('canvas');
|
|
35002
35003
|
const docInfos = {};
|
|
35003
35004
|
let shouldEncrypt = false;
|
|
35004
35005
|
const encryptImageBase64 = async function encryptImageBase64(blob) {
|
|
35005
35006
|
const imageArrayBuffer = await blobToArrayBuffer(blob);
|
|
35006
|
-
const
|
|
35007
|
+
const uint8Array = new Uint8Array(imageArrayBuffer);
|
|
35008
|
+
const resultEncrypt = await _this.mrzService.encryptBlob(uint8Array, pubKey);
|
|
35007
35009
|
return resultEncrypt;
|
|
35008
35010
|
};
|
|
35009
35011
|
const blobToArrayBuffer = async function blobToArrayBuffer(blob) {
|
|
@@ -35040,6 +35042,8 @@ class MRZModule {
|
|
|
35040
35042
|
frameHeight = height;
|
|
35041
35043
|
const resp = await SendRequestWithRetry$1(() => idRecognition.initScan(config.type, config.country, config.needConfirm, config.cardTypes));
|
|
35042
35044
|
shouldEncrypt = (_resp$shouldEncrypt = resp.shouldEncrypt) != null ? _resp$shouldEncrypt : shouldEncrypt;
|
|
35045
|
+
util.Storage.setItem('shouldEncrypt', shouldEncrypt);
|
|
35046
|
+
util.Storage.setItem('encryptDataBase64', encryptDataBase64);
|
|
35043
35047
|
pubKey = resp.parameters.pubKey;
|
|
35044
35048
|
scanId = resp.scanId;
|
|
35045
35049
|
uploadFullFrame = (_resp$parameters$frau = (_resp$parameters$frau2 = resp.parameters.fraud) == null ? void 0 : _resp$parameters$frau2.collectAllFrames) != null ? _resp$parameters$frau : config.uploadFullFrame;
|
|
@@ -35059,9 +35063,15 @@ class MRZModule {
|
|
|
35059
35063
|
});
|
|
35060
35064
|
},
|
|
35061
35065
|
ocrStart: async function (points, type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, faceMode, cardType, retry = false) {
|
|
35066
|
+
currentCardType = type;
|
|
35062
35067
|
await _this.mrzService.init();
|
|
35063
35068
|
await _this.mrzService.setFrameSize(frameWidth, frameHeight);
|
|
35064
35069
|
await _this.mrzService.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
|
|
35070
|
+
const oldParams = await _this.mrzService.getParams();
|
|
35071
|
+
await _this.mrzService.setParams(Object.assign({}, oldParams, {
|
|
35072
|
+
fImageBlurTh: 750,
|
|
35073
|
+
fCardMatchTh: 0.3
|
|
35074
|
+
}));
|
|
35065
35075
|
await _this.mrzService.startSession();
|
|
35066
35076
|
if (retry) {
|
|
35067
35077
|
docInfos[type].ocrImg = null;
|
|
@@ -35100,6 +35110,7 @@ class MRZModule {
|
|
|
35100
35110
|
},
|
|
35101
35111
|
acceptTypes,
|
|
35102
35112
|
recognition: async function (data) {
|
|
35113
|
+
var _docInfos$currentCard;
|
|
35103
35114
|
const mrzResult = await _this.mrzService.recognition(data);
|
|
35104
35115
|
if (_this.canvas) {
|
|
35105
35116
|
var _this$mrzService;
|
|
@@ -35114,8 +35125,28 @@ class MRZModule {
|
|
|
35114
35125
|
imgData.data.set(debugData);
|
|
35115
35126
|
ctx.putImageData(imgData, 0, 0);
|
|
35116
35127
|
}
|
|
35117
|
-
if (mrzResult.eStatus === idRecognition.EAuthMeMRZServiceStatus.Success
|
|
35118
|
-
|
|
35128
|
+
if (mrzResult.eStatus === idRecognition.EAuthMeMRZServiceStatus.Success) {
|
|
35129
|
+
const cardType = currentCardType;
|
|
35130
|
+
const ocrOriginImg = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
35131
|
+
// V9: 如果有卡片圖像就使用它,否則使用原始幀圖像
|
|
35132
|
+
let resultOcrImg;
|
|
35133
|
+
if (mrzResult.imageData && mrzResult.iWidth > 0 && mrzResult.iHeight > 0) {
|
|
35134
|
+
resultOcrImg = util.UintArrayToBlob(mrzResult.iWidth, mrzResult.iHeight, mrzResult.imageData, virtualCanvas);
|
|
35135
|
+
} else {
|
|
35136
|
+
resultOcrImg = ocrOriginImg;
|
|
35137
|
+
}
|
|
35138
|
+
// 存圖不等 docId — 避免競態條件導致圖片遺失
|
|
35139
|
+
if (!docInfos[cardType]) {
|
|
35140
|
+
docInfos[cardType] = {
|
|
35141
|
+
docId: '',
|
|
35142
|
+
ocrImg: null,
|
|
35143
|
+
ocrOriginImg: null,
|
|
35144
|
+
fraudOriginImg: null,
|
|
35145
|
+
fraudResult: null
|
|
35146
|
+
};
|
|
35147
|
+
}
|
|
35148
|
+
docInfos[cardType].ocrImg = resultOcrImg;
|
|
35149
|
+
docInfos[cardType].ocrOriginImg = ocrOriginImg;
|
|
35119
35150
|
await _this.mrzService.stop();
|
|
35120
35151
|
// 1. 最後結果統一使用 getFinalResult 取得的結果。
|
|
35121
35152
|
// 2. 由於 engine-lib 限制,getFinalResult 必須要在 stop 之後呼叫。
|
|
@@ -35159,13 +35190,13 @@ class MRZModule {
|
|
|
35159
35190
|
}
|
|
35160
35191
|
}
|
|
35161
35192
|
}
|
|
35162
|
-
} else if (uploadFullFrame) {
|
|
35193
|
+
} else if (uploadFullFrame && currentCardType && (_docInfos$currentCard = docInfos[currentCardType]) != null && _docInfos$currentCard.docId) {
|
|
35163
35194
|
const image = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
35164
35195
|
const requestImg = await encryptImageBase64(image);
|
|
35165
|
-
|
|
35196
|
+
const uploadCardType = currentCardType;
|
|
35166
35197
|
util.backgroundRequest(async function () {
|
|
35167
35198
|
const postData = {
|
|
35168
|
-
scanDocumentId: docInfos[
|
|
35199
|
+
scanDocumentId: docInfos[uploadCardType].docId,
|
|
35169
35200
|
image: requestImg,
|
|
35170
35201
|
type: idRecognition.ResourceImageType.Recognition,
|
|
35171
35202
|
info: {
|
|
@@ -35194,10 +35225,15 @@ class MRZModule {
|
|
|
35194
35225
|
}
|
|
35195
35226
|
},
|
|
35196
35227
|
confirmImage: async function (option) {
|
|
35197
|
-
|
|
35228
|
+
var _docInfos$option$type;
|
|
35229
|
+
const docId = (_docInfos$option$type = docInfos[option.type]) == null ? void 0 : _docInfos$option$type.docId;
|
|
35198
35230
|
if (docId) {
|
|
35199
35231
|
docInfos[option.type].docId = '';
|
|
35200
|
-
const
|
|
35232
|
+
const ocrOriginImg = docInfos[option.type].ocrOriginImg;
|
|
35233
|
+
if (!ocrOriginImg) {
|
|
35234
|
+
throw new core.AuthmeError(core.ErrorCode.SDK_INTERNAL_ERROR, 'MRZ card image not available for upload');
|
|
35235
|
+
}
|
|
35236
|
+
const requestImg = await encryptImageBase64(ocrOriginImg);
|
|
35201
35237
|
const report = await _this.mrzService.getReport();
|
|
35202
35238
|
await SendRequestWithRetry$1(async function () {
|
|
35203
35239
|
const postData = {
|
|
@@ -35210,7 +35246,7 @@ class MRZModule {
|
|
|
35210
35246
|
}
|
|
35211
35247
|
};
|
|
35212
35248
|
if (shouldEncrypt) {
|
|
35213
|
-
postData.image = await blobToBase64(
|
|
35249
|
+
postData.image = await blobToBase64(ocrOriginImg);
|
|
35214
35250
|
return idRecognition.uploadFrameBase64({
|
|
35215
35251
|
id: scanId,
|
|
35216
35252
|
encryptedBase64String: await encryptDataBase64(postData)
|
|
@@ -35638,7 +35674,8 @@ class OCRModule {
|
|
|
35638
35674
|
const docInfos = {};
|
|
35639
35675
|
const encryptImageBase64 = async function encryptImageBase64(blob) {
|
|
35640
35676
|
const imageArrayBuffer = await blobToArrayBuffer(blob);
|
|
35641
|
-
const
|
|
35677
|
+
const uint8Array = new Uint8Array(imageArrayBuffer);
|
|
35678
|
+
const resultEncrypt = await _this.ocrService.encryptBlob(uint8Array, pubKey);
|
|
35642
35679
|
return resultEncrypt;
|
|
35643
35680
|
};
|
|
35644
35681
|
const blobToArrayBuffer = async function blobToArrayBuffer(blob) {
|
|
@@ -35775,6 +35812,9 @@ class OCRModule {
|
|
|
35775
35812
|
_this.engine.setPublicKeyForJson('');
|
|
35776
35813
|
}
|
|
35777
35814
|
if (config.type === idRecognition.IdRecognitionCardType.IDCard && config.needAntiFraud) {
|
|
35815
|
+
if (!resp.parameters.fraud) {
|
|
35816
|
+
throw new core.AuthmeError(core.ErrorCode.ANTI_FRAUD_INIT_ERROR, 'Anti-fraud feature is not enabled on the server');
|
|
35817
|
+
}
|
|
35778
35818
|
// 先設定 stage 再 init,避免使用預設的 Frontal stage
|
|
35779
35819
|
await _this.antiFraudInstance.setStage(antiFraudStageList);
|
|
35780
35820
|
await _this.antiFraudInstance.init();
|
|
@@ -36841,7 +36881,6 @@ class OCRModule {
|
|
|
36841
36881
|
throw new core.AuthmeError(core.ErrorCode.EVENT_NAME_WRONG);
|
|
36842
36882
|
}))).pipe(rxjs.tap(downloadDebugLogs)));
|
|
36843
36883
|
} catch (error) {
|
|
36844
|
-
console.error(error);
|
|
36845
36884
|
const catchedError = error instanceof core.AuthmeError ? error : new core.AuthmeError(core.ErrorCode.SDK_INTERNAL_ERROR, error);
|
|
36846
36885
|
downloadDebugLogs();
|
|
36847
36886
|
return {
|
|
@@ -37322,7 +37361,7 @@ class AuthmeIdentityVerification extends engine.AuthmeFunctionModule {
|
|
|
37322
37361
|
}
|
|
37323
37362
|
|
|
37324
37363
|
var name = "authme/sdk";
|
|
37325
|
-
var version$1 = "2.8.
|
|
37364
|
+
var version$1 = "2.8.55";
|
|
37326
37365
|
var packageInfo = {
|
|
37327
37366
|
name: name,
|
|
37328
37367
|
version: version$1};
|
package/index.esm.js
CHANGED
|
@@ -29330,7 +29330,7 @@ const modal = arg => {
|
|
|
29330
29330
|
domTitle.innerText = arg.title;
|
|
29331
29331
|
domSubtitle.innerText = arg.subtitle;
|
|
29332
29332
|
domImage.src = arg.image;
|
|
29333
|
-
domContent.
|
|
29333
|
+
domContent.textContent = arg.content;
|
|
29334
29334
|
domClose.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.1943 6.41714C19.6393 5.97216 19.6393 5.2507 19.1943 4.80571C18.7493 4.36073 18.0278 4.36073 17.5829 4.80571L12 10.3886L6.41714 4.80572C5.97216 4.36073 5.2507 4.36073 4.80571 4.80571C4.36073 5.2507 4.36073 5.97216 4.80571 6.41714L10.3886 12L4.80571 17.5829C4.36073 18.0278 4.36073 18.7493 4.80571 19.1943C5.2507 19.6393 5.97216 19.6393 6.41714 19.1943L12 13.6114L17.5829 19.1943C18.0278 19.6393 18.7493 19.6393 19.1943 19.1943C19.6393 18.7493 19.6393 18.0278 19.1943 17.5829L13.6114 12L19.1943 6.41714Z" fill="${uiThemeConfig.nonEkycCloseButton.contentColor}" fill-opacity="${uiThemeConfig.nonEkycCloseButton.contentOpacity}" /></svg>`;
|
|
29335
29335
|
domConfirm.innerText = arg.confirm;
|
|
29336
29336
|
domClose.addEventListener('click', async () => {
|
|
@@ -31559,7 +31559,7 @@ const toast = arg => {
|
|
|
31559
31559
|
} else {
|
|
31560
31560
|
toast.style.opacity = '1';
|
|
31561
31561
|
}
|
|
31562
|
-
toast.
|
|
31562
|
+
toast.textContent = message;
|
|
31563
31563
|
document.body.appendChild(toast);
|
|
31564
31564
|
timer = setTimeout(() => {
|
|
31565
31565
|
clearStatus = true;
|
|
@@ -31808,7 +31808,7 @@ const popupView = arg => {
|
|
|
31808
31808
|
}
|
|
31809
31809
|
if (arg.cancel) {
|
|
31810
31810
|
uiThemeSmallButton(domCancel, uiThemeConfig.smallerMinorButton);
|
|
31811
|
-
domCancel.
|
|
31811
|
+
domCancel.textContent = arg.cancel;
|
|
31812
31812
|
domCancel.addEventListener('click', async () => {
|
|
31813
31813
|
if (arg.onCancel) {
|
|
31814
31814
|
arg.onCancel();
|
|
@@ -31822,9 +31822,9 @@ const popupView = arg => {
|
|
|
31822
31822
|
}
|
|
31823
31823
|
removePopview();
|
|
31824
31824
|
});
|
|
31825
|
-
domTitle.
|
|
31826
|
-
domContent.
|
|
31827
|
-
domConfirm.
|
|
31825
|
+
domTitle.textContent = arg.title;
|
|
31826
|
+
domContent.textContent = arg.content;
|
|
31827
|
+
domConfirm.textContent = arg.confirm;
|
|
31828
31828
|
domPopupViewContainer.appendChild(domTitleContainer);
|
|
31829
31829
|
domTitleContainer.appendChild(domTitle);
|
|
31830
31830
|
domPopupViewContainer.appendChild(domContentContainer);
|
|
@@ -34996,12 +34996,14 @@ class MRZModule {
|
|
|
34996
34996
|
let uploadFullFrame = false;
|
|
34997
34997
|
let pubKey = '';
|
|
34998
34998
|
let latestTField = null;
|
|
34999
|
+
let currentCardType = null;
|
|
34999
35000
|
const virtualCanvas = document.createElement('canvas');
|
|
35000
35001
|
const docInfos = {};
|
|
35001
35002
|
let shouldEncrypt = false;
|
|
35002
35003
|
const encryptImageBase64 = async function encryptImageBase64(blob) {
|
|
35003
35004
|
const imageArrayBuffer = await blobToArrayBuffer(blob);
|
|
35004
|
-
const
|
|
35005
|
+
const uint8Array = new Uint8Array(imageArrayBuffer);
|
|
35006
|
+
const resultEncrypt = await _this.mrzService.encryptBlob(uint8Array, pubKey);
|
|
35005
35007
|
return resultEncrypt;
|
|
35006
35008
|
};
|
|
35007
35009
|
const blobToArrayBuffer = async function blobToArrayBuffer(blob) {
|
|
@@ -35038,6 +35040,8 @@ class MRZModule {
|
|
|
35038
35040
|
frameHeight = height;
|
|
35039
35041
|
const resp = await SendRequestWithRetry$1(() => initScan(config.type, config.country, config.needConfirm, config.cardTypes));
|
|
35040
35042
|
shouldEncrypt = (_resp$shouldEncrypt = resp.shouldEncrypt) != null ? _resp$shouldEncrypt : shouldEncrypt;
|
|
35043
|
+
Storage.setItem('shouldEncrypt', shouldEncrypt);
|
|
35044
|
+
Storage.setItem('encryptDataBase64', encryptDataBase64);
|
|
35041
35045
|
pubKey = resp.parameters.pubKey;
|
|
35042
35046
|
scanId = resp.scanId;
|
|
35043
35047
|
uploadFullFrame = (_resp$parameters$frau = (_resp$parameters$frau2 = resp.parameters.fraud) == null ? void 0 : _resp$parameters$frau2.collectAllFrames) != null ? _resp$parameters$frau : config.uploadFullFrame;
|
|
@@ -35057,9 +35061,15 @@ class MRZModule {
|
|
|
35057
35061
|
});
|
|
35058
35062
|
},
|
|
35059
35063
|
ocrStart: async function (points, type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, faceMode, cardType, retry = false) {
|
|
35064
|
+
currentCardType = type;
|
|
35060
35065
|
await _this.mrzService.init();
|
|
35061
35066
|
await _this.mrzService.setFrameSize(frameWidth, frameHeight);
|
|
35062
35067
|
await _this.mrzService.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
|
|
35068
|
+
const oldParams = await _this.mrzService.getParams();
|
|
35069
|
+
await _this.mrzService.setParams(Object.assign({}, oldParams, {
|
|
35070
|
+
fImageBlurTh: 750,
|
|
35071
|
+
fCardMatchTh: 0.3
|
|
35072
|
+
}));
|
|
35063
35073
|
await _this.mrzService.startSession();
|
|
35064
35074
|
if (retry) {
|
|
35065
35075
|
docInfos[type].ocrImg = null;
|
|
@@ -35098,6 +35108,7 @@ class MRZModule {
|
|
|
35098
35108
|
},
|
|
35099
35109
|
acceptTypes,
|
|
35100
35110
|
recognition: async function (data) {
|
|
35111
|
+
var _docInfos$currentCard;
|
|
35101
35112
|
const mrzResult = await _this.mrzService.recognition(data);
|
|
35102
35113
|
if (_this.canvas) {
|
|
35103
35114
|
var _this$mrzService;
|
|
@@ -35112,8 +35123,28 @@ class MRZModule {
|
|
|
35112
35123
|
imgData.data.set(debugData);
|
|
35113
35124
|
ctx.putImageData(imgData, 0, 0);
|
|
35114
35125
|
}
|
|
35115
|
-
if (mrzResult.eStatus === EAuthMeMRZServiceStatus.Success
|
|
35116
|
-
|
|
35126
|
+
if (mrzResult.eStatus === EAuthMeMRZServiceStatus.Success) {
|
|
35127
|
+
const cardType = currentCardType;
|
|
35128
|
+
const ocrOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
35129
|
+
// V9: 如果有卡片圖像就使用它,否則使用原始幀圖像
|
|
35130
|
+
let resultOcrImg;
|
|
35131
|
+
if (mrzResult.imageData && mrzResult.iWidth > 0 && mrzResult.iHeight > 0) {
|
|
35132
|
+
resultOcrImg = UintArrayToBlob(mrzResult.iWidth, mrzResult.iHeight, mrzResult.imageData, virtualCanvas);
|
|
35133
|
+
} else {
|
|
35134
|
+
resultOcrImg = ocrOriginImg;
|
|
35135
|
+
}
|
|
35136
|
+
// 存圖不等 docId — 避免競態條件導致圖片遺失
|
|
35137
|
+
if (!docInfos[cardType]) {
|
|
35138
|
+
docInfos[cardType] = {
|
|
35139
|
+
docId: '',
|
|
35140
|
+
ocrImg: null,
|
|
35141
|
+
ocrOriginImg: null,
|
|
35142
|
+
fraudOriginImg: null,
|
|
35143
|
+
fraudResult: null
|
|
35144
|
+
};
|
|
35145
|
+
}
|
|
35146
|
+
docInfos[cardType].ocrImg = resultOcrImg;
|
|
35147
|
+
docInfos[cardType].ocrOriginImg = ocrOriginImg;
|
|
35117
35148
|
await _this.mrzService.stop();
|
|
35118
35149
|
// 1. 最後結果統一使用 getFinalResult 取得的結果。
|
|
35119
35150
|
// 2. 由於 engine-lib 限制,getFinalResult 必須要在 stop 之後呼叫。
|
|
@@ -35157,13 +35188,13 @@ class MRZModule {
|
|
|
35157
35188
|
}
|
|
35158
35189
|
}
|
|
35159
35190
|
}
|
|
35160
|
-
} else if (uploadFullFrame) {
|
|
35191
|
+
} else if (uploadFullFrame && currentCardType && (_docInfos$currentCard = docInfos[currentCardType]) != null && _docInfos$currentCard.docId) {
|
|
35161
35192
|
const image = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
|
|
35162
35193
|
const requestImg = await encryptImageBase64(image);
|
|
35163
|
-
|
|
35194
|
+
const uploadCardType = currentCardType;
|
|
35164
35195
|
backgroundRequest(async function () {
|
|
35165
35196
|
const postData = {
|
|
35166
|
-
scanDocumentId: docInfos[
|
|
35197
|
+
scanDocumentId: docInfos[uploadCardType].docId,
|
|
35167
35198
|
image: requestImg,
|
|
35168
35199
|
type: ResourceImageType.Recognition,
|
|
35169
35200
|
info: {
|
|
@@ -35192,10 +35223,15 @@ class MRZModule {
|
|
|
35192
35223
|
}
|
|
35193
35224
|
},
|
|
35194
35225
|
confirmImage: async function (option) {
|
|
35195
|
-
|
|
35226
|
+
var _docInfos$option$type;
|
|
35227
|
+
const docId = (_docInfos$option$type = docInfos[option.type]) == null ? void 0 : _docInfos$option$type.docId;
|
|
35196
35228
|
if (docId) {
|
|
35197
35229
|
docInfos[option.type].docId = '';
|
|
35198
|
-
const
|
|
35230
|
+
const ocrOriginImg = docInfos[option.type].ocrOriginImg;
|
|
35231
|
+
if (!ocrOriginImg) {
|
|
35232
|
+
throw new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, 'MRZ card image not available for upload');
|
|
35233
|
+
}
|
|
35234
|
+
const requestImg = await encryptImageBase64(ocrOriginImg);
|
|
35199
35235
|
const report = await _this.mrzService.getReport();
|
|
35200
35236
|
await SendRequestWithRetry$1(async function () {
|
|
35201
35237
|
const postData = {
|
|
@@ -35208,7 +35244,7 @@ class MRZModule {
|
|
|
35208
35244
|
}
|
|
35209
35245
|
};
|
|
35210
35246
|
if (shouldEncrypt) {
|
|
35211
|
-
postData.image = await blobToBase64(
|
|
35247
|
+
postData.image = await blobToBase64(ocrOriginImg);
|
|
35212
35248
|
return uploadFrameBase64({
|
|
35213
35249
|
id: scanId,
|
|
35214
35250
|
encryptedBase64String: await encryptDataBase64(postData)
|
|
@@ -35636,7 +35672,8 @@ class OCRModule {
|
|
|
35636
35672
|
const docInfos = {};
|
|
35637
35673
|
const encryptImageBase64 = async function encryptImageBase64(blob) {
|
|
35638
35674
|
const imageArrayBuffer = await blobToArrayBuffer(blob);
|
|
35639
|
-
const
|
|
35675
|
+
const uint8Array = new Uint8Array(imageArrayBuffer);
|
|
35676
|
+
const resultEncrypt = await _this.ocrService.encryptBlob(uint8Array, pubKey);
|
|
35640
35677
|
return resultEncrypt;
|
|
35641
35678
|
};
|
|
35642
35679
|
const blobToArrayBuffer = async function blobToArrayBuffer(blob) {
|
|
@@ -35773,6 +35810,9 @@ class OCRModule {
|
|
|
35773
35810
|
_this.engine.setPublicKeyForJson('');
|
|
35774
35811
|
}
|
|
35775
35812
|
if (config.type === IdRecognitionCardType.IDCard && config.needAntiFraud) {
|
|
35813
|
+
if (!resp.parameters.fraud) {
|
|
35814
|
+
throw new AuthmeError(ErrorCode.ANTI_FRAUD_INIT_ERROR, 'Anti-fraud feature is not enabled on the server');
|
|
35815
|
+
}
|
|
35776
35816
|
// 先設定 stage 再 init,避免使用預設的 Frontal stage
|
|
35777
35817
|
await _this.antiFraudInstance.setStage(antiFraudStageList);
|
|
35778
35818
|
await _this.antiFraudInstance.init();
|
|
@@ -36839,7 +36879,6 @@ class OCRModule {
|
|
|
36839
36879
|
throw new AuthmeError(ErrorCode.EVENT_NAME_WRONG);
|
|
36840
36880
|
}))).pipe(tap(downloadDebugLogs)));
|
|
36841
36881
|
} catch (error) {
|
|
36842
|
-
console.error(error);
|
|
36843
36882
|
const catchedError = error instanceof AuthmeError ? error : new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, error);
|
|
36844
36883
|
downloadDebugLogs();
|
|
36845
36884
|
return {
|
|
@@ -37320,7 +37359,7 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
|
|
|
37320
37359
|
}
|
|
37321
37360
|
|
|
37322
37361
|
var name = "authme/sdk";
|
|
37323
|
-
var version$1 = "2.8.
|
|
37362
|
+
var version$1 = "2.8.55";
|
|
37324
37363
|
var packageInfo = {
|
|
37325
37364
|
name: name,
|
|
37326
37365
|
version: version$1};
|