# @capacitor-community/device-security-detect 中文文档

规范地址：https://npmcn.com/package/%40capacitor-community/device-security-detect/

版本：8\.0\.0
npm 元数据更新时间：2026-10-23T21:47:48.197Z
中文译文更新时间：2026-11-09T04:19:03.357Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40capacitor-community/device-security-detect
原文对照：https://npmcn.com/package/%40capacitor-community/device-security-detect/?lang=original
项目主页：https://github.com/capacitor-community/device-security-detect#readme
源码仓库：https://github.com/capacitor-community/device-security-detect

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：50 kB，28 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=16\.0\.0
- 运行依赖：0 个
- peer 依赖：@capacitor/core \>=8\.0\.0
- 首次发布：2024-12-09T08:40:58.000Z
- 最新版本发布：2026-01-05T12:34:18.144Z
- 近 30 天下载量：33316（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 1 个）

## 中文简介

设备安全检测插件旨在为基于Capacitor的应用提供综合设备安全检测能力. 它旨在检测该装置已经被植入(Android)或被困(iOS). 通过使用此插件, 开发者 ca

## 安装

```sh
npm install @capacitor-community/device-security-detect
```

也可以使用：`pnpm add @capacitor-community/device-security-detect`、`yarn add @capacitor-community/device-security-detect`、`bun add @capacitor-community/device-security-detect`

## README

  
![](https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png)

### 设备安全检测插件

**`@capacitor-community/device-security-detect`**

设备安全检测插件旨在为基于Capacitor的应用提供综合设备安全检测能力. 它旨在检测该装置已经被植入(Android)或被困(iOS). 通过使用这个插件,开发者可以加强其应用程序的安全性,并根据检测出的安全性状态采取适当的行动.

![](https://img.shields.io/maintenance/yes/2026?style=flat-square) [![](https://img.shields.io/npm/l/@capacitor-community/device-security-detect?style=flat-square)](https://www.npmjs.com/package/@capacitor-community/device-security-detect)  
[![](https://img.shields.io/npm/dw/@capacitor-community/device-security-detect?style=flat-square)](https://www.npmjs.com/package/@capacitor-community/device-security-detect) [![](https://img.shields.io/npm/v/@capacitor-community/device-security-detect?style=flat-square)](https://www.npmjs.com/package/@capacitor-community/device-security-detect) [![](https://img.shields.io/badge/all%20contributors-2-orange?style=flat-square)](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-contributors-)

## 目录

-   [维护者](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-maintainers)
-   [插件版本](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-plugin-versions)
-   [支持的平台](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-supported-platforms)
-   [安装](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-installation)
-   [API 密码](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-api)
-   [使用量](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-usage)

## 维护者

| 维护者 | GitHub 图像 | 活动 |
| --- | --- | --- |
| 4ooper 密码 | [4ooper 密码](https://github.com/4ooper) | 对 |
| 尼亚a | [尼亚a](https://github.com/ryaa) | 对 |

## 插件版本

| 电容版本 | 插件版本 |
| --- | --- |
| 7.x 电话 | 7.x 电话 |
| 6.x (单位:千美元) | 6.x (单位:千美元) |

## 支持的平台

-   iOS系统
-   机器人

## 安装

```bash
npm install @capacitor-community/device-security-detect
npx cap sync
```

使用线条 :

```bash
yarn add @capacitor-community/device-security-detect
```

同步本地文件 :

```bash
npx cap sync
```

## API 密码

-   [`isJailBreakOrRooted()`](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-isjailbreakorrooted)
-   [`pinCheck()`](https://npmcn.com/package/%40capacitor-community/device-security-detect/#readme-pincheck)

### 是JailBreak OrRooted () (中文(简体) )

```typescript
isJailBreakOrRooted() => Promise<{ value: boolean; }>
```

检测设备是否已经被植入(Android)或被困(iOS).

这种方法提供了一个布尔值,表示设备是否 被篡改(例如通过打根或越狱).

**回返情况:** `Promise<{ value: boolean; }>`

**自:** 6.0.0 (单位:千美元)

* * *

### 检查( C)

```typescript
pinCheck() => Promise<{ value: boolean; }>
```

检查设备上是否启用了PIN,密码或生物鉴别认证.

这种方法检查用户是否设置了任何类型的安全锁机制 其移动设备(如PIN,密码,或生物鉴别认证).

**回返情况:** `Promise<{ value: boolean; }>`

**自:** 6.0.2 (单位:千美元)

* * *

## 使用量

### 检测设备是否已经被植入(Android)或被囚禁(iOS)

```typescript
import { DeviceSecurityDetect } from '@capacitor-community/device-security-detect';

async function checkRootStatus() {
  const { value } = await DeviceSecurityDetect.isJailBreakOrRooted();
  if (value) {
    console.warn('The device is rooted or jailbroken!');
  } else {
    console.log('The device is secure.');
  }
}
```

### 检查设备上是否启用了 PIN、 密码或生物鉴别认证

```typescript
import { DeviceSecurityDetect } from '@capacitor-community/device-security-detect';

async function checkPinStatus() {
  const { value } = await DeviceSecurityDetect.pinCheck();
  if (value) {
    console.log('A secure lock mechanism is enabled on the device.');
  } else {
    console.warn('No secure lock mechanism is detected.');
  }
}
```

### 完整示例

```typescript
import { DeviceSecurityDetect } from '@capacitor-community/device-security-detect';

const { value } = await DeviceSecurityDetect.isJailBreakOrRooted();
async function checkDeviceSecurity() {
  try {
    const rootStatus = await DeviceSecurityDetect.isJailBreakOrRooted();
    console.log(`Root/Jailbreak status: ${rootStatus.value ? 'Yes' : 'No'}`);

    const pinStatus = await DeviceSecurityDetect.pinCheck();
    console.log(`Secure lock enabled: ${pinStatus.value ? 'Yes' : 'No'}`);
  } catch (error) {
    console.error('Error checking device security:', error);
  }
}

checkDeviceSecurity();
```

或者请看 **示例应用程序** 一个完整的例子.

使用此插件可以增强应用程序的安全性,并适当应对潜在风险.

## 常见问题

### @capacitor-community/device-security-detect 是什么？

设备安全检测插件旨在为基于Capacitor的应用提供综合设备安全检测能力\. 它旨在检测该装置已经被植入\(Android\)或被困\(iOS\)\. 通过使用此插件, 开发者 ca

### 如何安装 @capacitor-community/device-security-detect？

在项目目录运行 npm install @capacitor-community/device-security-detect，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@capacitor/core（\>=8\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @capacitor-community/device-security-detect 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @capacitor-community/device-security-detect 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @capacitor-community/device-security-detect 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=16\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @capacitor-community/device-security-detect 可以商用吗？

@capacitor-community/device-security-detect 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @capacitor-community/device-security-detect 的下载量有多少？

根据 npm 官方下载统计，@capacitor-community/device-security-detect 在 2026/10/09 – 2026/11/07 这 30 天内被下载 33,316 次，日均约 1,111 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @capacitor-community/device-security-detect 还在维护吗？

最新版本 8\.0\.0 发布于 2026/01/05（10 个月前）；至今共发布 4 个版本，其中过去 12 个月发布了 1 个；首次发布于 2024/12/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

