JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 117
  • Score
    100M100P100Q85809F
  • License MIT

JS client for server-side usage of Private Captcha API

Package Exports

  • @private-captcha/private-captcha-js
  • @private-captcha/private-captcha-js/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@private-captcha/private-captcha-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

private-captcha-js

NPM Version badge CI

JavaScript client for server-side Private Captcha verification.

Installation

npm install private-captcha-js

Usage

Basic Verification

import { createClient } from 'private-captcha-js';

const client = createClient({ apiKey: 'your-api-key' });

const result = await client.verify({ solution: 'captcha-solution-from-client' });
if (result.success) {
    console.log('Captcha verified!');
}

Express.js Middleware

import express from 'express';
import { createClient } from 'private-captcha-js';

const app = express();
app.use(express.urlencoded({ extended: true })); // Required

const client = createClient({ apiKey: 'your-api-key' });

// Protect route with middleware
app.post('/submit', client.middleware(), (req, res) => {
    res.send('Form submitted successfully!');
});

// Or verify manually
app.post('/verify', async (req, res) => {
    try {
        const result = await client.verifyRequest(req);
        res.json({ success: result.success });
    } catch (error) {
        res.status(403).json({ error: error.message });
    }
});

Configuration

const client = createClient({
    apiKey: 'your-api-key',                 // Required
    formField: 'private-captcha-solution',  // Field from where to read the solution
    failedStatusCode: 403,                  // HTTP status code for failed verifications (middleware)
    domain: 'api.privatecaptcha.com'        // Override for EU isolation or for self-hosting
});

Retry configuration

client.verify({
    solution: 'solution',
    maxBackoffSeconds: 10,
    attempts: 10
});

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues with this Javascript client, please open an issue on GitHub.

For Private Captcha service questions, visit privatecaptcha.com.