Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_38335589
uni-app
提交
f37fb69c
U
uni-app
项目概览
weixin_38335589
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f37fb69c
编写于
11月 06, 2019
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(v3): 生物认证
上级
9db2ab6b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
230 addition
and
1 deletion
+230
-1
lib/apis.js
lib/apis.js
+4
-1
src/platforms/app-plus/service/api/device/soter-authentication.js
...forms/app-plus/service/api/device/soter-authentication.js
+225
-0
src/platforms/app-plus/service/api/index.js
src/platforms/app-plus/service/api/index.js
+1
-0
未找到文件。
lib/apis.js
浏览文件 @
f37fb69c
...
...
@@ -111,7 +111,10 @@ const device = [
'
onBeaconUpdate
'
,
'
getBeacons
'
,
'
startBeaconDiscovery
'
,
'
stopBeaconDiscovery
'
'
stopBeaconDiscovery
'
,
'
checkIsSupportSoterAuthentication
'
,
'
checkIsSoterEnrolledInDevice
'
,
'
startSoterAuthentication
'
]
const
keyboard
=
[
...
...
src/platforms/app-plus/service/api/device/soter-authentication.js
0 → 100644
浏览文件 @
f37fb69c
import
{
invoke
,
requireNativePlugin
}
from
'
../../bridge
'
function
checkIsSupportFaceID
()
{
const
platform
=
plus
.
os
.
name
.
toLowerCase
()
if
(
platform
!==
'
ios
'
)
{
return
false
}
const
faceID
=
requireNativePlugin
(
'
faceID
'
)
return
!!
(
faceID
&&
faceID
.
isSupport
())
}
function
checkIsSupportFingerPrint
()
{
return
!!
(
plus
.
fingerprint
&&
plus
.
fingerprint
.
isSupport
())
}
export
function
checkIsSupportSoterAuthentication
()
{
let
supportMode
=
[]
if
(
checkIsSupportFingerPrint
())
{
supportMode
.
push
(
'
fingerPrint
'
)
}
if
(
checkIsSupportFaceID
())
{
supportMode
.
push
(
'
facial
'
)
}
return
{
supportMode
,
errMsg
:
'
checkIsSupportSoterAuthentication:ok
'
}
}
export
function
checkIsSoterEnrolledInDevice
({
checkAuthMode
}
=
{})
{
if
(
checkAuthMode
===
'
fingerPrint
'
)
{
if
(
checkIsSupportFingerPrint
())
{
const
isEnrolled
=
plus
.
fingerprint
.
isKeyguardSecure
()
&&
plus
.
fingerprint
.
isEnrolledFingerprints
()
if
(
isEnrolled
)
{
return
{
isEnrolled
,
errMsg
:
'
checkIsSoterEnrolledInDevice:ok
'
}
}
else
{
return
{
isEnrolled
,
errMsg
:
'
checkIsSoterEnrolledInDevice:ok
'
}
}
}
else
{
return
{
isEnrolled
:
false
,
errMsg
:
'
checkIsSoterEnrolledInDevice:fail not support
'
}
}
}
else
if
(
checkAuthMode
===
'
facial
'
)
{
if
(
checkIsSupportFaceID
())
{
const
faceID
=
requireNativePlugin
(
'
faceID
'
)
const
isEnrolled
=
faceID
&&
faceID
.
isKeyguardSecure
()
&&
faceID
.
isEnrolledFaceID
()
if
(
isEnrolled
)
{
return
{
isEnrolled
,
errMsg
:
'
checkIsSoterEnrolledInDevice:ok
'
}
}
else
{
return
{
isEnrolled
,
errMsg
:
'
checkIsSoterEnrolledInDevice:ok
'
}
}
}
else
{
return
{
isEnrolled
:
false
,
errMsg
:
'
checkIsSoterEnrolledInDevice:fail not support
'
}
}
}
else
{
return
{
isEnrolled
:
false
,
errMsg
:
'
checkIsSoterEnrolledInDevice:fail not support
'
}
}
}
export
function
startSoterAuthentication
({
requestAuthModes
,
challenge
=
false
,
authContent
}
=
{},
callbackId
)
{
const
supportMode
=
checkIsSupportSoterAuthentication
().
supportMode
if
(
supportMode
.
length
===
0
)
{
return
{
authMode
:
supportMode
[
0
]
||
'
fingerPrint
'
,
errCode
:
90001
,
errMsg
:
'
startSoterAuthentication:fail
'
}
}
let
supportRequestAuthMode
=
[]
requestAuthModes
.
map
((
item
,
index
)
=>
{
if
(
supportMode
.
indexOf
(
item
)
>
-
1
)
{
supportRequestAuthMode
.
push
(
item
)
}
})
if
(
supportRequestAuthMode
.
length
===
0
)
{
return
{
authMode
:
supportRequestAuthMode
[
0
]
||
'
fingerPrint
'
,
errCode
:
90003
,
errMsg
:
'
startSoterAuthentication:fail no corresponding mode
'
}
}
let
enrolledRequestAuthMode
=
[]
supportRequestAuthMode
.
map
((
item
,
index
)
=>
{
const
checked
=
checkIsSoterEnrolledInDevice
({
checkAuthMode
:
item
}).
isEnrolled
if
(
checked
)
{
enrolledRequestAuthMode
.
push
(
item
)
}
})
if
(
enrolledRequestAuthMode
.
length
===
0
)
{
return
{
authMode
:
supportRequestAuthMode
[
0
],
errCode
:
90011
,
errMsg
:
`startSoterAuthentication:fail no
${
supportRequestAuthMode
[
0
]}
enrolled`
}
}
const
realAuthMode
=
enrolledRequestAuthMode
[
0
]
if
(
realAuthMode
===
'
fingerPrint
'
)
{
if
(
plus
.
os
.
name
.
toLowerCase
()
===
'
android
'
)
{
plus
.
nativeUI
.
showWaiting
(
authContent
||
'
指纹识别中...
'
).
onclose
=
function
()
{
plus
.
fingerprint
.
cancel
()
}
}
plus
.
fingerprint
.
authenticate
(()
=>
{
plus
.
nativeUI
.
closeWaiting
()
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
0
,
errMsg
:
'
startSoterAuthentication:ok
'
})
},
(
e
)
=>
{
switch
(
e
.
code
)
{
case
e
.
AUTHENTICATE_MISMATCH
:
// 微信小程序没有这个回调,如果要实现此处回调需要多次触发需要用事件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
()
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90010
,
errMsg
:
'
startSoterAuthentication:fail authenticate freeze. please try again later
'
})
break
case
e
.
CANCEL
:
plus
.
nativeUI
.
closeWaiting
()
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90008
,
errMsg
:
'
startSoterAuthentication:fail cancel
'
})
break
default
:
plus
.
nativeUI
.
closeWaiting
()
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90007
,
errMsg
:
'
startSoterAuthentication:fail
'
})
break
}
},
{
message
:
authContent
})
}
else
if
(
realAuthMode
===
'
facial
'
)
{
const
faceID
=
requireNativePlugin
(
'
faceID
'
)
faceID
.
authenticate
({
message
:
authContent
},
(
e
)
=>
{
if
(
e
.
type
===
'
success
'
&&
e
.
code
===
1
)
{
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
0
,
errMsg
:
'
startSoterAuthentication:ok
'
})
}
else
{
switch
(
e
.
code
)
{
case
4
:
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90009
,
errMsg
:
'
startSoterAuthentication:fail
'
})
break
case
5
:
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90010
,
errMsg
:
'
startSoterAuthentication:fail authenticate freeze. please try again later
'
})
break
case
6
:
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90008
,
errMsg
:
'
startSoterAuthentication:fail cancel
'
})
break
default
:
invoke
(
callbackId
,
{
authMode
:
realAuthMode
,
errCode
:
90007
,
errMsg
:
'
startSoterAuthentication:fail
'
})
break
}
}
})
}
}
src/platforms/app-plus/service/api/index.js
浏览文件 @
f37fb69c
...
...
@@ -15,6 +15,7 @@ export * from './device/get-network-type'
export
*
from
'
./device/ibeacon
'
export
*
from
'
./device/make-phone-call
'
export
*
from
'
./device/scan-code
'
export
*
from
'
./device/soter-authentication
'
export
*
from
'
./device/system
'
export
*
from
'
./device/vibrate
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录