npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-mock-gps-detector

v1.1.0

Published

Production-grade React Native library for detecting mocked, spoofed, or tampered GPS location signals on Android and iOS.

Readme

react-native-mock-gps-detector

npm version license Platform

Production-grade, zero-config-by-default React Native library designed to detect mocked, spoofed, or tampered GPS location signals on Android and iOS. Built with TurboModule Codegen (New Architecture) and full backward compatibility for the Old Architecture.


🌟 Key Features

  • Weighted Confidence Scoring (0–100): Avoid fragile binary booleans. Returns a calculated trust score along with specific triggered risk reasons.
  • Android Multi-Signal Detection:
    • OS Location mock flags (Location.isMock() on API 31+, Location.isFromMockProvider() on API 18+).
    • AppOps OPSTR_MOCK_LOCATION permission check.
    • Package Manager visibility scans for known Fake GPS apps (<queries> support).
    • Advanced Root checks (covering /system/xbin/su, KernelSU, APatch, test-keys).
    • Magisk mount point & LSPosed framework stack detection.
    • QEMU & Android Emulator hardware property heuristics.
    • Developer options & ADB debugging state check.
    • Google Play Integrity hardware attestation helper.
  • iOS Multi-Signal Detection:
    • Rootful & Rootless jailbreak heuristics (/var/jb, Dopamine, Palera1n, sandbox violation write tests, process fork tests).
    • Dynamic library injection inspection (_dyld_get_image_name) for spoofing tweaks (MobileSubstrate, ElleKit, Shadow, LocationFaker).
    • sysctl P_TRACED debugger detection.
    • Simulator environment detection.
    • Apple App Attest support check.
  • Expo Compatible: Zero-config plugin (app.plugin.js) for Expo Prebuild / EAS Build.

🛠️ Installation

npm install react-native-mock-gps-detector
# or
yarn add react-native-mock-gps-detector

iOS Setup

Run pod install inside the ios directory:

cd ios && pod install

Expo Setup

Add the plugin to your app.json or app.config.js:

{
  "expo": {
    "plugins": ["react-native-mock-gps-detector"]
  }
}

🚀 Quick Usage

1. One-Shot Boolean Check

import { isMockLocation } from 'react-native-mock-gps-detector';

async function checkLocation() {
  const isMocked = await isMockLocation();
  if (isMocked) {
    console.warn('⚠️ Warning: Location spoofing detected!');
  }
}

2. Comprehensive Detection Result

import { getDetectionResult } from 'react-native-mock-gps-detector';

async function evaluateSecurity() {
  const result = await getDetectionResult({ confidenceThreshold: 60 });

  console.log('Confidence Score:', result.confidence); // 0 (Fake) - 100 (Genuine)
  console.log('Is Mock Location:', result.isMockLocation);

  result.reasons.forEach((reason) => {
    console.log(`- [${reason.code}] Weight: ${reason.weight}: ${reason.description}`);
  });
}

3. React Hook (Continuous Monitoring)

import React from 'react';
import { View, Text } from 'react-native';
import { useMockLocationDetector } from 'react-native-mock-gps-detector';

export function LocationGuardComponent() {
  const result = useMockLocationDetector({ intervalMs: 10000, confidenceThreshold: 60 });

  if (!result) {
    return <Text>Evaluating location trust...</Text>;
  }

  return (
    <View>
      <Text>Trust Score: {result.confidence} / 100</Text>
      <Text>Location Status: {result.isMockLocation ? 'SPOOFED' : 'GENUINE'}</Text>
    </View>
  );
}

---

## 📖 API Reference

### `isMockLocation(): Promise<boolean>`
Fast one-shot check returning whether confidence score is below threshold (default 60).

### `getDetectionResult(options?: MonitoringOptions): Promise<DetectionResult>`
Returns a full diagnostic breakdown containing:
- `isMockLocation`: boolean
- `confidence`: number (0 to 100)
- `reasons`: Array of `{ code, weight, description }`
- `platform`: `'android'` | `'ios'`
- `android`: Android-specific indicators
- `ios`: iOS-specific indicators

### `startMonitoring(options?: MonitoringOptions): Promise<boolean>`
Starts native background timer polling at specified `intervalMs` (default: 10000ms) emitting `onDetectionUpdate` and `onMockLocationDetected` events.

### `stopMonitoring(): Promise<boolean>`
Stops the native background monitoring timer.

### `showMockLocationNotification(title?: string, message?: string): Promise<boolean>`
Triggers a High-Priority OS-level system notification (`NotificationChannel` on Android, `UNUserNotificationCenter` on iOS) alerting the user of mock location spoofing.

---

## 🛡️ Honest Security Statement & Best Practices

No client-side security signal is unbeatable against a root/kernel-level attacker using sophisticated tools like Magisk Hide, LSPosed, or hardware GPS simulators.

This library is designed to **raise the cost of spoofing** and catch >95% of casual and semi-sophisticated location fakers. For high-security applications (ride-hailing fare calculation, payroll attendance, anti-fraud geofencing), we recommend a multi-layered security posture:

1. **Client Heuristics (This Library):** Rapid, offline, zero-latency detection.
2. **Hardware Attestation:** Google Play Integrity & Apple App Attest tokens verified on your backend server.
3. **Server Behavioral Analysis:** Plausibility checks (speed, teleportation, clock drift audit).

---

## 📄 License

MIT License © 2026 Vijay