@nostr-relay/wot-guard
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

WoT Guard

A Web of Trust (WoT) security guard plugin for nostr-relay

Usage

Install

npm install @nostr-relay/wot-guard

Basic Usage

import { WotGuard } from '@nostr-relay/wot-guard';

// Create a relay instance
// ...

const wotGuard = new WotGuard({
  trustAnchorPubkey:
    '0000000000000000000000000000000000000000000000000000000000000000',
  trustDepth: 2,
  eventRepository,
});

relay.register(wotGuard);

Options

  • trustAnchorPubkey: (Required) The trust anchor public key in hex string.
  • trustDepth: (Required) The depth of the Web of Trust. 1 means trust anchor and anchor's following, 2 means trust anchor, anchor's following, and anchor's following's following. The maximum depth is 2 for now.
  • refreshInterval: The interval to refresh the trust graph in milliseconds. Default is 3600000 (1 hour).
  • enabled: Enable or disable the plugin. Default is true.
  • eventRepository: The event repository instance. It is the same as the one passed to NostrRelay. The plugin will find following events from the repository if you provide it.
  • relayUrls: The relay URLs to fetch the following events. If you provide it, the plugin will fetch the following events from the relay URLs.
  • skipFilters: An filter array. The events that match the skip filters can skip the WoT guard.
  • logger: Custom logger instance.

Note: The eventRepository and relayUrls can be provided together. And you must provide at least one of them.

TODO

  • [ ] Add tests
  • [ ] Improve the algorithm to build the trust graph

Donate

If you like this project, you can buy me a coffee :) ⚡️ codytseng@getalby.com ⚡️

License

MIT

Package Sidebar

Install

npm i @nostr-relay/wot-guard

Weekly Downloads

22

Version

0.0.11

License

MIT

Unpacked Size

27.1 kB

Total Files

12

Last publish

Collaborators

  • codytseng