Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
25185e0e
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
25185e0e
编写于
10月 08, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
!9873 更新userAuth和faceAuth的文档资料
Merge pull request !9873 from youliang_1314/master
上级
e32c25ab
ff308a39
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
499 addition
and
39 deletion
+499
-39
zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md
...pplication-dev/reference/apis/js-apis-useriam-faceauth.md
+16
-15
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
...pplication-dev/reference/apis/js-apis-useriam-userauth.md
+483
-24
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md
浏览文件 @
25185e0e
...
@@ -37,36 +37,38 @@ constructor()
...
@@ -37,36 +37,38 @@ constructor()
```
js
```
js
import
userIAM_faceAuth
from
'
@ohos.userIAM.faceAuth
'
;
import
userIAM_faceAuth
from
'
@ohos.userIAM.faceAuth
'
;
let
faceAuthManager
=
new
userIAM_faceAuth
.
FaceAuthManager
()
let
faceAuthManager
=
new
userIAM_faceAuth
.
FaceAuthManager
()
;
```
```
### setSurfaceId
### setSurfaceId
setSurfaceId(surfaceId: string):
ResultCode
;
setSurfaceId(surfaceId: string):
void
;
设置录入流程中人脸预览界面
[
XComponent
](
../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid
)
持有 Surface 的 ID
, 返回值表示操作是否成功
。
设置录入流程中人脸预览界面
[
XComponent
](
../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid
)
持有 Surface 的 ID。
**系统能力:**
SystemCapability.UserIAM.UserAuth.FaceAuth
**系统能力:**
SystemCapability.UserIAM.UserAuth.FaceAuth
**需要权限:**
ohos.permission.MANAGE_USER_IDM
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------- | ---- | -------------------------- |
| -------------- | ---------------------------------- | ---- | -------------------------- |
| surfaceId | string | 是 |
[
XComponent
](
../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid
)
持有 Surface 的 ID。 |
| surfaceId | string | 是 |
[
XComponent
](
../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid
)
持有 Surface 的 ID。 |
**返回值:**
| 类型 | 说明 |
| ---------- | ------------------------------------------------------------ |
|
[
ResultCode
](
#resultcode
)
| 表示操作是否成功 |
**示例:**
**示例:**
```
js
```
js
import
userIAM_faceAuth
from
'
@ohos.userIAM.faceAuth
'
;
import
faceAuth
from
'
@ohos.userIAM.faceAuth
'
;
let
faceAuthManager
=
new
userIAM_faceAuth
.
FaceAuthManager
()
let
surfaceId
=
"
123456
"
;
faceAuthManager
.
setSurfaceId
(
"
0
"
);
let
manager
=
new
faceAuth
.
FaceAuthManager
();
try
{
manager
.
setSurfaceId
(
surfaceId
);
console
.
info
(
"
set surface id success
"
);
}
catch
(
e
)
{
console
.
error
(
"
set surface id failed, error =
"
+
e
);
}
```
```
## ResultCode
## ResultCode
...
@@ -77,5 +79,4 @@ setSurfaceId(surfaceId: string): ResultCode;
...
@@ -77,5 +79,4 @@ setSurfaceId(surfaceId: string): ResultCode;
| 名称 | 默认值 | 描述 |
| 名称 | 默认值 | 描述 |
| ----------------------- | ------ | -------------------- |
| ----------------------- | ------ | -------------------- |
| SUCCESS | 0 | 执行成功。 |
| FAIL | 12700001 | 执行失败。 |
| FAIL | 1 | 执行失败。 |
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
浏览文件 @
25185e0e
...
@@ -14,6 +14,71 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth';
...
@@ -14,6 +14,71 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth';
## 完整示例
## 完整示例
```
js
// API version 9
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
export
default
{
getVersion
()
{
try
{
let
version
=
userIAM_userAuth
.
getVersion
();
console
.
info
(
"
auth version =
"
+
version
);
}
catch
(
error
)
{
console
.
info
(
"
get version failed, error =
"
+
error
);
}
},
start
()
{
console
.
info
(
"
start auth
"
);
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
on
(
"
result
"
,
{
callback
:
(
result
:
userIAM_userAuth
.
AuthResultInfo
)
=>
{
console
.
log
(
"
authV9 result
"
+
result
.
result
);
console
.
log
(
"
authV9 token
"
+
result
.
token
);
console
.
log
(
"
authV9 remainAttempts
"
+
result
.
remainAttempts
);
console
.
log
(
"
authV9 lockoutDuration
"
+
result
.
lockoutDuration
);
}
});
auth
.
start
();
console
.
log
(
"
authV9 start success
"
);
}
catch
(
error
)
{
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
}
},
getAvailableStatus
()
{
console
.
info
(
"
start check auth support
"
);
try
{
userIAM_userAuth
.
getAvailableStatus
(
userIAM_userAuth
.
UserAuthType
.
FACE
,
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
);
console
.
info
(
"
current auth trust level is supported
"
);
}
catch
(
error
)
{
console
.
info
(
"
current auth trust level is not supported, error =
"
+
error
);
}
},
cancel
()
{
console
.
info
(
"
start cancel auth
"
);
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
start
();
auth
.
cancel
();
console
.
info
(
"
cancel auth success
"
);
}
catch
(
error
)
{
console
.
info
(
"
cancel auth failed, error =
"
+
error
);
}
}
}
```
```
js
```
js
// API version 8
// API version 8
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
...
@@ -22,13 +87,13 @@ let auth = new userIAM_userAuth.UserAuth();
...
@@ -22,13 +87,13 @@ let auth = new userIAM_userAuth.UserAuth();
export
default
{
export
default
{
getVersion
()
{
getVersion
()
{
console
.
info
(
"
start get version
"
);
console
.
info
(
"
start get version
"
);
let
version
=
this
.
auth
.
getVersion
();
let
version
=
auth
.
getVersion
();
console
.
info
(
"
auth version =
"
+
version
);
console
.
info
(
"
auth version =
"
+
version
);
},
},
startAuth
()
{
startAuth
()
{
console
.
info
(
"
start auth
"
);
console
.
info
(
"
start auth
"
);
this
.
auth
.
auth
(
null
,
userIAM_userAuth
.
UserAuthType
.
FACE
,
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
,
{
auth
.
auth
(
null
,
userIAM_userAuth
.
UserAuthType
.
FACE
,
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
,
extraInfo
)
=>
{
try
{
try
{
console
.
info
(
"
auth onResult result =
"
+
result
);
console
.
info
(
"
auth onResult result =
"
+
result
);
...
@@ -108,15 +173,374 @@ export default {
...
@@ -108,15 +173,374 @@ export default {
}
}
```
```
## EventInfo<sup>9+</sup>
类型别名,用于表示认证事件信息的类型,取值可以为下表中的类型。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
| 类型 | 说明 |
| --------- | ----------------------- |
|
[
AuthResultInfo
](
#authresultinfo9
)
| 认证结果信息 |
|
[
TipInfo
](
#tipinfo9
)
| 认证过程中的提示信息 |
## AuthEvent<sup>9+</sup>
认证事件回调的对象。
### callback<sup>9+</sup>
callback: (result : EventInfo) => void
表示在认证结束后返回结果信息或者在认证操作中返回提示信息。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | -------------------------------------------------------- |
| result |
[
EventInfo
](
#eventinfo9
)
| 是 | 返回的认证结果信息或提示信息。 |
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
on
(
"
result
"
,
{
callback
:
(
result
:
userIAM_userAuth
.
AuthResultInfo
)
=>
{
console
.
log
(
"
authV9 result
"
+
result
.
result
);
console
.
log
(
"
authV9 token
"
+
result
.
token
);
console
.
log
(
"
authV9 remainAttempts
"
+
result
.
remainAttempts
);
console
.
log
(
"
authV9 lockoutDuration
"
+
result
.
lockoutDuration
);
}
});
auth
.
start
();
console
.
log
(
"
authV9 start success
"
);
}
catch
(
error
)
{
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
}
```
## AuthResultInfo<sup>9+</sup>
表示认证结果信息的对象。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 参数类型 | 必填 | 说明 |
| ------------ | ---------- | ---- | -------------------- |
| result | number | 是 | 认证结果。 |
| token | Uint8Array | 否 | 用户身份认证通过的凭证。 |
| remainAttempts | number | 否 | 剩余的认证操作次数。 |
| lockoutDuration | number | 否 | 认证操作的冻结时间。 |
## TipInfo<sup>9+</sup>
表示认证过程中提示信息的对象。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 参数类型 | 必填 | 说明 |
| ------------ | ---------- | ---- | -------------------- |
| module | number | 否 | 认证结果。 |
| tip | number | 否 | 认证过程提示信息。 |
## AuthEventKey<sup>9+</sup>
类型别名,表示认证事件的关键字,取值为表格内字符串。
| 取值 | 说明 |
| ---------- | ----------------------- |
| "result" | 取值为result时,事件回调返回认证的结果信息。 |
| "tip" | 取值为tip时,事件回调返回认证操作中的提示信息。 |
## AuthInstance<sup>9+</sup>
执行用户认证的对象。
### on<sup>9+</sup>
on(name : AuthEventKey, callback : AuthEvent) : void
表示开启对认证事件的监听。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | ------------------------- |
| name | AuthEventKey | 是 | 认证事件的关键字 |
| callback | AuthEvent | 是 | 认证事件的回调函数 |
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
on
(
"
result
"
,
{
callback
:
(
result
:
userIAM_userAuth
.
AuthResultInfo
)
=>
{
console
.
log
(
"
authV9 result
"
+
result
.
result
);
console
.
log
(
"
authV9 token
"
+
result
.
token
);
console
.
log
(
"
authV9 remainAttempts
"
+
result
.
remainAttempts
);
console
.
log
(
"
authV9 lockoutDuration
"
+
result
.
lockoutDuration
);
}
});
auth
.
start
();
console
.
log
(
"
authV9 start success
"
);
}
catch
(
error
)
{
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
}
```
### off<sup>9+</sup>
off(name : AuthEventKey) : void
表示关闭对认证事件的监听。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
| 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | ------------------------- |
| name | AuthEventKey | 是 | 认证事件的关键字 |
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
on
(
"
result
"
,
{
callback
:
(
result
:
userIAM_userAuth
.
AuthResultInfo
)
=>
{
console
.
log
(
"
authV9 result
"
+
result
.
result
);
console
.
log
(
"
authV9 token
"
+
result
.
token
);
console
.
log
(
"
authV9 remainAttempts
"
+
result
.
remainAttempts
);
console
.
log
(
"
authV9 lockoutDuration
"
+
result
.
lockoutDuration
);
}
});
console
.
log
(
"
turn on authentication event listening success
"
);
}
catch
(
error
)
{
console
.
log
(
"
turn off authentication event listening failed
"
+
error
);
// do error
}
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
off
(
"
result
"
);
console
.
info
(
"
turn off authentication event listening success
"
);
}
catch
(
error
)
{
console
.
info
(
"
turn off authentication event listening failed, error =
"
+
error
);
}
```
### start<sup>9+</sup>
start() : void
表示开始认证。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
start
();
console
.
info
(
"
authV9 start auth success
"
);
}
catch
(
error
)
{
console
.
info
(
"
authV9 start auth failed, error =
"
+
error
);
}
```
### cancel<sup>9+</sup>
cancel(): void
表示取消认证。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
start
();
auth
.
cancel
();
console
.
info
(
"
cancel auth success
"
);
}
catch
(
error
)
{
console
.
info
(
"
cancel auth failed, error =
"
+
error
);
}
```
## userIAM_userAuth.getAuthInstance<sup>9+</sup>
getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel): AuthInstance
获取AuthInstance对象,用于执行用户身份认证。
> **说明:**
> 每个AuthInstance只能用于发起一次认证,若需要再次发起认证需重新获取AuthInstance。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------- | ---- | ------------------------ |
| challenge | Uint8Array | 是 | 挑战值,最大长度为32字节,可以填null。 |
| authType |
[
UserAuthType
](
#userauthtype8
)
| 是 | 认证类型,当前支持FACE。 |
| authTrustLevel |
[
AuthTrustLevel
](
#authtrustlevel8
)
| 是 | 认证信任等级。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------- | ------------ |
|
[
AuthInstance
](
#authinstance9
)
| 认证器对象。 |
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
challenge
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
let
authType
=
userIAM_userAuth
.
UserAuthType
.
FACE
;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
console
.
info
(
"
get auth instance success
"
);
}
catch
(
error
)
{
console
.
info
(
"
get auth instance success failed, error =
"
+
error
);
}
```
## userIAM_userAuth.getVersion<sup>9+</sup>
getVersion(): number
获取认证器的版本信息。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**返回值:**
| 类型 | 说明 |
| ------ | ---------------------- |
| number | 获取的认证器版本信息。 |
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
try
{
let
version
=
userIAM_userAuth
.
getVersion
();
console
.
info
(
"
auth version =
"
+
version
);
}
catch
(
error
)
{
console
.
info
(
"
get version failed, error =
"
+
error
);
}
```
## userIAM_userAuth.getAvailableStatus<sup>9+</sup>
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void
表示检查指定的认证等级的认证能力是否可用。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------- | ---- | -------------------------- |
| authType |
[
UserAuthType
](
#userauthtype8
)
| 是 | 认证类型,当前只支持FACE。 |
| authTrustLevel |
[
AuthTrustLevel
](
#authtrustlevel8
)
| 是 | 认证结果的信任等级。 |
**示例:**
```
js
import
userIAM_userAuth
from
'
@ohos.userIAM.userAuth
'
;
try
{
userIAM_userAuth
.
getAvailableStatus
(
userIAM_userAuth
.
UserAuthType
.
FACE
,
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
);
console
.
info
(
"
current auth trust level is supported
"
);
}
catch
(
error
)
{
console
.
info
(
"
current auth trust level is not supported, error =
"
+
error
);
}
```
## ResultCodeV9
<sup>
9+
</sup>
表示执行结果的枚举。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 |
| ----------------------- | ------ | -------------------- |
| SUCCESS | 12500000 | 执行成功。 |
| FAIL | 12500001 | 执行失败。 |
| GENERAL_ERROR | 12500002 | 操作通用错误。 |
| CANCELED | 12500003 | 操作取消。 |
| TIMEOUT | 12500004 | 操作超时。 |
| TYPE_NOT_SUPPORT | 12500005 | 不支持的认证类型。 |
| TRUST_LEVEL_NOT_SUPPORT | 12500006 | 不支持的认证等级。 |
| BUSY | 12500007 | 忙碌状态。 |
| INVALID_PARAMETERS | 12500008 | 无效参数。 |
| LOCKED | 12500009 | 认证器已锁定。 |
| NOT_ENROLLED | 12500010 | 用户未录入认证信息。 |
## UserAuth<sup>8+</sup>
## UserAuth<sup>8+</sup>
认证器的对象。
认证器的对象。
### constructor<sup>
8+
</sup>
### constructor<sup>
(deprecated)
</sup>
constructor()
constructor()
> **说明:**
> 从 API version 9 开始废弃,请使用[getAuthInstance](#useriam_userauthgetauthinstance9)替代。
<br/>
从 API version 8 开始支持。
表示获取的认证器对象。
表示获取的认证器对象。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
...
@@ -135,10 +559,14 @@ constructor()
...
@@ -135,10 +559,14 @@ constructor()
let
auth
=
new
userIAM_userAuth
.
UserAuth
();
let
auth
=
new
userIAM_userAuth
.
UserAuth
();
```
```
### getVersion<sup>
8+
</sup>
### getVersion<sup>
(deprecated)
</sup>
getVersion() : number
getVersion() : number
> **说明:**
> 从 API version 9 开始废弃,请使用[getVersion](#useriam_userauthgetversion9)替代。
<br/>
从 API version 8 开始支持。
表示获取的认证器版本信息。
表示获取的认证器版本信息。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
...
@@ -161,10 +589,14 @@ getVersion() : number
...
@@ -161,10 +589,14 @@ getVersion() : number
console
.
info
(
"
auth version =
"
+
version
);
console
.
info
(
"
auth version =
"
+
version
);
```
```
### getAvailableStatus<sup>
8+
</sup>
### getAvailableStatus<sup>
(deprecated)
</sup>
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number
> **说明:**
> 从 API version 9 开始废弃,请使用开始废弃,请使用[getAvailableStatus](#useriam_userauthgetavailablestatus9)替代。
<br/>
从 API version 8 开始支持。
表示检查指定的认证等级的认证能力是否可用。
表示检查指定的认证等级的认证能力是否可用。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
...
@@ -182,7 +614,7 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n
...
@@ -182,7 +614,7 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n
| 类型 | 说明 |
| 类型 | 说明 |
| ------ | ------------------------------------------------------------ |
| ------ | ------------------------------------------------------------ |
| number | 获取指定的认证等级的认证能力是否可用的检查结果,返回值参见
[
ResultCode
](
#resultcode
8
)
。 |
| number | 获取指定的认证等级的认证能力是否可用的检查结果,返回值参见
[
ResultCode
](
#resultcode
deprecated
)
。 |
**示例:**
**示例:**
...
@@ -200,10 +632,14 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n
...
@@ -200,10 +632,14 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n
}
}
```
```
### auth<sup>
8+
</sup>
### auth<sup>
(deprecated)
</sup>
auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array
auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array
> **说明:**
> 从 API version 9 开始废弃,建议使用[start](#start9)代替。
<br/>
从 API version 8 开始支持。
表示执行用户认证,使用callback方式作为异步方法。
表示执行用户认证,使用callback方式作为异步方法。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
...
@@ -217,13 +653,13 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
...
@@ -217,13 +653,13 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
| challenge | Uint8Array | 是 | 挑战值,可以填null。 |
| challenge | Uint8Array | 是 | 挑战值,可以填null。 |
| authType |
[
UserAuthType
](
#userauthtype8
)
| 是 | 认证类型,当前支持FACE。 |
| authType |
[
UserAuthType
](
#userauthtype8
)
| 是 | 认证类型,当前支持FACE。 |
| authTrustLevel |
[
AuthTrustLevel
](
#authtrustlevel8
)
| 是 | 信任等级。 |
| authTrustLevel |
[
AuthTrustLevel
](
#authtrustlevel8
)
| 是 | 信任等级。 |
| callback |
[
IUserAuthCallback
](
#iuserauthcallback
8
)
| 是 | 回调函数。 |
| callback |
[
IUserAuthCallback
](
#iuserauthcallback
deprecated
)
| 是 | 回调函数。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| ---------- | ------------------------------------------------------------ |
| ---------- | ------------------------------------------------------------ |
| Uint8Array | ContextId,作为取消认证
[
cancelAuth
](
#cancelauth
8
)
接口的入参。 |
| Uint8Array | ContextId,作为取消认证
[
cancelAuth
](
#cancelauth
deprecated
)
接口的入参。 |
**示例:**
**示例:**
...
@@ -248,10 +684,14 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
...
@@ -248,10 +684,14 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
});
});
```
```
### cancelAuth<sup>
8+
</sup>
### cancelAuth<sup>
(deprecated)
</sup>
cancelAuth(contextID : Uint8Array) : number
cancelAuth(contextID : Uint8Array) : number
> **说明:**
> 从 API version 9 开始废弃,建议使用[cancel](#cancel9)代替。
<br/>
从 API version 8 开始支持。
表示通过contextID取消本次认证操作。
表示通过contextID取消本次认证操作。
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
**需要权限**
:ohos.permission.ACCESS_BIOMETRIC
...
@@ -262,7 +702,7 @@ cancelAuth(contextID : Uint8Array) : number
...
@@ -262,7 +702,7 @@ cancelAuth(contextID : Uint8Array) : number
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------- | ---- | ------------------------------------------ |
| --------- | ---------- | ---- | ------------------------------------------ |
| contextID | Uint8Array | 是 | 上下文ID信息,通过
[
auth
](
#auth
8
)
接口获得。 |
| contextID | Uint8Array | 是 | 上下文ID信息,通过
[
auth
](
#auth
deprecated
)
接口获得。 |
**返回值:**
**返回值:**
...
@@ -286,14 +726,22 @@ cancelAuth(contextID : Uint8Array) : number
...
@@ -286,14 +726,22 @@ cancelAuth(contextID : Uint8Array) : number
}
}
```
```
## IUserAuthCallback<sup>8+</sup>
## IUserAuthCallback<sup>(deprecated)</sup>
> **说明:**
> 从 API version 9 开始废弃,建议使用[AuthEvent](#authevent9)代替。
<br/>
从 API version 8 开始支持。
认证过程中回调结果的对象。
认证过程中回调结果的对象。
### onResult<sup>
8+
</sup>
### onResult<sup>
(deprecated)
</sup>
onResult: (result : number, extraInfo : AuthResult) => void
onResult: (result : number, extraInfo : AuthResult) => void
> **说明:**
> 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。
<br/>
从 API version 8 开始支持。
表示在认证操作中,获取认证结果。
表示在认证操作中,获取认证结果。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
...
@@ -302,8 +750,8 @@ onResult: (result : number, extraInfo : AuthResult) => void
...
@@ -302,8 +750,8 @@ onResult: (result : number, extraInfo : AuthResult) => void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | ------------------------------------------------------------ |
| --------- | -------------------------- | ---- | ------------------------------------------------------------ |
| result | number | 是 | 认证结果,参见
[
ResultCode
](
#resultcode
8
)
。 |
| result | number | 是 | 认证结果,参见
[
ResultCode
](
#resultcode
deprecated
)
。 |
| extraInfo |
[
AuthResult
](
#authresult
8
)
| 是 | 扩展信息,不同情况下的具体信息,
<br/>
如果身份验证通过,则在extrainfo中返回用户认证令牌,
<br/>
如果身份验证失败,则在extrainfo中返回剩余的用户认证次数,
<br/>
如果身份验证执行器被锁定,则在extrainfo中返回冻结时间。 |
| extraInfo |
[
AuthResult
](
#authresult
deprecated
)
| 是 | 扩展信息,不同情况下的具体信息,
<br/>
如果身份验证通过,则在extrainfo中返回用户认证令牌,
<br/>
如果身份验证失败,则在extrainfo中返回剩余的用户认证次数,
<br/>
如果身份验证执行器被锁定,则在extrainfo中返回冻结时间。 |
**示例:**
**示例:**
...
@@ -339,10 +787,14 @@ onResult: (result : number, extraInfo : AuthResult) => void
...
@@ -339,10 +787,14 @@ onResult: (result : number, extraInfo : AuthResult) => void
});
});
```
```
### onAcquireInfo<sup>
8+
</sup>
### onAcquireInfo<sup>
(deprecated)
</sup>
onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
> **说明:**
> 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。
<br/>
从 API version 8 开始支持。
表示在认证过程中,获取提示码信息,非必须实现。
表示在认证过程中,获取提示码信息,非必须实现。
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
...
@@ -388,7 +840,11 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
...
@@ -388,7 +840,11 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
});
});
```
```
## AuthResult<sup>8+</sup>
## AuthResult<sup>(deprecated)</sup>
> **说明:**
> 从 API version 9 开始废弃,建议使用[AuthResultInfo](#authresultinfo9)代替。
<br/>
从 API version 8 开始支持。
表示认证结果的对象。
表示认证结果的对象。
...
@@ -400,7 +856,10 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
...
@@ -400,7 +856,10 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
| remainTimes | number | 否 | 剩余的认证操作次数。 |
| remainTimes | number | 否 | 剩余的认证操作次数。 |
| freezingTime | number | 否 | 认证操作的冻结时间。 |
| freezingTime | number | 否 | 认证操作的冻结时间。 |
## ResultCode<sup>8+</sup>
## ResultCode<sup>(deprecated)</sup>
> **说明:**
> 从 API version 9 开始废弃,建议使用[ResultCodeV9](#resultcodev99)代替。
表示执行结果的枚举。
表示执行结果的枚举。
...
@@ -487,7 +946,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
...
@@ -487,7 +946,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
getAuthenticator(): Authenticator
getAuthenticator(): Authenticator
> **说明:**
> **说明:**
> 从 API
Version 8 开始废弃,建议使用[constructor](#constructor8
)替代。
> 从 API
version 8 开始废弃,建议使用[constructor](#constructordeprecated
)替代。
获取Authenticator对象,用于执行用户身份认证。
获取Authenticator对象,用于执行用户身份认证。
...
@@ -507,7 +966,7 @@ getAuthenticator(): Authenticator
...
@@ -507,7 +966,7 @@ getAuthenticator(): Authenticator
## Authenticator<sup>(deprecated)</sup>
## Authenticator<sup>(deprecated)</sup>
> **说明:**
> **说明:**
> 从 API
V
ersion 8 开始废弃,建议使用[UserAuth](#userauth8)替代。
> 从 API
v
ersion 8 开始废弃,建议使用[UserAuth](#userauth8)替代。
认证器对象。
认证器对象。
...
@@ -517,7 +976,7 @@ getAuthenticator(): Authenticator
...
@@ -517,7 +976,7 @@ getAuthenticator(): Authenticator
execute(type: AuthType, level: SecureLevel, callback: AsyncCallback
<
number
>
): void
execute(type: AuthType, level: SecureLevel, callback: AsyncCallback
<
number
>
): void
> **说明:**
> **说明:**
> 从 API
Version 8 开始废弃,建议使用[auth](#auth8
)替代。
> 从 API
version 8 开始废弃,建议使用[auth](#authdeprecated
)替代。
执行用户认证,使用callback方式作为异步方法。
执行用户认证,使用callback方式作为异步方法。
...
@@ -557,7 +1016,7 @@ execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>
...
@@ -557,7 +1016,7 @@ execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>
execute(type:AuthType, level:SecureLevel): Promise
<
number
>
execute(type:AuthType, level:SecureLevel): Promise
<
number
>
> **说明:**
> **说明:**
> 从 API
Version 8 开始废弃,建议使用[auth](#auth8
)替代。
> 从 API
version 8 开始废弃,建议使用[auth](#authdeprecated
)替代。
执行用户认证,使用promise方式作为异步方法。
执行用户认证,使用promise方式作为异步方法。
...
@@ -592,7 +1051,7 @@ execute(type:AuthType, level:SecureLevel): Promise<number>
...
@@ -592,7 +1051,7 @@ execute(type:AuthType, level:SecureLevel): Promise<number>
## AuthenticationResult<sup>(deprecated)</sup>
## AuthenticationResult<sup>(deprecated)</sup>
> **说明:**
> **说明:**
> 从 API
Version 8 开始废弃,建议使用[ResultCode](#resultcode8
)替代。
> 从 API
version 8 开始废弃,建议使用[ResultCode](#resultcodedeprecated
)替代。
表示认证结果的枚举。
表示认证结果的枚举。
...
@@ -610,4 +1069,4 @@ execute(type:AuthType, level:SecureLevel): Promise<number>
...
@@ -610,4 +1069,4 @@ execute(type:AuthType, level:SecureLevel): Promise<number>
| INVALID_PARAMETERS | 6 | 认证参数无效。 |
| INVALID_PARAMETERS | 6 | 认证参数无效。 |
| LOCKED | 7 | 认证失败次数过多,已锁定。 |
| LOCKED | 7 | 认证失败次数过多,已锁定。 |
| NOT_ENROLLED | 8 | 未录入认证凭据。 |
| NOT_ENROLLED | 8 | 未录入认证凭据。 |
| GENERAL_ERROR | 100 | 其他错误。 |
| GENERAL_ERROR | 100 | 其他错误。 |
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录