Files
2025-09-02 00:09:46 +00:00

6.3 KiB

NIP-XX: Site Administration Events

Abstract

This NIP defines a custom event kind for storing site administration policies and configurations in Nostr applications. It allows site administrators to persist content moderation settings, user access controls, and site configuration across devices and sessions.

Specification

Event Kind

This NIP introduces event kind 39767 for site administration data.

Event Structure

Site administration events are addressable events that use the d tag to identify different configuration categories.

{
  "kind": 39767,
  "content": "<JSON-encoded administration data>",
  "tags": [
    ["d", "admin-config"],
    ["alt", "Site administration configuration and policies"]
  ],
  "created_at": <unix timestamp>,
  "pubkey": "<site administrator's pubkey>"
}

Content Schema

The content field contains a JSON object with the following structure:

{
  "hiddenEvents": ["<event_id>", "..."],
  "allowList": ["<pubkey>", "..."],
  "denyList": ["<pubkey>", "..."],
  "blockedWords": ["word1", "phrase2", "..."],
  "caseSensitive": false,
  "wholeWordsOnly": true,
  "enableModeration": true,
  "autoHideBlocked": true,
  "requireApproval": false,
  "siteName": "My Nostr Site",
  "siteDescription": "A description of the site"
}

Field Descriptions

  • hiddenEvents: Array of event IDs that have been manually hidden by the administrator
  • allowList: Array of pubkeys explicitly allowed to post content (if not empty, only these users can post)
  • denyList: Array of pubkeys blocked from posting content
  • blockedWords: Array of words or phrases that trigger content filtering
  • caseSensitive: Boolean indicating whether word filtering is case-sensitive
  • wholeWordsOnly: Boolean indicating whether to match whole words only (vs partial matches)
  • enableModeration: Boolean to enable/disable all moderation features
  • autoHideBlocked: Boolean to automatically hide content matching blocked words
  • requireApproval: Boolean to require manual approval for all content
  • siteName: String containing the site's display name
  • siteDescription: String containing the site's description

Usage

Publishing Administration Events

Site administrators publish these events to store their moderation policies:

const adminEvent = {
  kind: 39767,
  content: JSON.stringify({
    hiddenEvents: [],
    allowList: [],
    denyList: ["banned_user_pubkey"],
    blockedWords: ["spam", "inappropriate"],
    caseSensitive: false,
    wholeWordsOnly: true,
    enableModeration: true,
    autoHideBlocked: true,
    requireApproval: false,
    siteName: "My Community",
    siteDescription: "A moderated Nostr community"
  }),
  tags: [
    ["d", "admin-config"],
    ["alt", "Site administration configuration and policies"]
  ]
};

Querying Administration Events

Clients query for the latest administration configuration:

const adminConfig = await relay.query([{
  kinds: [39767],
  authors: [adminPubkey],
  "#d": ["admin-config"],
  limit: 1
}]);

Implementation Guidelines

Authentication

  • Only events signed by the designated site administrator's private key are valid
  • The administrator's pubkey should be configured in the application (e.g., environment variable)
  • Clients should verify the event signature before applying policies

Content Filtering

  • Allow List: If not empty, only users on this list can post content
  • Deny List: Users on this list are blocked regardless of allow list status
  • Blocked Words: Content containing these words/phrases is filtered according to settings
  • Case Sensitivity: Controls whether word matching is case-sensitive
  • Whole Words: Controls whether to match complete words vs partial strings

Precedence Rules

  1. Deny list takes precedence over allow list
  2. Manual hiding (hiddenEvents) takes precedence over automatic filtering
  3. If moderation is disabled, no filtering is applied

Client Behavior

  • Clients should cache the latest administration event for performance
  • Updates to administration policies should be reflected immediately in the UI
  • Clients may choose to implement additional local filtering beyond these policies

Security Considerations

  • Administration events contain sensitive moderation data and should only be published by authorized administrators
  • The alt tag provides human-readable context for the event purpose
  • Clients should validate the JSON content structure before applying policies
  • Consider implementing rate limiting for administration event updates

Rationale

This NIP addresses the need for persistent, cross-device site administration in decentralized Nostr applications. By storing policies as Nostr events, administrators can:

  • Maintain consistent moderation across multiple devices
  • Backup and restore moderation settings
  • Share administrative responsibilities (with proper key management)
  • Maintain audit trails of policy changes

The addressable event structure allows for future expansion with additional configuration categories using different d tag values.

Examples

Basic Moderation Setup

{
  "kind": 39767,
  "content": "{\"hiddenEvents\":[],\"allowList\":[],\"denyList\":[\"spam_user_pubkey\"],\"blockedWords\":[\"spam\",\"scam\"],\"caseSensitive\":false,\"wholeWordsOnly\":true,\"enableModeration\":true,\"autoHideBlocked\":true,\"requireApproval\":false,\"siteName\":\"Family-Friendly Community\",\"siteDescription\":\"A safe space for family discussions\"}",
  "tags": [
    ["d", "admin-config"],
    ["alt", "Site administration configuration and policies"]
  ]
}

Allowlist-Only Community

{
  "kind": 39767,
  "content": "{\"hiddenEvents\":[],\"allowList\":[\"trusted_user1\",\"trusted_user2\"],\"denyList\":[],\"blockedWords\":[],\"caseSensitive\":false,\"wholeWordsOnly\":true,\"enableModeration\":true,\"autoHideBlocked\":false,\"requireApproval\":true,\"siteName\":\"Private Community\",\"siteDescription\":\"Invitation-only community\"}",
  "tags": [
    ["d", "admin-config"],
    ["alt", "Site administration configuration and policies"]
  ]
}

References