This module identifies fraud risks of a device.
Start version: 5.0.0(12)
Fraud detection request parameters.
System capability: SystemCapability.Security.BusinessRiskIntelligentDetection
Start version: 5.0.0(12)
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
nonce | Uint8Array | No | No | A randomly generated nonce value passed by your app, which is used to prevent replay attacks. The detection result contains this value. A nonce value must contain 24 to 80 bytes. |
algorithm | No | No | Digital signature algorithm. |
Digital signature algorithm.
System capability: SystemCapability.Security.BusinessRiskIntelligentDetection
Start version: 5.0.0(12)
Name | Value | Description |
|---|---|---|
ES256 | 0 | SHA256withECDSA. |
detectFraudRisk(params: FraudDetectionRequest): Promise<string>
Obtains the fraud risks of a device. This API returns the result asynchronously through a promise.
System capability: SystemCapability.Security.BusinessRiskIntelligentDetection
Start version: 5.0.0(12)
Parameters:
Parameter | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Request parameters. |
Returns:
Type | Description |
|---|---|
Promise<string> | Fraud detection result, which is a JWS string encoded using Base64URL and returned through a promise. If an exception or error occurs, an error code will be returned. Fields in JWS-format Header are as follows: {
"alg": "ES256",
"x5c": ["",""]
}
Fields in JWS-format Payload are as follows: {
"timestampMs": 9xxxxxxxxx,
"nonce": "Rxxxxxxxxx",
"appId": "xxxxxxxxx",
"version": 1,
"riskScore": 90,
"tags": [
"phishing",
"malware",
"interdiction",
"control"
]
} NOTE:
|
Value of tags | Description |
|---|---|
phishing | Over the past period, a device was involved in one or more of the following activities that led to fraudulent information: Answered fraudulent calls Received fraudulent SMS messages Clicked fraudulent URLs in SMS messages from unknown senders |
malware | Over the past period, apps that might be used for fraudulent activities were installed on a device. These apps include: Fraudulent order apps Finance apps Video conferencing apps Apps with the remote control function |
interdiction | A device is preventing the user from receiving calls because the device is in one of the following states: Call forwarding enabled Airplane mode on Currently in a voice call Currently in a video call |
control | A device may be at risk of being manipulated due to the following reasons: Screen sharing enabled Remote assistance enabled |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Message |
|---|---|
401 | Invalid parameters. |
1012500001 | Internal error. |
1012500002 | The network is unreachable. |
1012500003 | Access cloud server fail. |
1012500004 | Verify cloud capability fail. |
Example:
import { businessRiskIntelligentDetection } from '@kit.DeviceSecurityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG = "[BusinessRiskIntelligentDetectionModel]";
let params = {
nonce : xxxxxxx, // TODO(developer): Change the value of nonce to a random value generated by the server.
algorithm: businessRiskIntelligentDetection.SigningAlgorithm.ES256
} as businessRiskIntelligentDetection.FraudDetectionRequest;
try {
hilog.info(0x0000, TAG, 'Detect fraud risk begin.');
businessRiskIntelligentDetection.detectFraudRisk(params).then((result: string) => {
// Indicates communication with the service was successful.
// Use result to get the result data.
hilog.info(0x0000, TAG, 'Detect fraud risk success: %{public}s', result);
}).catch((error: Error) => {
// An error occurred while communicating with the service.
let e: BusinessError = error as BusinessError;
hilog.error(0x0000, TAG, 'Detect fraud risk failed: %{public}d %{public}s', e.code, e.message);
});
} catch (error) {
// An error occurred while using api.
let e: BusinessError = error as BusinessError;
hilog.error(0x0000, TAG, 'Detect fraud risk failed: %{public}d %{public}s', e.code, e.message);
}