未验证 提交 5011b6f8 编写于 作者: O openharmony_ci 提交者: Gitee

!23699 用户IAM:ArkTs整改

Merge pull request !23699 from liuziwei/master
......@@ -85,12 +85,12 @@ onResult(result: UserAuthResult): void
```js
import userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authTrustLevel: userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam :userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
......@@ -143,12 +143,12 @@ on(type: 'result', callback: IAuthCallback): void
```js
import userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authTrustLevel: userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam :userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
......@@ -198,12 +198,12 @@ off(type: 'result', callback?: IAuthCallback): void
```js
import userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authTrustLevel: userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam :userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
......@@ -256,12 +256,12 @@ start(): void
```js
import userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authTrustLevel: userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam :userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
......@@ -301,12 +301,12 @@ cancel(): void
```js
import userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authTrustLevel: userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam :userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
......@@ -361,12 +361,12 @@ getUserAuthInstance(authParam: AuthParam, widgetParam: WidgetParam): UserAuthIns
```js
import userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authTrustLevel: userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam :userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
......@@ -426,14 +426,23 @@ 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 eventData = {
const eventData : EventData = {
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;
......@@ -714,7 +723,7 @@ try {
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) {
......@@ -735,7 +744,7 @@ try {
// do others
}
}
});
} as userIAM_userAuth.AuthEvent);
auth.start();
console.log("authV9 start success");
} catch (error) {
......
......@@ -71,20 +71,19 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证
```js
import userIAM_userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userIAM_userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authType: [userIAM_userAuth.UserAuthType.PIN],
authTrustLevel: userIAM_userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam : userIAM_userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
windowMode: userIAM_userAuth.WindowModeType.DIALOG_BOX,
};
let userAuthInstance;
try {
//获取认证对象
userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
let userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
console.log('get userAuth instance success');
//订阅认证结果
userAuthInstance.on('result', {
......@@ -95,11 +94,7 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证
console.log('auth on success');
userAuthInstance.start();
console.log('auth start 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));
......@@ -126,30 +121,24 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证
```js
import userIAM_userAuth from '@ohos.userIAM.userAuth';
const authParam = {
const authParam : userIAM_userAuth.AuthParam = {
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
authType: [userAuth.UserAuthType.PIN],
authTrustLevel: 10000,
authType: [userIAM_userAuth.UserAuthType.PIN],
authTrustLevel: userIAM_userAuth.AuthTrustLevel.ATL1,
};
const widgetParam = {
const widgetParam : userIAM_userAuth.WidgetParam = {
title: '请输入密码',
navigationButtonText: '返回',
windowMode: userAuth.WindowModeType.DIALOG_BOX,
windowMode: userIAM_userAuth.WindowModeType.DIALOG_BOX,
};
let userAuthInstance;
try {
//获取认证对象
userAuthInstance = userIAM_userAuth.getUserAuthInstance(authParam, widgetParam);
let 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');
} catch (error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册