@olo/fraud-prevention-js-sdk
v1.0.0
Published
[](https://www.npmjs.com/package/@olo/fraud-prevention-js-sdk) [](https://opensource.org/licenses/MIT)
Maintainers
Keywords
Readme
Fraud Prevention JS SDK
Introduction
The Fraud Prevention JS SDK is a lightweight, browser-based JavaScript library that simplifies fraud prevention integration in web applications. The SDK handles script injection, session tracking, and token management automatically, so you can protect your application from fraudulent transactions with just a few lines of code.
Currently Supported Providers:
- Forter - Real-time fraud prevention platform
Key Features:
- Simple, minimal API - just initialize, create, and get the token
- TypeScript support with full type definitions
- Automatic session tracking and token generation
- Memory leak prevention with built-in cleanup
Installation
npm install @olo/fraud-prevention-js-sdkQuick Start
import { ForterFP, ForterEnvironment } from "@olo/fraud-prevention-js-sdk";
// 1. Initialize once at app startup
const fraudPrevention = new ForterFP({
siteId: "olo-forter-site-id", // Contact your Olo representative to obtain this
environment: ForterEnvironment.Production,
});
fraudPrevention.create();
// 2. Make it globally accessible
window.fraudPrevention = fraudPrevention;
// 3. Use throughout your app when submitting orders
await fetch("/api/orders", {
method: "POST",
body: JSON.stringify({
...orderData,
fraudSessionId: window.fraudPrevention?.getFraudSessionId() ?? undefined,
}),
});Note: The
siteIdis Olo's global Forter site ID. Contact your Olo representative to obtain this value.
Provider Documentation
For detailed integration instructions and API reference, see:
- Forter Integration Guide - Complete setup, usage examples, and troubleshooting
API Reference
Core Classes
ForterFP
The Forter fraud prevention integration class.
Constructor:
new ForterFP(config: ForterFPConfig)Configuration:
siteId(string, required): Olo's global Forter site ID. Contact your Olo representative to obtain this value.environment(ForterEnvironment, optional): Environment setting (Production, Staging, or Development)
Methods:
create(): Initializes and injects the Forter script into the DOMgetFraudSessionId(): Returns the fraud session ID (token) or null if not yet availabledestroy(removeScript?: boolean): Cleans up event listeners and optionally removes the script from the DOM
For complete API documentation and usage examples, refer to the Forter Integration Guide.
Development
See CONTRIBUTING.md for development setup and contribution guidelines.
Quick Start for Contributors
# Install dependencies
npm install
# Run tests
npm run test
# Build the library
npm run build
# Run linting
npm run lintBrowser Support
This library supports all modern browsers that support ES2022.
License
MIT © Olo
