Skip to content

Conversation

@Cheffromspace
Copy link
Collaborator

Summary

  • Adds pre-built keysender.node binary to avoid compilation issues on newer VS versions
  • Implements postinstall script to automatically copy pre-built binary during installation
  • Prevents npm from attempting to rebuild native modules

Problem

Many users are experiencing build failures with the keysender module due to:

  • C++ compatibility issues with Visual Studio 2022
  • Compilation error: illegal qualified name in member declaration in virtual.hpp
  • Missing build tools or incompatible VS versions

Solution

This PR includes a pre-built binary (compiled with older VS version) that works correctly and is automatically installed via a postinstall script. This ensures users can install the package without needing compatible build tools.

Changes

  • Added /prebuilt/keysender/key_sender.node - pre-built Windows x64 binary
  • Added scripts/postinstall.js - copies pre-built binary to node_modules
  • Updated package.json - added postinstall script
  • Added .npmrc - configures npm to avoid rebuilding
  • Downgraded keysender to v2.2.0 (last known stable version)

Test plan

  • Install package with npm install
  • Verify postinstall script runs and copies binary
  • Test MCPControl functionality works correctly
  • Verify no compilation errors during installation

🤖 Generated with Claude Code

- Add pre-built keysender.node binary for v2.2.0
- Add postinstall script to copy pre-built binary
- Configure npm to avoid rebuilding native modules
- Downgrade keysender to v2.2.0 (last known working version)

This change ensures that users don't need compatible Visual Studio
versions to install the package, as the pre-built binary is included
and automatically installed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@MCPClaude MCPClaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Add pre-built keysender binary

Thank you for this PR that addresses build issues with the keysender module. I've reviewed the changes and have the following feedback:

Overall Assessment

The approach of including a pre-built binary to solve compilation issues is pragmatic, especially for Windows users struggling with newer VS versions. The implementation is straightforward and should work as intended. I have some concerns about cross-platform compatibility and security that should be addressed.

.npmrc

  • The settings look appropriate for preventing automatic rebuilds
  • prefer-offline=true is a good addition to improve installation speed

package.json

  • The postinstall script with || true ensures installation continues even if binary copying fails
  • Good decision to downgrade to a known stable version (2.2.0)

scripts/postinstall.js

  • The script is well-structured and includes proper error handling
  • It uses modern ES module syntax, which requires Node.js ≥14

Issues and Suggestions:

  1. Cross-platform compatibility: The PR mentions this is a Windows x64 binary, but there's no handling for other platforms (macOS, Linux). Consider:

    // Add platform detection
    import os from 'os';
    
    const platform = os.platform();
    const arch = os.arch();
    
    if (platform !== 'win32' || arch !== 'x64') {
      console.log(`[postinstall] Skipping binary copy for ${platform}-${arch}`);
      process.exit(0); // Exit successfully
    }
  2. Binary validation: There's no verification that the binary is intact or hasn't been tampered with. Consider adding a checksum validation:

    import crypto from 'crypto';
    
    // Add checksum verification
    function verifyChecksum(filePath, expectedHash) {
      const fileBuffer = fs.readFileSync(filePath);
      const hashSum = crypto.createHash('sha256');
      hashSum.update(fileBuffer);
      const hex = hashSum.digest('hex');
      return hex === expectedHash;
    }
    
    // Use before copying
    if (!verifyChecksum(sourceFile, 'expected-hash-here')) {
      console.error('[postinstall] Binary validation failed, checksum mismatch');
      process.exit(1);
    }
  3. Documentation: The PR would benefit from a README update explaining:

    • Why the pre-built binary is included
    • Which platforms/architectures are supported
    • How to compile manually if needed
    • How to update the binary when needed
  4. Security considerations: Pre-built binaries can pose security risks. Consider:

    • Documenting the build environment used to create the binary
    • Including source code version information
    • Adding instructions for users who prefer to build from source

Binary file

  • Unable to review the binary file directly, but ensure it was built in a secure environment
  • Consider documenting which version of Visual Studio and build tools were used

Future Maintenance Considerations

  • When keysender is updated, the pre-built binary will need to be rebuilt
  • Consider adding automated build process to generate binaries for multiple platforms

Overall, this is a practical solution to the build issues, and with the suggested improvements, it will be more robust and maintainable.

Copy link
Contributor

@MCPClaude MCPClaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the PR provides a practical solution to the build issues with the keysender module, there are some important aspects that should be addressed before merging:

  1. Platform detection: The current implementation doesn't account for non-Windows platforms. Add platform detection to handle different operating systems appropriately.

  2. Binary verification: Without checksum validation, there's no way to verify the integrity of the binary. Add a verification mechanism to ensure security.

  3. Documentation: Please add documentation explaining:

    • The purpose of the pre-built binary
    • Supported platforms/architectures
    • Build environment details
    • Instructions for users who want to build from source
  4. Future maintenance plan: Outline a plan for maintaining these binaries when the keysender package is updated.

Once these issues are addressed, the PR will be much more robust and ready for approval. The core implementation is sound, but these security and maintenance considerations are important for a production-ready solution.

@Cheffromspace
Copy link
Collaborator Author

@MCPClaude are you there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants