{"_id":"@aliakhgar1/react-native-control-tower","_rev":"3-78695354cf6164a016873d224172f080","name":"@aliakhgar1/react-native-control-tower","dist-tags":{"latest":"1.2.1"},"versions":{"1.1.0":{"name":"@aliakhgar1/react-native-control-tower","version":"1.1.0","keywords":["react-native","ios","android"],"author":{"url":"https://github.com/AliAkhgar","name":"Ali Akhgar","email":"theakhgar@gmail.com"},"license":"MIT","_id":"@aliakhgar1/react-native-control-tower@1.1.0","maintainers":[{"name":"aliakhgar","email":"theakhgar@gmail.com"}],"homepage":"https://github.com/AliAkhgar/react-native-control-tower#readme","bugs":{"url":"https://github.com/AliAkhgar/react-native-control-tower/issues"},"dist":{"shasum":"861527ad09cb2f6d9d47fe3c165df5e257977aa5","tarball":"https://registry.npmjs.org/@aliakhgar1/react-native-control-tower/-/react-native-control-tower-1.1.0.tgz","fileCount":10,"integrity":"sha512-fsZXUNphoXKnXFn5diIzsRvnpG/arF1JtD+7Ti9SdW28Cex4d/9j4OB2LRnEp1BbdWMaUPvtgDfKY2cykELOdw==","signatures":[{"sig":"MEQCIHQOw3GBe1SZaiXjuFAPCu5sn7r9BnNlvBwT/SxETDgyAiAMyKzACIjcYy/NxHLsRC1B72HlqEvOdWLAwfqEZnF3cA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16482},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"main":"./lib/module/index.js","types":"./lib/typescript/src/index.d.ts","exports":{".":{"types":"./lib/typescript/src/index.d.ts","source":"./src/index.tsx","default":"./lib/module/index.js"},"./package.json":"./package.json"},"gitHead":"dbd3428d4974ee8b8176c95a2957da25aad14c7a","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"jest","clean":"del-cli lib","example":"yarn workspace react-native-control-tower-example","prepare":"bob build","release":"release-it --only-version","typecheck":"tsc","semantic-release":"semantic-release"},"_npmUser":{"name":"aliakhgar","email":"theakhgar@gmail.com"},"prettier":{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":{"name":"angular"}}}},"repository":{"url":"git+https://github.com/AliAkhgar/react-native-control-tower.git","type":"git"},"workspaces":["example"],"_npmVersion":"10.9.3","description":"Control Tower","directories":{},"_nodeVersion":"20.19.4","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"packageManager":"yarn@3.6.1","devDependencies":{"jest":"^29.7.0","react":"19.0.0","eslint":"^9.22.0","del-cli":"^5.1.0","prettier":"^3.0.3","@eslint/js":"^9.22.0","commitlint":"^19.6.1","release-it":"^17.10.0","typescript":"^5.8.3","@types/jest":"^29.5.5","@types/react":"^19.0.12","react-native":"0.79.5","@eslint/compat":"^1.2.7","@eslint/eslintrc":"^3.3.0","semantic-release":"^24.2.7","@evilmartians/lefthook":"^1.5.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.3","react-native-builder-bob":"^0.40.8","@react-native/babel-preset":"0.78.2","@react-native/eslint-config":"^0.78.0","@commitlint/config-conventional":"^19.6.0","@release-it/conventional-changelog":"^9.0.2"},"peerDependencies":{"react":"*","react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/react-native-control-tower_1.1.0_1754168186759_0.3497337564632763","host":"s3://npm-registry-packages-npm-production"},"react-native-builder-bob":{"output":"lib","source":"src","targets":[["module",{"esm":true}],["typescript",{"project":"tsconfig.build.json"}]]},"create-react-native-library":{"type":"library","version":"0.52.0","languages":"js"}},"1.2.0":{"name":"@aliakhgar1/react-native-control-tower","version":"1.2.0","keywords":["react-native","ios","android"],"author":{"url":"https://github.com/AliAkhgar","name":"Ali Akhgar","email":"theakhgar@gmail.com"},"license":"MIT","_id":"@aliakhgar1/react-native-control-tower@1.2.0","maintainers":[{"name":"aliakhgar","email":"theakhgar@gmail.com"}],"homepage":"https://github.com/AliAkhgar/react-native-control-tower#readme","bugs":{"url":"https://github.com/AliAkhgar/react-native-control-tower/issues"},"dist":{"shasum":"5681ffb5c4071ab32bfc50b60d814a23909a33b0","tarball":"https://registry.npmjs.org/@aliakhgar1/react-native-control-tower/-/react-native-control-tower-1.2.0.tgz","fileCount":10,"integrity":"sha512-Ml8k/It/2QKI97TpkD+l42a13OJo5AYKcmOcPopaxHhQhsTb0/pI4zGTMIe4IxFfPGOqqrUUfkR1JuMwm8gIWw==","signatures":[{"sig":"MEQCIA6iRGutA6Rjf4y9PethWV1sX5FJ9tPWxqs8ZBz5UDd5AiAA4qrrGtF8qw/rCTdBU+YajtgJE/rwuhIsMBeIwEep0A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17729},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"main":"./lib/module/index.js","types":"./lib/typescript/src/index.d.ts","exports":{".":{"types":"./lib/typescript/src/index.d.ts","source":"./src/index.tsx","default":"./lib/module/index.js"},"./package.json":"./package.json"},"gitHead":"1e85418b4be15eefbf332a1e5c7909ad9568a00e","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"jest","clean":"del-cli lib","example":"yarn workspace react-native-control-tower-example","prepare":"bob build","release":"release-it --only-version","typecheck":"tsc","semantic-release":"semantic-release"},"_npmUser":{"name":"aliakhgar","email":"theakhgar@gmail.com"},"prettier":{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":{"name":"angular"}}}},"repository":{"url":"git+https://github.com/AliAkhgar/react-native-control-tower.git","type":"git"},"workspaces":["example"],"_npmVersion":"10.9.3","description":"Control Tower for VPN Applications","directories":{},"_nodeVersion":"20.19.4","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"packageManager":"yarn@3.6.1","devDependencies":{"jest":"^29.7.0","react":"19.0.0","eslint":"^9.22.0","del-cli":"^5.1.0","prettier":"^3.0.3","@eslint/js":"^9.22.0","commitlint":"^19.6.1","release-it":"^17.10.0","typescript":"^5.8.3","@types/jest":"^29.5.5","@types/react":"^19.0.12","react-native":"0.79.5","@eslint/compat":"^1.2.7","@eslint/eslintrc":"^3.3.0","semantic-release":"^24.2.7","@evilmartians/lefthook":"^1.5.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.3","react-native-builder-bob":"^0.40.8","@react-native/babel-preset":"0.78.2","@react-native/eslint-config":"^0.78.0","@commitlint/config-conventional":"^19.6.0","@release-it/conventional-changelog":"^9.0.2"},"peerDependencies":{"react":"*","react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/react-native-control-tower_1.2.0_1754169283128_0.2315983228232661","host":"s3://npm-registry-packages-npm-production"},"react-native-builder-bob":{"output":"lib","source":"src","targets":[["module",{"esm":true}],["typescript",{"project":"tsconfig.build.json"}]]},"create-react-native-library":{"type":"library","version":"0.52.0","languages":"js"}},"1.2.1":{"name":"@aliakhgar1/react-native-control-tower","version":"1.2.1","description":"Control Tower for VPN Applications","main":"./lib/module/index.js","types":"./lib/typescript/src/index.d.ts","exports":{".":{"source":"./src/index.tsx","types":"./lib/typescript/src/index.d.ts","default":"./lib/module/index.js"},"./package.json":"./package.json"},"scripts":{"example":"yarn workspace react-native-control-tower-example","test":"jest","typecheck":"tsc","lint":"eslint \"**/*.{js,ts,tsx}\"","clean":"del-cli lib","prepare":"bob build","release":"release-it --only-version","semantic-release":"semantic-release"},"keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/AliAkhgar/react-native-control-tower.git"},"author":{"name":"Ali Akhgar","email":"theakhgar@gmail.com","url":"https://github.com/AliAkhgar"},"license":"MIT","bugs":{"url":"https://github.com/AliAkhgar/react-native-control-tower/issues"},"homepage":"https://github.com/AliAkhgar/react-native-control-tower#readme","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"devDependencies":{"@commitlint/config-conventional":"^19.6.0","@eslint/compat":"^1.2.7","@eslint/eslintrc":"^3.3.0","@eslint/js":"^9.22.0","@evilmartians/lefthook":"^1.5.0","@react-native/babel-preset":"0.78.2","@react-native/eslint-config":"^0.78.0","@release-it/conventional-changelog":"^9.0.2","@types/jest":"^29.5.5","@types/react":"^19.0.12","commitlint":"^19.6.1","del-cli":"^5.1.0","eslint":"^9.22.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.3","jest":"^29.7.0","prettier":"^3.0.3","react":"19.0.0","react-native":"0.79.5","react-native-builder-bob":"^0.40.8","release-it":"^17.10.0","semantic-release":"^24.2.7","typescript":"^5.8.3"},"peerDependencies":{"react":"*","react-native":"*"},"workspaces":["example"],"packageManager":"yarn@3.6.1","jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"commitMessage":"chore: release ${version}","tagName":"v${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":{"name":"angular"}}}},"prettier":{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false},"react-native-builder-bob":{"source":"src","output":"lib","targets":[["module",{"esm":true}],["typescript",{"project":"tsconfig.build.json"}]]},"create-react-native-library":{"languages":"js","type":"library","version":"0.52.0"},"_id":"@aliakhgar1/react-native-control-tower@1.2.1","gitHead":"b6597a58b2205ec9940d8e089014af7f29c6239f","_nodeVersion":"20.19.4","_npmVersion":"10.9.3","dist":{"integrity":"sha512-DRtImOHEFzRHhfV3PjhPI4wRuFzeYiat+YUL8QR31wZ356CAuMh/sBjporZHYGTaZD8IRdIL4eQI1XpoP9R7Kg==","shasum":"65a434953a27f3403a8636e1c042bcf41a9cf586","tarball":"https://registry.npmjs.org/@aliakhgar1/react-native-control-tower/-/react-native-control-tower-1.2.1.tgz","fileCount":10,"unpackedSize":25010,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCUxoxptMk/EQ9OIJTZ9OB/FNK9nCIvM5ZgctqhiU9cTAIhAMv1s8pv9fjYnTcvO1wrxDl78O2rfTKeZEGvDMYcx9mh"}]},"_npmUser":{"name":"aliakhgar","email":"theakhgar@gmail.com"},"directories":{},"maintainers":[{"name":"aliakhgar","email":"theakhgar@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-control-tower_1.2.1_1754174911963_0.8236408344160473"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-02T20:56:26.636Z","modified":"2025-08-02T22:48:32.324Z","1.1.0":"2025-08-02T20:56:26.936Z","1.2.0":"2025-08-02T21:14:43.301Z","1.2.1":"2025-08-02T22:48:32.128Z"},"bugs":{"url":"https://github.com/AliAkhgar/react-native-control-tower/issues"},"author":{"name":"Ali Akhgar","email":"theakhgar@gmail.com","url":"https://github.com/AliAkhgar"},"license":"MIT","homepage":"https://github.com/AliAkhgar/react-native-control-tower#readme","keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/AliAkhgar/react-native-control-tower.git"},"description":"Control Tower for VPN Applications","maintainers":[{"name":"aliakhgar","email":"theakhgar@gmail.com"}],"readme":"<div align=\"center\">\n\n<h1>🗼 React Native Control Tower</h1>\n\n![Gemini_Generated_Image_yivo3gyivo3gyivo-2](https://github.com/user-attachments/assets/a065a676-70b0-4bab-b996-a23ead24bc88)\n\n*VPN Control & Monitoring for React Native*\n\n</div>\n\n<div align=\"center\">\n\n[![npm version](https://badge.fury.io/js/@aliakhgar1%2Freact-native-control-tower.svg)](https://badge.fury.io/js/@aliakhgar1%2Freact-native-control-tower)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![React Native](https://img.shields.io/badge/React%20Native-0.60+-blue.svg)](https://reactnative.dev/)\n\n</div>\n\n<div align=\"center\">\n\n**React Native Control Tower** is a lightweight library that provides comprehensive VPN protocol management and real-time status monitoring for React Native applications. Built with flexibility, it supports multiple VPN protocols and offers both React hooks and standalone functions for enhanced integration.\n\n</div>\n\n---\n\n## ✨ Features\n\n🚀 **Multi-Protocol Support** - Keeps track of multiple VPN protocols states  \n⚡ **Real-time Updates** - Live status monitoring with instant connection state changes  \n🪝 **React Hooks Ready** - Modern React patterns with hooks  \n🔧 **Standalone Functions** - Use outside React components with static functions  \n💪 **TypeScript Support** - Full type safety with comprehensive TypeScript definitions  \n🎯 **Lightweight** - Minimal footprint with zero external dependencies  \n🔄 **Event-Driven** - Efficient listener-based architecture for optimal performance  \n⚙️ **Easy Integration** - Simple API design for quick setup and usage  \n\n## 📦 Installation\n\n```bash\nnpm install @aliakhgar1/react-native-control-tower\n```\n\n```bash\nyarn add @aliakhgar1/react-native-control-tower\n```\n\n## 🚀 Quick Showcase\n\n### Using with React Hooks\n\n```javascript\nimport React from 'react';\nimport { View, Text } from 'react-native';\nimport * as Wireguard from 'react-native-wireguard';\nimport * as ControlTower from '@aliakhgar1/react-native-control-tower';\n\nfunction VPNStatusComponent() {\n\n  //React Hooks for Reactive Updates\n   const { \n    VPNStatuses,           // All VPN statuses object\n    VPNStatus,             // connection status type=> -1, 0, 1, 2,...\n    VPNStatusTitle,        // Human-readable status\n    connectedVpnType,      // Currently connected VPN type\n    updateVpnStatus,       // Function to update status\n    getVpnStatuses         // Function to get all statuses\n  } = ControlTower.useVpnStatuses();\n\n  React.useEffect(() => {\n\n    var WGSub = Wireguard.addWireguardStateChangeListener((WGState) => {\n      //Updating ControlTower state for Wireguard without hook functions.\n      ControlTower.updateVpnStatus('WireGuard', WGState?.state);\n    });\n\n    return () => {\n      WGSub.remove();\n    };\n  }, []);\n\n  return (\n    <View>\n      <Text>Status: {VPNStatusTitle}</Text>\n      <Text>Connected VPN: {connectedVpnType || 'None'}</Text>\n    </View>\n  );\n}\n```\n\n### Using Outside React Components\n\n```javascript\nimport * as ControlTower from '@aliakhgar1/react-native-control-tower';\n\n// Update VPN status\nControlTower.updateVpnStatus('WireGuard', ControlTower.ConnectionStatus.CONNECTED);\n\n// Get current status\nconst status = ControlTower.getVpnConnectionStatus();\nconst statusTitle = ControlTower.getVpnConnectionStatusTitle();\nconst activeVPN = ControlTower.getConnectedVpnType();\n\nconsole.log(`Status: ${statusTitle}, Active VPN: ${activeVPN}`);\n```\n\n## 📚 Complete Usage Guide\n\n### 📡 Integration with VPN Libraries\n\nHere's how to integrate with popular VPN libraries:\n\n#### Connection Status Natively Compatible Event Integration\n\nHere, Wireguard addWireguardStateChangeListener sends the compatible types to Control Tower by default.\n\n```javascript\nimport * as Wireguard from 'react-native-wireguard';\nimport * as ControlTower from '@aliakhgar1/react-native-control-tower';\n\n// Listen to WireGuard state changes\nconst WGSub = Wireguard.addWireguardStateChangeListener((WGState) => {\n  ControlTower.updateVpnStatus('WireGuard', WGState?.state);\n});\n\n// Don't forget to clean up\n// WGSub.remove();\n```\n\n#### Abstract Event Data Integration\n\nIn this case, you will need to convert the VPN client status to a compatible status which Control Tower accepts.\n\n```javascript\nimport OpenVPN from 'react-native-openvpn';\nimport * as ControlTower from '@aliakhgar1/react-native-control-tower';\n\nOpenVPN.addVpnStateListener((state) => {\n  // Map OpenVPN states to Control Tower states\n  let controlTowerState;\n  switch (state.state) {\n    case 'CONNECTED':\n      controlTowerState = ControlTower.ConnectionStatus.CONNECTED;\n      break;\n    case 'CONNECTING':\n      controlTowerState = ControlTower.ConnectionStatus.CONNECTING;\n      break;\n    case 'DISCONNECTING':\n      controlTowerState = ControlTower.ConnectionStatus.DISCONNECTING;\n      break;\n    default:\n      controlTowerState = ControlTower.ConnectionStatus.DISCONNECTED;\n  }\n  \n  ControlTower.updateVpnStatus('OpenVPN', controlTowerState);\n});\n```\n\n\n### 🎯 Supported VPN Protocols\n\nControl Tower supports these VPN protocols out of the box:\n\n- **WireGuard** - Modern, fast, and secure VPN protocol\n- **OpenVPN** - Industry-standard VPN protocol\n- **IKEv2** - Internet Key Exchange version 2\n- **OpenConnect** - SSL VPN client\n- **L2TP** - Layer 2 Tunneling Protocol\n- **PPTP** - Point-to-Point Tunneling Protocol\n- **SSTP** - Secure Socket Tunneling Protocol\n- **SoftEther** - Multi-protocol VPN software\n- **V2Ray** - Platform for building proxies\n- **SSH** - Secure Shell tunneling\n- **SingBox** - Universal proxy platform\n\n### 🔗 Connection States\n\nThis is the map of compatible statues which Control Tower accepts and sends back as status.\n\n```javascript\nimport { ConnectionStatus } from '@aliakhgar1/react-native-control-tower';\n\n// Available connection states:\nConnectionStatus.DISCONNECTED  // '0' - Not connected\nConnectionStatus.DISCONNECTING // '1' - Disconnecting\nConnectionStatus.CONNECTING    // '2' - Connecting\nConnectionStatus.CONNECTED     // '3' - Connected\nConnectionStatus.INVALID       // '-1' - Invalid state\nConnectionStatus.ERROR         // '-2' - Error occurred\n```\n\n\n\n### 🔧 Standalone Functions\n\nUse Control Tower outside React components:\n\n```javascript\nimport * as ControlTower from '@aliakhgar1/react-native-control-tower';\n\n// Update any VPN status\nControlTower.updateVpnStatus('V2Ray', ControlTower.ConnectionStatus.CONNECTED);\nControlTower.updateVpnStatus('OpenVPN', ControlTower.ConnectionStatus.CONNECTING);\n\n// Get overall connection status\nconst overallStatus = ControlTower.getVpnConnectionStatus();\nconsole.log('Overall Status:', overallStatus); // '3' if any VPN is connected\n\n// Get human-readable status title\nconst statusTitle = ControlTower.getVpnConnectionStatusTitle();\nconsole.log('Status Title:', statusTitle); // 'CONNECTED', 'CONNECTING', etc.\n\n// Get currently connected VPN type\nconst activeVPN = ControlTower.getConnectedVpnType();\nconsole.log('Active VPN:', activeVPN); // 'V2Ray' or undefined\n\n// Get all VPN statuses\nconst allStatuses = ControlTower.getVpnStatuses();\nconsole.log('All Statuses:', allStatuses);\n/* Output:\n{\n  OpenConnect: '0',\n  OpenVPN: '2',\n  Ikev2: '0',\n  WireGuard: '0',\n  // ... other protocols\n  V2Ray: '3',\n  // ...\n}\n*/\n```\n\n## 📖 API Reference\n\nFor complete API documentation including hooks, functions, types, and usage examples, see:\n\n👉 **[API Reference](./API_REFERENCE.md)**\n\nThe API Reference includes:\n- React hooks (`useVpnStatuses`)\n- Standalone functions (`updateVpnStatus`, `getVpnConnectionStatus`, etc.)\n- TypeScript type definitions (`VpnType`, `ConnectionStatus`)\n- Complete usage examples and patterns\n\n## 📄 License\n\nMIT © [Ali Akhgar](https://github.com/AliAkhgar)\n","readmeFilename":"README.md"}