Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5011b6f8
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
未验证
提交
5011b6f8
编写于
9月 02, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 02, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23699 用户IAM:ArkTs整改
Merge pull request !23699 from liuziwei/master
上级
64200b15
be2dc13a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
146 addition
and
148 deletion
+146
-148
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
...pplication-dev/reference/apis/js-apis-useriam-userauth.md
+100
-91
zh-cn/application-dev/security/userauth-guidelines.md
zh-cn/application-dev/security/userauth-guidelines.md
+46
-57
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
浏览文件 @
5011b6f8
...
...
@@ -85,15 +85,15 @@ onResult(result: UserAuthResult): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
const
authParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
10000
,
const
authParam
:
userAuth
.
AuthParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
};
const
widgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
const
widgetParam
:
userAuth
.
WidgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
...
...
@@ -143,15 +143,15 @@ on(type: 'result', callback: IAuthCallback): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
const
authParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
10000
,
const
authParam
:
userAuth
.
AuthParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
};
const
widgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
const
widgetParam
:
userAuth
.
WidgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
...
...
@@ -198,15 +198,15 @@ off(type: 'result', callback?: IAuthCallback): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
const
authParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
10000
,
const
authParam
:
userAuth
.
AuthParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
};
const
widgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
const
widgetParam
:
userAuth
.
WidgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
...
...
@@ -256,15 +256,15 @@ start(): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
const
authParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
10000
,
const
authParam
:
userAuth
.
AuthParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
};
const
widgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
const
widgetParam
:
userAuth
.
WidgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
...
...
@@ -301,15 +301,15 @@ cancel(): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
const
authParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
10000
,
const
authParam
:
userAuth
.
AuthParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
};
const
widgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
const
widgetParam
:
userAuth
.
WidgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
...
...
@@ -361,15 +361,15 @@ getUserAuthInstance(authParam: AuthParam, widgetParam: WidgetParam): UserAuthIns
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
const
authParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
10000
,
const
authParam
:
userAuth
.
AuthParam
=
{
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
]),
authType
:
[
userAuth
.
UserAuthType
.
PIN
],
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
};
const
widgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
const
widgetParam
:
userAuth
.
WidgetParam
=
{
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
...
...
@@ -426,21 +426,30 @@ sendNotice(noticeType: NoticeType, eventData: string): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
class
EventData
{
widgetContextId
:
number
=
0
;
event
:
string
=
""
;
version
:
string
=
""
;
payload
:
PayLoad
=
{
type
:
[
'
pin
'
]
};
}
class
PayLoad
{
type
:
Object
[]
=
[];
}
try
{
const
e
ventData
=
{
widgetContextId
:
123456
,
event
:
'
EVENT_AUTH_TYPE_READY
'
,
version
:
'
1
'
,
payload
:
{
type
:
[
'
pin
'
]
}
,
};
const
jsonEventData
=
JSON
.
stringify
(
eventData
);
let
noticeType
=
userAuth
.
NoticeType
.
WIDGET_NOTICE
;
userAuth
.
sendNotice
(
noticeType
,
jsonEventData
);
console
.
log
(
'
sendNotice success
'
);
const
eventData
:
E
ventData
=
{
widgetContextId
:
123456
,
event
:
'
EVENT_AUTH_TYPE_READY
'
,
version
:
'
1
'
,
payload
:
{
type
:
[
'
pin
'
]
}
as
PayLoad
,
};
const
jsonEventData
=
JSON
.
stringify
(
eventData
);
let
noticeType
=
userAuth
.
NoticeType
.
WIDGET_NOTICE
;
userAuth
.
sendNotice
(
noticeType
,
jsonEventData
);
console
.
log
(
'
sendNotice success
'
);
}
catch
(
error
)
{
console
.
log
(
'
sendNotice catch error:
'
+
JSON
.
stringify
(
error
));
console
.
log
(
'
sendNotice catch error:
'
+
JSON
.
stringify
(
error
));
}
```
...
...
@@ -706,41 +715,41 @@ let authType = userIAM_userAuth.UserAuthType.FACE;
let
authTrustLevel
=
userIAM_userAuth
.
AuthTrustLevel
.
ATL1
;
// 通过callback获取认证结果
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
"
);
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
);
}
}
as
userIAM_userAuth
.
AuthEvent
);
auth
.
start
();
console
.
log
(
"
authV9 start success
"
);
}
catch
(
error
)
{
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
}
// 通过callback获取认证过程中的提示信息
try
{
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
on
(
"
tip
"
,
{
callback
:
(
result
:
userIAM_userAuth
.
TipInfo
)
=>
{
switch
(
result
.
tip
)
{
case
userIAM_userAuth
.
FaceTips
.
FACE_AUTH_TIP_TOO_BRIGHT
:
// do something;
case
userIAM_userAuth
.
FaceTips
.
FACE_AUTH_TIP_TOO_DARK
:
// do something;
default
:
// do others
}
}
}
);
auth
.
start
();
console
.
log
(
"
authV9 start success
"
);
let
auth
=
userIAM_userAuth
.
getAuthInstance
(
challenge
,
authType
,
authTrustLevel
);
auth
.
on
(
"
tip
"
,
{
callback
:
(
result
:
userIAM_userAuth
.
TipInfo
)
=>
{
switch
(
result
.
tip
)
{
case
userIAM_userAuth
.
FaceTips
.
FACE_AUTH_TIP_TOO_BRIGHT
:
// do something;
case
userIAM_userAuth
.
FaceTips
.
FACE_AUTH_TIP_TOO_DARK
:
// do something;
default
:
// do others
}
}
}
as
userIAM_userAuth
.
AuthEvent
);
auth
.
start
();
console
.
log
(
"
authV9 start success
"
);
}
catch
(
error
)
{
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
console
.
log
(
"
authV9 error =
"
+
error
);
// do error
}
```
...
...
zh-cn/application-dev/security/userauth-guidelines.md
浏览文件 @
5011b6f8
...
...
@@ -71,43 +71,38 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证
```js
import userIAM_userAuth from '@ohos.userIAM.userAuth';
const authParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [
userAuth.UserAuthType.PIN],
authTrustLevel: 10000
,
const authParam
: userIAM_userAuth.AuthParam
= {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userIAM_
userAuth.UserAuthType.PIN],
authTrustLevel: userIAM_userAuth.AuthTrustLevel.ATL1
,
};
const widgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode:
userAuth.WindowModeType.DIALOG_BOX,
const widgetParam
: userIAM_userAuth.WidgetParam
= {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userIAM_
userAuth.WindowModeType.DIALOG_BOX,
};
let userAuthInstance;
try {
//获取认证对象
userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
console.log('get userAuth instance success');
//订阅认证结果
userAuthInstance.on('result', {
onResult (result) {
console.log('userAuthInstance callback result = ' + JSON.stringify(result));
}
});
console.log('auth on success');
userAuthInstance.start();
console.log('auth start success');
//获取认证对象
let userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
console.log('get userAuth instance success');
//订阅认证结果
userAuthInstance.on('result', {
onResult (result) {
console.log('userAuthInstance callback result = ' + JSON.stringify(result));
}
});
console.log('auth on success');
userAuthInstance.start();
console.log('auth start success');
//取消订阅认证结果
userAuthInstance.off('result', {
onResult (result) {
console.log('auth off result: ' + JSON.stringify(result));
}
});
console.log('auth off success');
} catch (error) {
console.log('auth on catch error: ' + JSON.stringify(error));
}
//取消订阅认证结果
try {
userAuthInstance.off('result', {
onResult (result) {
console.log('auth off result: ' + JSON.stringify(result));
}
});
console.log('auth off success');
} catch (error) {
console.log('auth catch error: ' + JSON.stringify(error));
console.log('auth catch error: ' + JSON.stringify(error));
}
```
...
...
@@ -126,33 +121,27 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证
```js
import userIAM_userAuth from '@ohos.userIAM.userAuth';
const authParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [
userAuth.UserAuthType.PIN],
authTrustLevel: 10000
,
const authParam
: userIAM_userAuth.AuthParam
= {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userIAM_
userAuth.UserAuthType.PIN],
authTrustLevel: userIAM_userAuth.AuthTrustLevel.ATL1
,
};
const widgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode:
userAuth.WindowModeType.DIALOG_BOX,
const widgetParam
: userIAM_userAuth.WidgetParam
= {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userIAM_
userAuth.WindowModeType.DIALOG_BOX,
};
let userAuthInstance;
try {
//获取认证对象
userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
console.log('get userAuth instance success');
//开始认证
userAuthInstance.start();
console.log('auth start success');
} catch (error) {
console.log('auth catch error: ' + JSON.stringify(error));
}
// 取消认证
try {
userAuthInstance.cancel();
console.log('auth cancel success');
//获取认证对象
let userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
console.log('get userAuth instance success');
//开始认证
userAuthInstance.start();
console.log('auth start success');
// 取消认证
userAuthInstance.cancel();
console.log('auth cancel success');
} catch (error) {
console.log('auth catch error: ' + JSON.stringify(error));
console.log('auth catch error: ' + JSON.stringify(error));
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录