-
Notifications
You must be signed in to change notification settings - Fork 0
api_reference
This document provides the reference for the main public APIs exported by the fingerprint library.
Creates an Express-compliant middleware.
-
Returns:
Function(Express middleware)
Analyzes the request outside Express middleware to return a stateful identifier.
-
Returns:
Promise<string>(e.g.device:<id>,suspicious_high:<ip>)
Generates a configuration preset deeply merged with your overrides.
-
Parameters:
-
profileName:'balanced' | 'strict' | 'api' | 'blog' | 'ecommerce' -
overrides:object
-
Allows constructing server-side fingerprints manually.
import { FingerprintBuilder } from '@anonympins/fingerprint';
const builder = new FingerprintBuilder();
builder.add('user_agent', req.headers['user-agent']);
const hash = builder.toString();Replaces the default in-memory store with an external backend.
// MongoDB Example
import { configureStore } from '@anonympins/fingerprint';
import { createMongoDbStore } from '@anonympins/fingerprint/mongodb';
import { MongoClient } from 'mongodb';
const client = new MongoClient(process.env.MONGODB_URL);
await client.connect();
configureStore(createMongoDbStore(client.db('dbname'), 'sessions_collection'));The main class to orchestrate script protection.
Initializes the protection engine with a configuration.
Analyzes the current superglobals, headers, and environment. If malicious/suspicious, executes challenge output or blocks immediately, calling exit().
If safe, returns the calculated score and vector.
Creates a customized profile preset.
-
Parameters:
-
$profileName:'balanced' | 'strict' | 'api' | 'blog' | 'ecommerce' -
$overrides:array
-
Switches store engines for sessions, nonces, and IP history.
use Anonympins\Fingerprint\Store\StoreManager;
use Anonympins\Fingerprint\Store\RedisStore;
StoreManager::configureStore(new RedisStore($redisConnection));