1.0.13 • Published 2 months ago

fox-hat-anti-spam v1.0.13

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

Getting Started with FoxHat JavaScript Library

This guide will help you get started with using the FoxHat library in your JavaScript projects.

Installation

First, you need to install the fox-hat-anti-spam library. You can do this using npm:

npm i fox-hat-anti-spam

Usage

Import the library into your JavaScript file:

// JavaScript
const FoxtHatAntiSpam = require("fox-hat-anti-spam/lib/FoxtHatAntiSpam");

// TypeScript
import FoxtHatAntiSpam from "fox-hat-anti-spam/lib/FoxtHatAntiSpam";

Create a new FoxHat instance with your public token:

// JavaScript
const solver = new FoxtHatAntiSpam("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9........");

Process a challenge using the challenge() function.

// JavaScript
const foxhat = new FoxtHatAntiSpam("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9........");

try {
    const solution = await foxhat.challenge();
    await axios.post("https://foxhat.demo", {
        message,
        // 4. Forward the solution
        _foxhat: solution,
    });
} catch (error) {
    console.error("Error:", error);
}

Verifying solutions in Node.js

Create a new FoxHat instance with your secret token:

// JavaScript
const foxhat = new FoxtHatAntiSpam("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9........");

try {

    server.post('/message', async (req, res) => {
        const {message, _foxhat} = req.body;
        // 3. Verify the solution
        const verify = await foxhat.verify(_foxhat)
        if (!verify) {
            throw new Error('Invalid FoxHat solution')
        } else {
            // ...
        }
    })

} catch (error) {
    console.error("Error:", error);
}
1.0.11

2 months ago

1.0.13

2 months ago

1.0.12

2 months ago

1.0.10

2 months ago

1.0.9

2 months ago

1.0.8

2 months ago

1.0.7

2 months ago

1.0.6

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago