SuiSec Local Blocklists

This is a Javascript/Typescript library that makes it easy to access the Suiet Guardians: for example, scan a domain against the domain-list.

It's designed to support React Native, Chrome Extension and Node.js environments.

Install

npm install suisecblocklist

Usage

In order to execute lookups, you need to fetch a domainlist packagelist objectlist coinlist. After the first fetch, you should keep these objects updated. You can save the objects in a local database (for example, using local storage in Chrome extension).

We recommend updating it every 5 minutes.

Basic usage

import { SuiSecBlocklist } from "suisecblocklist";

const blocklist = new SuiSecBlocklist();

// 1. Fetch the domainlist and persist it in the storage
blocklist.fetchDomainlist();

// 2. Re-refetch the domainlist every 5 minutes
setInterval(() => blocklist.fetchDomainlist(), 1000 * 60 * 5);

// 3. Once you have a domainlist object saved, you can execute lookups
const action = blocklist.scanDomain("<https://scam-website.io>");

if (action === Action.BLOCK) {
  // block the domain
}

// 4. Fetch the packjectlist and persist it in the storage, Once you have a packjectlist object saved, you can execute lookups
blocklist.fetchPackagelist();

const action = blocklist.scanPackage(
  "0x13530eb10a4ffe6396d7acc8499f2b3fba7c18ac38f88570fae51823f6a203b4"
);

if (action === Action.BLOCK) {
  // block the packject
}

// 5. Fetch the objectlist and persist it in the storage, Once you have a objectlist object saved, you can execute lookups
blocklist.fetchObjectlist();

const action = blocklist.scanObject(
  "0x13530eb10a4ffe6396d7acc8499f2b3fba7c18ac38f88570fae51823f6a203b4::my_hero::Hero"
);

if (action === Action.BLOCK) {
  // block the object
}

// 6. Fetch the coinlist and persist it in the storage, Once you have a coinlist object saved, you can execute lookups
blocklist.fetchCoinlist();

const action = blocklist.scanCoin(
  "0x043a9bd4cd74f93e861b8a3138a373e726bb1f7bf8f4f38cde4872f0234ed20b::usdt::USDT"
);

if (action === Action.BLOCK) {
  // block the coin
}

Error handling

Functions that depend on API an/or network can return null when I/O errors are encountered.

If you would like to track errors, you can pass optional reportError callback to SuiSecBlocklist constructor.

It could be called with an Error or with a string.