XuqmGroup-RNSDK/packages/license/README.md

60 行
1.3 KiB
Markdown

# @xuqm/rn-license
XuqmGroup RN SDK 证书授权模块。提供设备 License 验证能力。
## 安装
```bash
yarn add @xuqm/rn-license react-native-quick-crypto
```
Peer dependencies`react-native >= 0.76`,`@react-native-async-storage/async-storage >= 1.21.0`,`react-native-quick-crypto >= 0.7.0`
## 使用
**无需独立初始化。** 内部自动调用 `awaitInitialization()` 等待 `XuqmSDK` 就绪。
```ts
import { checkLicense, getStatus, clear } from '@xuqm/rn-license'
// 验证 License
const result = await checkLicense()
if (result.type === 'success') {
console.log('License 通过:', result.reason)
} else {
console.error('License 失败:', result.message)
}
// 获取状态
const status = await getStatus() // 'ok' | 'denied' | 'unknown'
// 清除本地缓存(调试用)
await clear()
```
## API
| API | 说明 |
|-----|------|
| `checkLicense(userInfo?)` | 验证设备 License |
| `getStatus()` | 获取当前 License 状态 |
| `getDeviceId()` | 获取设备 ID |
| `clear()` | 清除本地 License 缓存 |
## 类型
```ts
interface LicenseUserInfo {
userId?: string
userSig?: string
}
type LicenseStatus = 'ok' | 'denied' | 'unknown'
interface LicenseResult {
type: 'success' | 'denied' | 'error'
reason?: string
message?: string
}
```