提交 73382263 编写于 作者: fxy060608's avatar fxy060608

chore: build

上级 71303a99
......@@ -11533,7 +11533,7 @@ const API_GET_SCREEN_BRIGHTNESS = 'getScreenBrightness';
const API_SET_SCREEN_BRIGHTNESS = 'setScreenBrightness';
const API_SET_KEEP_SCREEN_ON = 'setKeepScreenOn';
const API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION = 'soterAuthentication';
const API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION = 'checkIsSupportSoterAuthentication';
const API_CHECK_IS_SOTER_ENROLLED_IN_DEVICE = 'checkIsSoterEnrolledInDevice';
const CheckAuthModes = [
'fingerPrint',
......@@ -11551,7 +11551,7 @@ const CheckIsSoterEnrolledInDeviceOptions = {
const CheckIsSoterEnrolledInDeviceProtocols = {
checkAuthMode: String,
};
const API_START_SOTER_AUTHENTICATION = 'checkIsSoterEnrolledInDevice';
const API_START_SOTER_AUTHENTICATION = 'startSoterAuthentication';
const StartSoterAuthenticationOptions = {
formatArgs: {
requestAuthModes(value, params) {
......@@ -14141,29 +14141,27 @@ const startSoterAuthentication = defineAsyncApi(API_START_SOTER_AUTHENTICATION,
*/
initI18nStartSoterAuthenticationMsgsOnce();
const { t } = useI18n();
const supportMode = baseCheckIsSupportSoterAuthentication().supportMode;
if (supportMode.length === 0) {
return {
const { supportMode } = baseCheckIsSupportSoterAuthentication();
if (!supportMode.length) {
return reject('not support', {
authMode: 'fingerPrint',
errCode: 90001,
errMsg: 'startSoterAuthentication:fail',
};
});
}
const supportRequestAuthMode = [];
requestAuthModes.map((item, index) => {
requestAuthModes.forEach((item) => {
if (supportMode.indexOf(item) > -1) {
supportRequestAuthMode.push(item);
}
});
if (supportRequestAuthMode.length === 0) {
return {
if (!supportRequestAuthMode.length) {
return reject('startSoterAuthentication:fail no corresponding mode', {
authMode: 'fingerPrint',
errCode: 90003,
errMsg: 'startSoterAuthentication:fail no corresponding mode',
};
});
}
const enrolledRequestAuthMode = [];
supportRequestAuthMode.map((item, index) => {
supportRequestAuthMode.forEach((item) => {
const checked = basecheckIsSoterEnrolledInDevice({
checkAuthMode: item,
}).isEnrolled;
......@@ -14171,20 +14169,69 @@ const startSoterAuthentication = defineAsyncApi(API_START_SOTER_AUTHENTICATION,
enrolledRequestAuthMode.push(item);
}
});
if (enrolledRequestAuthMode.length === 0) {
return {
if (!enrolledRequestAuthMode.length) {
return reject(`startSoterAuthentication:fail no ${supportRequestAuthMode[0]} enrolled`, {
authMode: supportRequestAuthMode[0],
errCode: 90011,
errMsg: `startSoterAuthentication:fail no ${supportRequestAuthMode[0]} enrolled`,
};
});
}
const realAuthMode = enrolledRequestAuthMode[0];
let waiting = null;
let waitingTimer;
const authenticateMessage = authContent || t('uni.startSoterAuthentication.authContent');
const errorCB = (err) => {
const { code } = err;
const res = {
authMode: realAuthMode,
};
const handler = {
// AUTHENTICATE_MISMATCH
4: () => {
if (waiting) {
clearTimeout(waitingTimer);
waiting.setTitle('无法识别');
waitingTimer = setTimeout(() => {
waiting && waiting.setTitle(authenticateMessage);
}, 1000);
}
else {
reject('', extend(res, {
errCode: 90009,
}));
}
},
// AUTHENTICATE_OVERLIMIT
5: () => {
// 微信小程序在第一次重试次数超限时安卓IOS返回不一致
// 安卓端会返回次数超过限制(errCode: 90010)
// IOS端会返回认证失败(errCode: 90009)
// APP-IOS实际运行时不会次数超限,超过指定次数之后会弹出输入密码的界面
plus.nativeUI.closeWaiting();
reject('authenticate freeze. please try again later', extend(res, {
errCode: 90010,
}));
},
// CANCEL
6: () => {
plus.nativeUI.closeWaiting();
reject('cancel', extend(res, {
errCode: 90008,
}));
},
};
if (code && handler[code]) {
handler[code]();
}
else {
plus.nativeUI.closeWaiting();
reject('', extend(res, {
errCode: 90007,
}));
}
};
if (realAuthMode === 'fingerPrint') {
let waiting = null;
let waitingTimer;
const waitingTitle = authContent || t('uni.startSoterAuthentication.authContent');
if (plus.os.name.toLowerCase() === 'android') {
waiting = plus.nativeUI.showWaiting(waitingTitle);
waiting = plus.nativeUI.showWaiting(authenticateMessage);
waiting.onclose = function () {
plus.fingerprint.cancel();
};
......@@ -14195,58 +14242,15 @@ const startSoterAuthentication = defineAsyncApi(API_START_SOTER_AUTHENTICATION,
authMode: realAuthMode,
errCode: 0,
});
}, (e) => {
const res = {
authMode: realAuthMode,
};
switch (e.code) {
case e.AUTHENTICATE_MISMATCH:
if (waiting) {
clearTimeout(waitingTimer);
waiting.setTitle('无法识别');
waitingTimer = setTimeout(() => {
waiting && waiting.setTitle(waitingTitle);
}, 1000);
}
// 微信小程序没有这个回调,如果要实现此处回调需要多次触发需要用事件publish实现
// invoke(callbackId, {
// authMode: realAuthMode,
// errCode: 90009,
// errMsg: 'startSoterAuthentication:fail'
// })
break;
case e.AUTHENTICATE_OVERLIMIT:
// 微信小程序在第一次重试次数超限时安卓IOS返回不一致,安卓端会返回次数超过限制(errCode: 90010),IOS端会返回认证失败(errCode: 90009)。APP-IOS实际运行时不会次数超限,超过指定次数之后会弹出输入密码的界面
plus.nativeUI.closeWaiting();
reject('authenticate freeze. please try again later', extend(res, {
errCode: 90010,
}));
break;
case e.CANCEL:
plus.nativeUI.closeWaiting();
reject('cancel', extend(res, {
errCode: 90008,
}));
break;
default:
plus.nativeUI.closeWaiting();
reject('', extend(res, {
errCode: 90007,
}));
break;
}
}, {
message: authContent,
}, errorCB, {
message: authenticateMessage,
});
}
else if (realAuthMode === 'facial') {
const faceID = requireNativePlugin('faceID');
faceID.authenticate({
message: authContent,
message: authenticateMessage,
}, (e) => {
const res = {
authMode: realAuthMode,
};
if (e.type === 'success' && e.code === 0) {
resolve({
authMode: realAuthMode,
......@@ -14254,28 +14258,7 @@ const startSoterAuthentication = defineAsyncApi(API_START_SOTER_AUTHENTICATION,
});
}
else {
switch (e.code) {
case 4:
reject('', extend(res, {
errCode: 90009,
}));
break;
case 5:
reject('authenticate freeze. please try again later', extend(res, {
errCode: 90010,
}));
break;
case 6:
reject('', extend(res, {
errCode: 90008,
}));
break;
default:
reject('', extend(res, {
errCode: 90007,
}));
break;
}
errorCB(e);
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册