Socket
Book a DemoInstallSign in
Socket

paybito-slider-captcha

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paybito-slider-captcha

A beautiful, interactive slider-based CAPTCHA verification system with puzzle piece matching. Provides secure human verification with an elegant user interface.

1.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

🧩 Paybito Slider Captcha

A beautiful, interactive slider-based CAPTCHA verification system with puzzle piece matching. Provides secure human verification with an elegant, responsive user interface.

npm version License: MIT

✨ Features

  • 🎯 Interactive Puzzle Matching - Drag slider to match puzzle piece position
  • 🎨 Beautiful UI - Modern, responsive design with smooth animations
  • 🔒 Secure Verification - Integrates with Paybito's CAPTCHA API
  • 📱 Mobile Friendly - Fully responsive design for all devices
  • 🎭 Multiple Shapes - Star, circle, triangle, diamond, puzzle, and heart shapes
  • Zero Dependencies - Pure JavaScript, no external libraries required
  • 🛡️ Anti-Bot Protection - Effective against automated attacks
  • 🔧 Easy Integration - Simple API with customizable options

🚀 Installation

npm install paybito-slider-captcha

Or include directly in HTML:

<script src="https://unpkg.com/paybito-slider-captcha@latest/index.js"></script>

📋 Quick Start

Basic Usage

// Import the library
const VerificationSlider = require('paybito-slider-captcha');

// Create instance
const captcha = new VerificationSlider({
  apiEndpoint : 'YOUR_VERIFICATION_API_ENDPOINT'
});

// Show verification
captcha.verify((result) => {
  if (result.success) {
    console.log('✅ Verification successful!');
    console.log('Session ID:', result.sessionId);
    console.log('Response:', result.gRecaptchaResponse);
  } else {
    console.log('❌ Verification failed or cancelled');
  }
});

HTML Integration

<!DOCTYPE html>
<html>
<head>
  <title>CAPTCHA Demo</title>
</head>
<body>
  <button onclick="showCaptcha()">Verify Human</button>
  
  <script src="https://unpkg.com/paybito-slider-captcha@latest/index.js"></script>
  <script>
    function showCaptcha() {
      // Use the global instance
      verificationSlider.verify((result) => {
        if (result.success) {
          alert('✅ Verification successful!');
        } else {
          alert('❌ Verification failed');
        }
      });
    }
  </script>
</body>
</html>

React Integration

import React, { useEffect, useRef } from 'react';
import VerificationSlider from 'paybito-slider-captcha';

function CaptchaComponent() {
  const captchaRef = useRef(null);

  useEffect(() => {
    captchaRef.current = new VerificationSlider({
      tolerance: 8,
      defaultImage: 'https://example.com/custom-image.jpg'
    });

    return () => {
      if (captchaRef.current) {
        captchaRef.current.destroy();
      }
    };
  }, []);

  const handleVerification = () => {
    captchaRef.current.verify((result) => {
      if (result.success) {
        console.log('Verification successful!', result);
        // Handle successful verification
      } else {
        console.log('Verification failed');
        // Handle failed verification
      }
    });
  };

  return (
    <div>
      <button onClick={handleVerification}>
        🛡️ Verify Human
      </button>
    </div>
  );
}

export default CaptchaComponent;

⚙️ Configuration Options

const captcha = new VerificationSlider({
  // API endpoint for CAPTCHA generation
  apiEndpoint: 'Your_endpoint_url',
  
  // Position matching tolerance (pixels)
  tolerance: 5,
  
  // Default image to use for puzzles
  defaultImage: 'https://example.com/puzzle-image.jpg',
  
  // Image dimensions
  imageWidth: 300,
  imageHeight: 200,
  
  // Puzzle piece size
  pieceSize: 50
});

Configuration Parameters

ParameterTypeDefaultDescription
apiEndpointstringPaybito API URLCAPTCHA generation endpoint
tolerancenumber5Position matching tolerance in pixels
defaultImagestringDefault image URLFallback image for puzzles
imageWidthnumber300Canvas width in pixels
imageHeightnumber200Canvas height in pixels
pieceSizenumber50Puzzle piece size in pixels

🎯 API Reference

Methods

verify(callback)

Shows the verification modal and starts the verification process.

captcha.verify((result) => {
  // Handle verification result
});

Parameters:

  • callback (Function): Called when verification completes

