Sets an [XComponent surface ID](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) for the face preview page in the face enrollment process.
Sets an [XComponent surface ID](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) for the face preview page in the face enrollment process. This API must be used with [AddCredential](./js-apis-osAccount.md#addcredential8).
The **userIAM.userAuth** module provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app login.
The **userIAM.userAuth** module provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app login.
...
@@ -12,268 +12,115 @@ The **userIAM.userAuth** module provides user authentication capabilities in ide
...
@@ -12,268 +12,115 @@ The **userIAM.userAuth** module provides user authentication capabilities in ide
| name | AuthEventKey | Yes | Keyword of the authentication event to listen for. |
| name | [AuthEventKey](#autheventkey9) | Yes | Authentication event type. If the value is **result**, the callback returns the authentication result. If the value is **tip**, the callback returns the authentication tip information.|
| callback | AuthEvent | Yes | Callback invoked to return the authentication event. |
| callback | [AuthEvent](#authevent9) | Yes | Callback invoked to return the authentication result or tip information.|
For details about the error codes, see [User Authentication Error Codes](../errorcodes/errorcode-useriam.md).
| name | AuthEventKey | Yes | Keyword of the authentication event. |
| name | [AuthEventKey](#autheventkey9) | Yes | Type of the authentication event to unsubscribe from. If the value is **result**, the authentication result is unsubscribed from. If the value is **tip**, the authentication tip information is unsubscribed from.|
For details about the error codes, see [User Authentication Error Codes](../errorcodes/errorcode-useriam.md).
> Use the [AuthInstance](#authinstance9) instance obtained to invoke this API. The [AuthInstance](#authinstance9) instance must be the one being authenticated.
| SUCCESS | 12500000 | The operation is successful. |
| SUCCESS | 12500000 | The authentication is successful. |
| FAIL | 12500001 | The operation failed. |
| FAIL | 12500001 | The authentication failed. |
| GENERAL_ERROR | 12500002 | A common operation error occurred. |
| GENERAL_ERROR | 12500002 | A general operation error occurred. |
| CANCELED | 12500003 | The operation is canceled. |
| CANCELED | 12500003 | The authentication is canceled. |
| TIMEOUT | 12500004 | The operation timed out. |
| TIMEOUT | 12500004 | The authentication timed out. |
| TYPE_NOT_SUPPORT | 12500005 | The authentication type is not supported. |
| TYPE_NOT_SUPPORT | 12500005 | The authentication type is not supported. |
| TRUST_LEVEL_NOT_SUPPORT | 12500006 | The authentication trust level is not supported. |
| TRUST_LEVEL_NOT_SUPPORT | 12500006 | The authentication trust level is not supported. |
| BUSY | 12500007 | Indicates the busy state. |
| BUSY | 12500007 | Indicates the busy state. |
| INVALID_PARAMETERS | 12500008 | Invalid parameters are detected. |
| LOCKED | 12500009 | The authentication executor is locked. |
| LOCKED | 12500009 | The authentication executor is locked. |
| NOT_ENROLLED | 12500010 | The user has not entered the authentication information.|
| NOT_ENROLLED | 12500010 | The user has not entered the authentication information.|
## UserAuth<sup>8+</sup>
## UserAuth<sup>8+</sup>
Provides methods to manage an **Authenticator** object.
Provides APIs to manage an **Authenticator** object.
### constructor<sup>(deprecated)</sup>
### constructor<sup>(deprecated)</sup>
constructor()
constructor()
> **NOTE**
A constructor used to create an authenticator instance.
>
>This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAuthInstance](#useriam_userauthgetauthinstance9).
A constructor used to create an **authenticator** object.
> **NOTE**<br>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAuthInstance](#useriam_userauthgetauthinstance9).
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number
> **NOTE**
Checks whether the specified authentication capability is supported.
>
>This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAvailableStatus](#useriam_userauthgetavailablestatus9).
Obtains the available status of the specified authentication trust level.
> **NOTE**<br>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAvailableStatus](#useriam_userauthgetavailablestatus9).
| number | Available status obtained. For details, see [ResultCode](#resultcodedeprecated).|
| number | Query result. If the authentication capability is supported, **SUCCESS** is returned. Otherwise, a [ResultCode](#resultcodedeprecated) is returned.|
| result | number | Yes | Authentication result. For details, see [ResultCode](#resultcodedeprecated). |
| result | number | Yes | Authentication result. For details, see [ResultCode](#resultcodedeprecated).|
| extraInfo | [AuthResult](#authresultdeprecated) | Yes | Extended information, which varies depending on the authentication result.<br>If the authentication is successful, the user authentication token will be returned in **extraInfo**.<br>If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.<br>If the authentication executor is locked, the freeze time will be returned in **extraInfo**.|
| extraInfo | [AuthResult](#authresultdeprecated) | Yes | Extended information, which varies depending on the authentication result.<br>If the authentication is successful, the user authentication token will be returned in **extraInfo**.<br>If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.<br>If the authentication executor is locked, the freeze time will be returned in **extraInfo**.|
| type | AuthType | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.|
| type | AuthType | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.|
| level | SecureLevel | Yes | Security level of the authentication. It can be **S1** (lowest), **S2**, **S3**, or **S4** (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.|
| level | SecureLevel | Yes | Security level of the authentication. It can be **S1** (lowest), **S2**, **S3**, or **S4** (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.|
| callback | AsyncCallback<number> | No | Callback used to return the result. |
| callback | AsyncCallback<number> | Yes | Callback used to return the result. |
For details, see [Universal Error Codes](./errorcode-universal.md).
## 202 Invoker Is Not a System Application
For details, see [Universal Error Codes](./errorcode-universal.md).
## 401 Parameter Check Failed.
For details, see [Universal Error Codes](./errorcode-universal.md).
## 12500001 Authentication Failed
**Error Message**
Authentication failed.
**Possible Causes**
The credential does not match the credential enrolled.
**Solution**
Initiate authentication again.
## 12500002 General Operation Error
**Error Message**
General operation error.
**Possible Causes**
1. An error occurs when the NAPI layer parses parameters.
2. The process of the user authentication service is not started.
3. The proxy client fails to write data over IPC.
4. The stub server fails to parse data over IPC.
5. The driver service is not obtained.
**Solution**
Call the API again later or restart the device.
## 12500003 Authentication Canceled
**Error Message**
Authentication canceled.
**Possible Causes**
The authentication operation has been canceled.
**Solution**
Initiate the authentication again.
## 12500004 Authentication Timed Out
**Error Message**
Authentication timeout.
**Possible Causes**
The authentication is not complete within the specified time.
**Solution**
Initiate the authentication again.
## 12500005 Unsupported Authentication Type
**Error Message**
The authentication type is not supported.
**Possible Causes**
1. The input authentication type parameter is not supported. For example, if the authentication type passed in **getAvailableStatus** of the **userAuth** module is not **FACE** or **FINGERPRINT**, error code 12500005 is returned.
2. The device does not support the authentication type. For example, if fingerprint authentication is initiated on a device that has no fingerprint sensor, error code 12500005 is returned.
**Solution**
Check the authentication type parameter and call the API again.
1. The **authTrustLevel** value in **getAvailableStatus** or **getAuthInstance** of the **userAuth** module is not in the range [ATL1, ATL2, ATL3, ATL4].
2. The device does not support the authentication trust level. For example, if facial authentication for payment is initiated on a device that has only 2D cameras, error code 12500006 is returned.
**Solution**
Check that the **authTrustLevel** passed in is within the value range, and the device supports the specified authentication trust level.
## 12500007 Authentication Service Unavailable
**Error Message**
Authentication service is busy.
**Possible Causes**
Another authentication is initiated when the current authentication has not been finished yet.
**Solution**
Initiate authentication again later.
## 12500009 Authentication Locked
**Error Message**
Authentication is lockout.
**Possible Causes**
The number of authentication failures exceeds the limit.
**Solution**
Initiate authentication later.
## 12500010 Credential Not Enrolled
**Error Message**
The type of credential has not been enrolled.
**Possible Causes**
The **authType** parameter set in **getAvailableStatus** of the **userAuth** module is **FACE**, but no facial credential is enrolled in the device.
**start()** is called to initiate facial authentication, but no facial credential is enrolled in the device.
**Solution**
Check that the related type of credential has been enrolled in the device.
## 12700001 Failed to Enroll Faces
**Error Message**
The operation is failed.
**Possible Causes**
1. The facial authentication service is not started when **setSurfaceId()** of the **userAuth** module is called.
2. The proxy client fails to write data over IPC.
3. The stub server fails to parse data over IPC.
4. An error occurs when the facial authentication driver is invoked.