@capacitor-community/device-security-detect

中文文档
8.0.0发布于 2026/01/05MITTypeScriptESM + CJS零依赖近 30 天下载 3.3万

The Device Security Detect plugin is designed to provide comprehensive device security detection capabilities for Capacitor-based applications. It aims to detect the device has been rooted (Android) or jailbroken (iOS). By using this plugin, developers ca

原始使用文档
文档目录13 节
  1. Device Security Detect Plugin
  2. Table of Contents
  3. Maintainers
  4. Plugin versions
  5. Supported Platforms
  6. Installation
  7. API
  8. isJailBreakOrRooted()
  9. pinCheck()
  10. Usage
  11. Detect if the device has been rooted (Android) or jailbroke…
  12. Check if a PIN, password, or biometric authentication is en…
  13. Full Example


Device Security Detect Plugin

@capacitor-community/device-security-detect

The Device Security Detect plugin is designed to provide comprehensive device security detection capabilities for Capacitor-based applications. It aims to detect the device has been rooted (Android) or jailbroken (iOS). By using this plugin, developers can enhance the security of their applications and take appropriate actions based on the detected security status.


Table of Contents

Maintainers

MaintainerGitHubActive
4ooper4ooperyes
ryaaryaayes

Plugin versions

Capacitor versionPlugin version
7.x7.x
6.x6.x

Supported Platforms

  • iOS
  • Android

Installation

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

Using yarn:

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

Sync native files:

npx cap sync

API

isJailBreakOrRooted()

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

Detect if the device has been rooted (Android) or jailbroken (iOS).

This method provides a boolean value indicating whether the device has been tampered with (e.g., by rooting or jailbreaking).

Returns: Promise<{ value: boolean; }>

Since: 6.0.0


pinCheck()

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

Check if a PIN, password, or biometric authentication is enabled on the device.

This method checks whether the user has set up any kind of secure lock mechanism (e.g., PIN, password, or biometric authentication) on their mobile device.

Returns: Promise<{ value: boolean; }>

Since: 6.0.2


Usage

Detect if the device has been rooted (Android) or jailbroken (iOS)

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.');
  }
}

Check if a PIN, password, or biometric authentication is enabled on the device

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.');
  }
}

Full Example

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();

or please see example-app for a complete example.

Use this plugin to enhance your application's security and respond appropriately to potential risks.

版本与发布记录

@capacitor-community/device-security-detect 共发布 4 个版本,首次发布于 2024/12/09;过去 12 个月发布了 1 个版本。

版本发布日期距今
8.0.0latest2026/01/0510 个月前
7.0.02025/05/261.5 年前
6.0.12024/12/181.9 年前
6.0.02024/12/091.9 年前

关于 @capacitor-community/device-security-detect 的常见问题

@capacitor-community/device-security-detect 是什么?

The Device Security Detect plugin is designed to provide comprehensive device security detection capabilities for Capacitor-based applications. It aims to detect the device has been rooted (Android) or jailbroken (iOS). By using this plugin, developers 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 和提交记录判断。