A ThreatDetector allows you to easily build out community safety features in your dApp or wallet. It is a smart wrapper around ChainPatrol’s APIs that allows you to check if a website is a scam or not. It comes with a variety of storage adapters, so you can easily cache the results of your checks and avoid making unnecessary API calls.

import { ThreatDetector, Storage } from "@chainpatrol/sdk";

// Create a new detector instance
const detector = new ThreatDetector({
  mode: "cloud", // 'cloud' | 'local' (default: 'cloud')

  // Optional: Specify a custom API key (only available for 'cloud' mode)
  apiKey: "YOUR_API_KEY",

  // Optional: Configure a proxy server (only available for 'cloud' mode)
  proxyUrl: "https://proxy.acme.com",

  // Optional: Specify a custom storage adapter
  storage: Storage.extension(),
  // storage: Storage.browser(),
  // storage: Storage.memory(),

  // Optional: Specify a custom redirect URL
  redirectUrl: "https://app.chainpatrol.io/warning",
});

Constructor

new ThreatDetector(options)

Creates a new instance of the ThreatDetector class.


Instance Methods

url()

Checks if a URL is a scam or not.

allow()

Adds a URL to the local allowlist.

block()

Adds a URL to the local blocklist.

ignore()

Adds a URL to the local ignorelist.