Callback Result:

{
  success: boolean,           // Whether verification succeeded
  sessionId?: string,         // Session ID (on success)
  gRecaptchaResponse?: string // Encrypted response (on success)
}

init()

Manually initialize the captcha (called automatically by verify()).

captcha.init();

hideModal()

Programmatically hide the verification modal.

captcha.hideModal();

refreshCaptcha()

Generate a new puzzle challenge.

captcha.refreshCaptcha();

destroy()

Clean up resources and remove the captcha from DOM.

captcha.destroy();

Properties

PropertyTypeDescription
isInitializedbooleanWhether the captcha is initialized
isVisiblebooleanWhether the modal is currently visible
sliderValuenumberCurrent slider position (0-100)
tolerancenumberPosition matching tolerance

🎨 Customization

Custom Styling

The captcha uses CSS classes that can be customized:

/* Override modal appearance */
.verification-modal {
  max-width: 600px !important;
  border-radius: 20px !important;
}

/* Custom header colors */
.verification-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

/* Custom slider colors */
.verification-slider::-webkit-slider-thumb {
  background: linear-gradient(45deg, #ff6b6b, #ee5a24) !important;
}

.verification-slider-fill {
  background: linear-gradient(90deg, #ff6b6b, #ee5a24) !important;
}

Custom Images

const captcha = new VerificationSlider({
  defaultImage: 'https://your-domain.com/custom-puzzle-image.jpg'
});

🔒 Security Features

  • Server-Side Validation - Verification happens on Paybito's secure servers
  • Encrypted Responses - SHA-256 encrypted verification data
  • Session Management - Unique session IDs for each verification
  • Anti-Automation - Multiple puzzle shapes and randomized positions
  • Timeout Protection - Automatic refresh after inactivity

🌟 Advanced Usage

Form Integration

<form id="loginForm">
  <input type="email" name="email" required>
  <input type="password" name="password" required>
  <button type="button" onclick="verifyCaptcha()">Login</button>
</form>

<script>
function verifyCaptcha() {
  verificationSlider.verify((result) => {
    if (result.success) {
      // Add CAPTCHA data to form
      const form = document.getElementById('loginForm');
      const hiddenField = document.createElement('input');
      hiddenField.type = 'hidden';
      hiddenField.name = 'captcha_response';
      hiddenField.value = result.gRecaptchaResponse;
      form.appendChild(hiddenField);
      
      // Submit form
      form.submit();
    }
  });
}
</script>

Multiple Instances

// Create multiple captcha instances
const loginCaptcha = new VerificationSlider({ tolerance: 5 });
const registerCaptcha = new VerificationSlider({ tolerance: 8 });

// Use different instances for different forms
document.getElementById('loginBtn').onclick = () => {
  loginCaptcha.verify(handleLoginVerification);
};

document.getElementById('registerBtn').onclick = () => {
  registerCaptcha.verify(handleRegisterVerification);
};

Error Handling

captcha.verify((result) => {
  if (result.success) {
    // Success handling
    console.log('✅ Verification successful');
    // Proceed with form submission
  } else {
    // Failure handling
    console.log('❌ Verification failed');
    // Show error message to user
    showErrorMessage('Please complete the verification');
  }
});

📱 Mobile Responsiveness

The captcha automatically adapts to different screen sizes:

  • Desktop: Full-featured modal with hover effects
  • Tablet: Optimized touch interactions
  • Mobile: Responsive layout with larger touch targets

🔧 Troubleshooting

Common Issues

1. Modal not showing

// Ensure the captcha is properly initialized
if (!captcha.isInitialized) {
  captcha.init();
}

2. API errors

// Check network connectivity and API endpoint
// Verify CORS settings if using custom endpoint

3. Styling conflicts

// The captcha uses high z-index (10000)
// Ensure no other elements interfere

4. Multiple instances

// Always destroy previous instances
captcha.destroy();
const newCaptcha = new VerificationSlider();

🌐 Browser Support

  • ✅ Chrome 60+
  • ✅ Firefox 55+
  • ✅ Safari 12+
  • ✅ Edge 79+
  • ✅ Mobile browsers (iOS Safari, Chrome Mobile)

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

📞 Support

Made with ❤️ for better web security

Keywords

captcha

FAQs

Package last updated on 21 Aug 2025

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.