0.0.44 • Published 3 days ago

foxhat-javascript-sdk v0.0.44

Weekly downloads
-
License
-
Repository
-
Last release
3 days 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 foxhat-anti-spam library. You can do this using npm:

npm i foxhat-anti-spam

Usage

Import the library into your JavaScript file:

// JavaScript
const {FoxtHatAntiSpam} = require('foxhat-anti-spam');

// TypeScript
import FoxtHatAntiSpam from "foxhat-anti-spam";

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);
}
0.0.40

3 days ago

0.0.41

3 days ago

0.0.42

3 days ago

0.0.43

3 days ago

0.0.44

3 days ago

0.0.37

3 days ago

0.0.38

3 days ago

0.0.39

3 days ago

0.0.30

4 days ago

0.0.31

4 days ago

0.0.32

4 days ago

0.0.33

4 days ago

0.0.34

4 days ago

0.0.35

3 days ago

0.0.36

3 days ago

0.0.26

12 days ago

0.0.27

12 days ago

0.0.28

12 days ago

0.0.29

11 days ago

0.0.25

12 days ago

0.0.21

15 days ago

0.0.22

14 days ago

0.0.23

14 days ago

0.0.24

14 days ago

0.0.20

16 days ago

0.0.16

19 days ago

0.0.17

19 days ago

0.0.18

18 days ago

0.0.19

18 days ago

0.0.10

19 days ago

0.0.11

19 days ago

0.0.12

19 days ago

0.0.13

19 days ago

0.0.14

19 days ago

0.0.15

19 days ago

0.0.9

19 days ago

0.0.8

1 month ago

0.0.7

1 month ago

0.0.6

1 month ago

0.0.5

1 month ago

0.0.4

1 month ago

0.0.3

1 month ago

0.0.2

1 month ago

0.0.1

1 month ago

1.0.6

1 month ago