UserAuthenticationKit打元服务标签

Signed-off-by: tangjie <1402602435@qq.com>
This commit is contained in:
tangjie 2024-07-24 17:16:28 +08:00
parent e9c4e95ba0
commit 2f429fad98
2 changed files with 351 additions and 0 deletions

View File

@ -27,12 +27,21 @@ import type { AsyncCallback } from './@ohos.base';
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 6
*/
/**
* User authentication
*
* @namespace userAuth
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
declare namespace userAuth {
/**
* The maximum allowable reuse duration is 300000 milliseconds.
*
* @constant
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
const MAX_ALLOWABLE_REUSE_DURATION: 300000;
@ -663,6 +672,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Credential type for authentication.
*
* @enum { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
enum UserAuthType {
/**
* Authentication type pin.
@ -670,6 +687,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Authentication type pin.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
PIN = 1,
/**
@ -678,6 +702,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Authentication type face.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
FACE = 2,
/**
@ -686,6 +717,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Authentication type fingerprint.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
FINGERPRINT = 4
}
@ -696,6 +734,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Trust level of authentication results.
*
* @enum { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
enum AuthTrustLevel {
/**
* Authentication result trusted level 1.
@ -703,6 +749,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Authentication result trusted level 1.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
ATL1 = 10000,
/**
@ -711,6 +764,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Authentication result trusted level 2.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
ATL2 = 20000,
/**
@ -719,6 +779,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Authentication result trusted level 3.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
ATL3 = 30000,
/**
@ -727,6 +794,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 8
*/
/**
* Authentication result trusted level 4.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
ATL4 = 40000
}
@ -953,6 +1027,7 @@ declare namespace userAuth {
* @throws { BusinessError } 12500010 - The type of credential has not been enrolled.
* @throws { BusinessError } 12500013 - Operation failed because of PIN expired.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
function getAvailableStatus(authType: UserAuthType, authTrustLevel: AuthTrustLevel): void;
@ -962,6 +1037,7 @@ declare namespace userAuth {
*
* @typedef EnrolledState
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface EnrolledState {
@ -970,6 +1046,7 @@ declare namespace userAuth {
*
* @type { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
credentialDigest: number;
@ -979,6 +1056,7 @@ declare namespace userAuth {
*
* @type { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
credentialCount: number;
@ -997,6 +1075,7 @@ declare namespace userAuth {
* @throws { BusinessError } 12500005 - The authentication type is not supported.
* @throws { BusinessError } 12500010 - The type of credential has not been enrolled.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
function getEnrolledState(authType: UserAuthType): EnrolledState;
@ -1052,6 +1131,7 @@ declare namespace userAuth {
*
* @enum { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
enum ReuseMode {
@ -1060,6 +1140,7 @@ declare namespace userAuth {
* valid duration as well as it comes from one of specified UserAuthTypes of the AuthParam.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
AUTH_TYPE_RELEVANT = 1,
@ -1069,6 +1150,7 @@ declare namespace userAuth {
* valid duration.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
AUTH_TYPE_IRRELEVANT = 2
@ -1079,6 +1161,7 @@ declare namespace userAuth {
*
* @typedef ReuseUnlockResult
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface ReuseUnlockResult {
@ -1087,6 +1170,7 @@ declare namespace userAuth {
*
* @type { ReuseMode }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
reuseMode: ReuseMode;
@ -1096,6 +1180,7 @@ declare namespace userAuth {
*
* @type { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
reuseDuration: number;
@ -1108,6 +1193,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Auth parameter.
*
* @typedef AuthParam
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface AuthParam {
/**
* Pass in challenge value.
@ -1116,6 +1209,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Pass in challenge value.
*
* @type { Uint8Array }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
challenge: Uint8Array;
/**
@ -1125,6 +1226,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Credential type for authentication.
*
* @type { UserAuthType[] }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
authType: UserAuthType[];
/**
@ -1134,6 +1243,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Trust level of authentication result.
*
* @type { AuthTrustLevel }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
authTrustLevel: AuthTrustLevel;
/**
@ -1141,6 +1258,7 @@ declare namespace userAuth {
*
* @type { ?ReuseUnlockResult }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
reuseUnlockResult?: ReuseUnlockResult;
@ -1153,6 +1271,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Auth widget parameter.
*
* @typedef WidgetParam
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface WidgetParam {
/**
* Title of widget.
@ -1161,6 +1287,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Title of widget.
*
* @type { string }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
title: string;
/**
@ -1170,6 +1304,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* The description text of navigation button.
*
* @type { ?string }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
navigationButtonText?: string;
/**
@ -1191,6 +1333,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Authentication result: authentication token, credential type for authentication succeed.
*
* @typedef UserAuthResult
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface UserAuthResult {
/**
* The authentication result.
@ -1199,6 +1349,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* The authentication result.
*
* @type { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
result: number;
/**
@ -1208,6 +1366,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* The authentication result if the authentication is passed.
*
* @type { ?Uint8Array }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
token?: Uint8Array;
/**
@ -1217,6 +1383,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Credential type for authentication succeed.
*
* @type { ?UserAuthType }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
authType?: UserAuthType;
/**
@ -1225,6 +1399,7 @@ declare namespace userAuth {
*
* @type { ?EnrolledState }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
enrolledState?: EnrolledState;
@ -1237,6 +1412,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Asynchronous callback of authentication operation.
*
* @interface IAuthCallback
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface IAuthCallback {
/**
* The authentication result code is returned through the callback.
@ -1246,6 +1429,15 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* The authentication result code is returned through the callback.
* If the authentication is passed, the authentication token is returned in extraInfo.
*
* @param { UserAuthResult } result - Authentication result information.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
onResult(result: UserAuthResult): void;
}
@ -1256,6 +1448,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* User authentication instance, used to initiate a complete authentication.
*
* @interface UserAuthInstance
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
interface UserAuthInstance {
/**
* Turn on widget authentication result event listening.
@ -1270,6 +1470,20 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Turn on widget authentication result event listening.
*
* @param { 'result' } type - Indicates the type of event.
* @param { IAuthCallback } callback - Indicates the listener.
* @throws { BusinessError } 401 - Incorrect parameters. Possible causes:
* <br>1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* <br>3. Parameter verification failed.
* @throws { BusinessError } 12500002 - General operation error.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
on(type: 'result', callback: IAuthCallback): void;
/**
@ -1285,6 +1499,20 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Turn off widget authentication result event listening.
*
* @param { 'result' } type - Indicates the type of event.
* @param { IAuthCallback } callback - Indicates the listener.
* @throws { BusinessError } 401 - Incorrect parameters. Possible causes:
* <br>1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* <br>3. Parameter verification failed.
* @throws { BusinessError } 12500002 - General operation error.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
off(type: 'result', callback?: IAuthCallback): void;
/**
@ -1326,6 +1554,7 @@ declare namespace userAuth {
* @throws { BusinessError } 12500011 - Switched to the custom authentication process.
* @throws { BusinessError } 12500013 - Operation failed because of PIN expired.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
start(): void;
@ -1341,6 +1570,18 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Cancel this authentication.
*
* @permission ohos.permission.ACCESS_BIOMETRIC
* @throws { BusinessError } 201 - Permission verification failed.
* @throws { BusinessError } 401 - Incorrect parameters. Possible causes:
* <br>1. Incorrect parameter types.
* @throws { BusinessError } 12500002 - General operation error.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
cancel(): void;
}
@ -1360,6 +1601,23 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Get user authentication instance with widget.
*
* @param { AuthParam } authParam - Auth parameter.
* @param { WidgetParam } widgetParam - Widget parameter.
* @returns { UserAuthInstance } Returns an authentication instance with widget.
* @throws { BusinessError } 401 - Incorrect parameters. Possible causes:
* <br>1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* <br>3. Parameter verification failed.
* @throws { BusinessError } 12500002 - General operation error.
* @throws { BusinessError } 12500005 - The authentication type is not supported.
* @throws { BusinessError } 12500006 - The authentication trust level is not supported.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
function getUserAuthInstance(authParam: AuthParam, widgetParam: WidgetParam): UserAuthInstance;
/**
@ -1407,6 +1665,14 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Enum for operation result.
*
* @enum { number }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
enum UserAuthResultCode {
/**
* Indicates that the result is success or ability is supported.
@ -1414,6 +1680,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that the result is success or ability is supported.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
SUCCESS = 12500000,
/**
@ -1422,6 +1695,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that the authentication result is failed.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
FAIL = 12500001,
/**
@ -1430,6 +1710,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates other errors.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
GENERAL_ERROR = 12500002,
/**
@ -1438,6 +1725,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that this operation is canceled.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
CANCELED = 12500003,
/**
@ -1446,6 +1740,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that this operation is time-out.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
TIMEOUT = 12500004,
/**
@ -1454,6 +1755,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that this authentication type is not supported.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
TYPE_NOT_SUPPORT = 12500005,
/**
@ -1462,6 +1770,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that the authentication trust level is not supported.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
TRUST_LEVEL_NOT_SUPPORT = 12500006,
/**
@ -1470,6 +1785,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that the authentication task is busy. Wait for a few seconds and try again.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
BUSY = 12500007,
/**
@ -1478,6 +1800,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that the authenticator is locked.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
LOCKED = 12500009,
/**
@ -1486,6 +1815,13 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 9
*/
/**
* Indicates that the user has not enrolled the authenticator.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
NOT_ENROLLED = 12500010,
/**
@ -1494,12 +1830,20 @@ declare namespace userAuth {
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @since 10
*/
/**
* Indicates that this operation is canceled from widget's navigation button.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
CANCELED_FROM_WIDGET = 12500011,
/**
* Indicates that current operation failed because of PIN expired.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
PIN_EXPIRED = 12500013

View File

@ -24,6 +24,7 @@ import userAuth from '@ohos.userIAM.userAuth';
* Declare UserAuthIcon, use for user authentication.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
@Component
@ -33,6 +34,7 @@ export default struct UserAuthIcon {
*
* @type { userAuth.AuthParam }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
authParam: userAuth.AuthParam;
@ -42,6 +44,7 @@ export default struct UserAuthIcon {
*
* @type { userAuth.WidgetParam }
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
widgetParam: userAuth.WidgetParam;
@ -52,6 +55,7 @@ export default struct UserAuthIcon {
* @type { ?Dimension }
* @default 64
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
iconHeight?: Dimension;
@ -62,6 +66,7 @@ export default struct UserAuthIcon {
* @type { ?ResourceColor }
* @default $r('sys.color.ohos_id_color_activated')
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
iconColor?: ResourceColor;
@ -73,6 +78,7 @@ export default struct UserAuthIcon {
*
* @param { userAuth.UserAuthResult } result - Authentication result information.
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
onAuthResult: (result: userAuth.UserAuthResult) => void;
@ -81,6 +87,7 @@ export default struct UserAuthIcon {
* When user click the icon, it will be returned through this callback.
*
* @syscap SystemCapability.UserIAM.UserAuth.Core
* @atomicservice
* @since 12
*/
onIconClick?: () => void;