Integration Requirements
Environment Requirements
| Description | |
|---|---|
| Compatible Version | API 12 and above |
| Supported Architectures | arm64-v8a, x86_64 |
Integration Steps
Installation Configuration
Installation Instructions
ohpm install @trustdecision/apisign
Integrate the SDK
Set the third-party package dependency in the project's oh-package.json5 file. A configuration example is as follows:
"dependencies": {
"@trustdecision/apisign": "1.0.1"
}API Signature
Method Definition
public static sign(path: string): TDAPISignResult;Structure Definition
export class TDAPISignResult {
// Signature result
signature: string
// Signature status code
code: number
// Exception information
message: string
constructor(sign: string, code: number, msg: string) {
this.signature = sign
this.code = code
this.message = msg
}
}Best Practices
An API to be protected is in the form: <https://sg.apitd.net/de/v1?name=jacky&age=12>
import { TDAPISign } from "@trustdecision/apisign"
const signResult = TDAPISign.sign('de/v1')
if (signResult.code === 0) {
// Obtain the signature and use it
const signature: string = signResult.signature
} else {
// Obtain error information and status code
const message: string = signResult.message
const code: number = signResult.code
// Continue with business logic; the signature can be replaced with an empty string here
}Status Check
The signature is successful if the status code obtained from the returned structure is 0.
TDAPISignResult.code === 0Status Codes
| Error Code | Error Message | Handling Method |
|---|---|---|
| 0 | Success | / |
| 2000 | path is empty | Please set the path parameter |
| 22xx | Internal error | Please contact TD technical support |
| 5001 | Failed to call the so file; the so file dependent on the SDK may be missing | Please check if the architecture of the current device is configured in the project |
