Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
8e4e385a
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8e4e385a
编写于
11月 18, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(app): startSoterAuthentication
上级
325d8b20
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
114 deletion
+99
-114
packages/uni-api/src/protocols/device/soterAuthentication.ts
packages/uni-api/src/protocols/device/soterAuthentication.ts
+3
-2
packages/uni-app-plus/src/service/api/device/soterAuthentication.ts
...ni-app-plus/src/service/api/device/soterAuthentication.ts
+96
-112
未找到文件。
packages/uni-api/src/protocols/device/soterAuthentication.ts
浏览文件 @
8e4e385a
export
const
API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION
=
'
soterAuthentication
'
export
const
API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION
=
'
checkIsSupportSoterAuthentication
'
export
type
API_TYPE_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION
=
typeof
uni
.
checkIsSupportSoterAuthentication
...
...
@@ -27,7 +28,7 @@ export const CheckIsSoterEnrolledInDeviceProtocols: ApiProtocol<API_TYPE_CHECK_I
checkAuthMode
:
String
as
any
,
}
export
const
API_START_SOTER_AUTHENTICATION
=
'
checkIsSoterEnrolledInDevice
'
export
const
API_START_SOTER_AUTHENTICATION
=
'
startSoterAuthentication
'
export
type
API_TYPE_START_SOTER_AUTHENTICATION
=
typeof
uni
.
startSoterAuthentication
export
const
StartSoterAuthenticationOptions
:
ApiOptions
<
API_TYPE_START_SOTER_AUTHENTICATION
>
=
...
...
packages/uni-app-plus/src/service/api/device/soterAuthentication.ts
浏览文件 @
8e4e385a
...
...
@@ -148,29 +148,30 @@ export const startSoterAuthentication =
*/
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
:
UniApp
.
SoterAuthModes
[]
=
[]
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
:
UniApp
.
SoterAuthModes
[]
=
[]
supportRequestAuthMode
.
map
((
item
,
index
)
=>
{
supportRequestAuthMode
.
forEach
((
item
)
=>
{
const
checked
=
basecheckIsSoterEnrolledInDevice
({
checkAuthMode
:
item
,
}).
isEnrolled
...
...
@@ -178,21 +179,89 @@ export const startSoterAuthentication =
enrolledRequestAuthMode
.
push
(
item
)
}
})
if
(
enrolledRequestAuthMode
.
length
===
0
)
{
return
{
authMode
:
supportRequestAuthMode
[
0
],
errCode
:
90011
,
errMsg
:
`startSoterAuthentication:fail no
${
supportRequestAuthMode
[
0
]}
enrolled`
,
}
if
(
!
enrolledRequestAuthMode
.
length
)
{
return
reject
(
`startSoterAuthentication:fail no
${
supportRequestAuthMode
[
0
]}
enrolled`
,
{
authMode
:
supportRequestAuthMode
[
0
],
errCode
:
90011
,
}
)
}
const
realAuthMode
=
enrolledRequestAuthMode
[
0
]
let
waiting
:
PlusNativeUIWaitingObj
|
null
=
null
let
waitingTimer
:
ReturnType
<
typeof
setTimeout
>
const
authenticateMessage
=
authContent
||
t
(
'
uni.startSoterAuthentication.authContent
'
)
const
errorCB
=
(
err
:
PlusFingerprintFingerprintError
)
=>
{
const
{
code
}
=
err
const
res
=
{
authMode
:
realAuthMode
,
}
const
handler
:
Record
<
number
,
Function
>
=
{
// 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
:
PlusNativeUIWaitingObj
|
null
=
null
let
waitingTimer
:
ReturnType
<
typeof
setTimeout
>
const
waitingTitle
=
authContent
||
t
(
'
uni.startSoterAuthentication.authContent
'
)
if
(
plus
.
os
.
name
!
.
toLowerCase
()
===
'
android
'
)
{
waiting
=
plus
.
nativeUI
.
showWaiting
(
waitingTitl
e
)
waiting
=
plus
.
nativeUI
.
showWaiting
(
authenticateMessag
e
)
waiting
.
onclose
=
function
()
{
plus
.
fingerprint
.
cancel
()
}
...
...
@@ -205,110 +274,25 @@ export const startSoterAuthentication =
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
}
},
errorCB
,
{
message
:
auth
Content
,
message
:
auth
enticateMessage
,
}
)
}
else
if
(
realAuthMode
===
'
facial
'
)
{
const
faceID
=
requireNativePlugin
(
'
faceID
'
)
faceID
.
authenticate
(
{
message
:
auth
Content
,
message
:
auth
enticateMessage
,
},
(
e
:
Data
)
=>
{
const
res
=
{
authMode
:
realAuthMode
,
}
(
e
:
PlusFingerprintFingerprintError
&
{
type
:
string
})
=>
{
if
(
e
.
type
===
'
success
'
&&
e
.
code
===
0
)
{
resolve
({
authMode
:
realAuthMode
,
errCode
:
0
,
})
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录