A Web of Trust (WoT) security guard plugin for nostr-relay
npm install @nostr-relay/wot-guard
import { WotGuard } from '@nostr-relay/wot-guard';
// Create a relay instance
// ...
const wotGuard = new WotGuard({
trustAnchorPubkey:
'0000000000000000000000000000000000000000000000000000000000000000',
trustDepth: 2,
eventRepository,
});
relay.register(wotGuard);
-
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 istrue
. -
eventRepository
: The event repository instance. It is the same as the one passed toNostrRelay
. 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
andrelayUrls
can be provided together. And you must provide at least one of them.
- [ ] Add tests
- [ ] Improve the algorithm to build the trust graph
If you like this project, you can buy me a coffee :) ⚡️ codytseng@getalby.com ⚡️
MIT