{"_id":"@aarav-shukla/secure-visibility-api","name":"@aarav-shukla/secure-visibility-api","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aarav-shukla/secure-visibility-api","version":"1.0.0","description":"Protect Electron app content from being captured, recorded, or screen-shared.","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build","install":"node-gyp rebuild --arch=x64"},"keywords":["electron","security","privacy","capture-protection","screenshot","screen-share"],"author":{"name":"Aarav Shukla"},"license":"MIT","dependencies":{"bindings":"^1.5.0","node-addon-api":"^7.1.0"},"devDependencies":{"typescript":"^5.3.3","node-gyp":"^10.3.1"},"_id":"@aarav-shukla/secure-visibility-api@1.0.0","gitHead":"a91cb3a6df43bb0d3d1d16f035821083b7b1daeb","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-7UB8lj7mlvgI028KlPX5WQ5FhY54VIeEs/IGnYCF7XpoPEeqB+vWZA/uI4Ue+sR3GGr6g78lRHNO08xJWXcn+g==","shasum":"7fa1a400cdb211b7cb049bdea4c0fd7afc1c5358","tarball":"https://registry.npmjs.org/@aarav-shukla/secure-visibility-api/-/secure-visibility-api-1.0.0.tgz","fileCount":16,"unpackedSize":26385,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCJdJp1DS5iVSrtlix7P22gXkfaZ/C8m/DiFO2xBKUK+wIhALmNwGeql5OvE6jVdRNZMIX751Sw3oHYXynJwaYRSn1t"}]},"_npmUser":{"name":"aarav-shukla","email":"aarav.shukla105@gmail.com"},"directories":{},"maintainers":[{"name":"aarav-shukla","email":"aarav.shukla105@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/secure-visibility-api_1.0.0_1760683930993_0.6939318149115823"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-17T06:52:10.871Z","1.0.0":"2025-10-17T06:52:11.168Z","modified":"2025-10-17T06:52:11.487Z"},"maintainers":[{"name":"aarav-shukla","email":"aarav.shukla105@gmail.com"}],"description":"Protect Electron app content from being captured, recorded, or screen-shared.","keywords":["electron","security","privacy","capture-protection","screenshot","screen-share"],"author":{"name":"Aarav Shukla"},"license":"MIT","readme":"# Secure Visibility API\r\n\r\nA cross-platform API for preventing screen capture and recording in Electron applications. This library allows developers to protect sensitive content from being captured during screen sharing, recording, or other screen capture scenarios.\r\n\r\n## 🚀 Features\r\n\r\n- **Cross-Platform Support**: Windows (✅), macOS (🚧), Linux (🚧)\r\n- **Easy Integration**: Simple TypeScript/JavaScript API\r\n- **Native Performance**: Direct OS-level API integration\r\n- **Privacy Protection**: Prevents content from appearing in screen captures\r\n- **Reversible**: Can enable/disable protection dynamically\r\n\r\n## 📋 Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Quick Start](#quick-start)\r\n- [API Reference](#api-reference)\r\n- [Platform Support](#platform-support)\r\n- [Examples](#examples)\r\n- [Building from Source](#building-from-source)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n## 🛠 Installation\r\n\r\n```bash\r\nnpm install secure-visibility-api\r\n```\r\n\r\n### Prerequisites\r\n\r\n- Node.js 14.0.0 or higher\r\n- Electron 10.0.0 or higher\r\n- Platform-specific build tools (see [Building from Source](#building-from-source))\r\n\r\n## 🚀 Quick Start\r\n\r\n```typescript\r\nimport { preventCapture, allowCapture, isCapturePrevented } from 'secure-visibility-api';\r\nimport { BrowserWindow } from 'electron';\r\n\r\n// Create your Electron window\r\nconst mainWindow = new BrowserWindow({\r\n  width: 800,\r\n  height: 600,\r\n  webPreferences: {\r\n    nodeIntegration: true,\r\n    contextIsolation: false\r\n  }\r\n});\r\n\r\n// Get the native window handle\r\nconst hwnd = mainWindow.getNativeWindowHandle();\r\n\r\n// Prevent screen capture\r\ntry {\r\n  const success = preventCapture(hwnd);\r\n  if (success) {\r\n    console.log('Screen capture prevention enabled');\r\n  }\r\n} catch (error) {\r\n  console.error('Failed to prevent capture:', error);\r\n}\r\n\r\n// Check if capture is prevented\r\nconst isProtected = isCapturePrevented(hwnd);\r\nconsole.log('Window is protected:', isProtected);\r\n\r\n// Allow capture again (if needed)\r\nallowCapture(hwnd);\r\n```\r\n\r\n## 📚 API Reference\r\n\r\n### `preventCapture(hwnd: number): boolean`\r\n\r\nPrevents screen capture and recording of the specified window.\r\n\r\n**Parameters:**\r\n- `hwnd` - The window handle from `BrowserWindow.getNativeWindowHandle()`\r\n\r\n**Returns:**\r\n- `boolean` - `true` if successful, `false` otherwise\r\n\r\n**Throws:**\r\n- `Error` - If the operation fails or invalid parameters are provided\r\n\r\n### `allowCapture(hwnd: number): boolean`\r\n\r\nAllows screen capture and recording of the specified window (reverses `preventCapture`).\r\n\r\n**Parameters:**\r\n- `hwnd` - The window handle from `BrowserWindow.getNativeWindowHandle()`\r\n\r\n**Returns:**\r\n- `boolean` - `true` if successful, `false` otherwise\r\n\r\n**Throws:**\r\n- `Error` - If the operation fails or invalid parameters are provided\r\n\r\n### `isCapturePrevented(hwnd: number): boolean`\r\n\r\nChecks if capture prevention is currently active for the specified window.\r\n\r\n**Parameters:**\r\n- `hwnd` - The window handle from `BrowserWindow.getNativeWindowHandle()`\r\n\r\n**Returns:**\r\n- `boolean` - `true` if capture is prevented, `false` if capture is allowed\r\n\r\n**Throws:**\r\n- `Error` - If the operation fails or invalid parameters are provided\r\n\r\n### `getPlatform(): string`\r\n\r\nGets the current platform.\r\n\r\n**Returns:**\r\n- `string` - The platform string (`'win32'`, `'darwin'`, `'linux'`)\r\n\r\n### `isPlatformSupported(): boolean`\r\n\r\nChecks if the current platform is supported.\r\n\r\n**Returns:**\r\n- `boolean` - `true` if the platform is supported, `false` otherwise\r\n\r\n## 🖥 Platform Support\r\n\r\n| Platform | Status | API Used | Notes |\r\n|----------|--------|----------|-------|\r\n| Windows | ✅ Supported | `SetWindowDisplayAffinity` | Full support with `WDA_MONITOR` |\r\n| macOS | 🚧 In Development | Core Graphics APIs | Planned implementation |\r\n| Linux | 🚧 In Development | X11/Wayland APIs | Limited support due to platform restrictions |\r\n\r\n### Windows Implementation\r\n\r\nUses the Windows API `SetWindowDisplayAffinity` with `WDA_MONITOR` flag to prevent:\r\n- Screen capture tools (Snipping Tool, etc.)\r\n- Screen recording software\r\n- Remote desktop applications\r\n- Screen sharing in video conferencing apps\r\n\r\n## 💡 Examples\r\n\r\n### Basic Usage\r\n\r\n```typescript\r\nimport { preventCapture, allowCapture } from 'secure-visibility-api';\r\nimport { BrowserWindow, ipcMain } from 'electron';\r\n\r\nconst mainWindow = new BrowserWindow({\r\n  width: 1200,\r\n  height: 800\r\n});\r\n\r\n// Enable protection when window is ready\r\nmainWindow.once('ready-to-show', () => {\r\n  const hwnd = mainWindow.getNativeWindowHandle();\r\n  preventCapture(hwnd);\r\n});\r\n\r\n// IPC handlers for dynamic control\r\nipcMain.handle('enable-protection', () => {\r\n  const hwnd = mainWindow.getNativeWindowHandle();\r\n  return preventCapture(hwnd);\r\n});\r\n\r\nipcMain.handle('disable-protection', () => {\r\n  const hwnd = mainWindow.getNativeWindowHandle();\r\n  return allowCapture(hwnd);\r\n});\r\n```\r\n\r\n### Advanced Usage with Error Handling\r\n\r\n```typescript\r\nimport { \r\n  preventCapture, \r\n  allowCapture, \r\n  isCapturePrevented, \r\n  isPlatformSupported \r\n} from 'secure-visibility-api';\r\n\r\nclass WindowProtection {\r\n  private hwnd: number;\r\n  private isProtected: boolean = false;\r\n\r\n  constructor(hwnd: number) {\r\n    this.hwnd = hwnd;\r\n  }\r\n\r\n  async enableProtection(): Promise<boolean> {\r\n    if (!isPlatformSupported()) {\r\n      throw new Error('Platform not supported');\r\n    }\r\n\r\n    try {\r\n      this.isProtected = preventCapture(this.hwnd);\r\n      return this.isProtected;\r\n    } catch (error) {\r\n      console.error('Failed to enable protection:', error);\r\n      return false;\r\n    }\r\n  }\r\n\r\n  async disableProtection(): Promise<boolean> {\r\n    try {\r\n      const result = allowCapture(this.hwnd);\r\n      if (result) {\r\n        this.isProtected = false;\r\n      }\r\n      return result;\r\n    } catch (error) {\r\n      console.error('Failed to disable protection:', error);\r\n      return false;\r\n    }\r\n  }\r\n\r\n  getProtectionStatus(): boolean {\r\n    try {\r\n      return isCapturePrevented(this.hwnd);\r\n    } catch (error) {\r\n      console.error('Failed to get protection status:', error);\r\n      return false;\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n## 🔨 Building from Source\r\n\r\n### Prerequisites\r\n\r\n#### Windows\r\n- Visual Studio 2019 or later with C++ build tools\r\n- Windows SDK\r\n\r\n#### macOS\r\n- Xcode Command Line Tools\r\n- macOS SDK\r\n\r\n#### Linux\r\n- GCC/G++ compiler\r\n- Python 3.x\r\n- make\r\n\r\n### Build Commands\r\n\r\n```bash\r\n# Install dependencies\r\nnpm install\r\n\r\n# Build TypeScript and native modules\r\nnpm run build\r\n\r\n# Build only TypeScript\r\nnpm run build:ts\r\n\r\n# Build only native modules\r\nnpm run build:native\r\n\r\n# Clean build artifacts\r\nnpm run clean\r\n\r\n# Run tests\r\nnpm test\r\n```\r\n\r\n### Platform-Specific Builds\r\n\r\n```bash\r\n# Windows\r\nnpm run build:native:win32\r\n\r\n# macOS (when implemented)\r\nnpm run build:native:darwin\r\n\r\n# Linux (when implemented)\r\nnpm run build:native:linux\r\n```\r\n\r\n## 🧪 Testing\r\n\r\n```bash\r\n# Run all tests\r\nnpm test\r\n\r\n# Run tests in watch mode\r\nnpm run test:watch\r\n\r\n# Run example app\r\nnpm run example\r\n```\r\n\r\n## ⚠️ Important Notes\r\n\r\n1. **Window Handle**: Always use `BrowserWindow.getNativeWindowHandle()` to get the correct window handle\r\n2. **Timing**: Apply protection after the window is fully loaded and visible\r\n3. **Platform Limitations**: Some platforms may have limited or no support for capture prevention\r\n4. **Performance**: Native modules provide optimal performance with minimal overhead\r\n5. **Security**: This library prevents visual capture but doesn't protect against other forms of data extraction\r\n\r\n## 🤝 Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\n### Development Setup\r\n\r\n1. Fork the repository\r\n2. Clone your fork\r\n3. Install dependencies: `npm install`\r\n4. Create a feature branch\r\n5. Make your changes\r\n6. Add tests for new functionality\r\n7. Run tests: `npm test`\r\n8. Submit a pull request\r\n\r\n## 📄 License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## 🙏 Acknowledgments\r\n\r\n- Windows implementation based on Microsoft's `SetWindowDisplayAffinity` API\r\n- Inspired by the need for privacy protection in Electron applications\r\n- Built with Node.js Native Addons API\r\n\r\n## 📞 Support\r\n\r\nIf you encounter any issues or have questions:\r\n\r\n1. Check the [Issues](https://github.com/aarav-shukla07/secure-visibility-api/issues) page\r\n2. Create a new issue with detailed information\r\n3. Include your platform, Node.js version, and Electron version\r\n\r\n---\r\n\r\n**Made with ❤️ for the Electron community**\r\n","readmeFilename":"README.md","_rev":"1-df60e9228ec065c22e446f05754a7d05"}