diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-12 21:06:39 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-12 21:21:52 +0000 |
| commit | 82b56c37b26a2fac1a294873e539b19b9325dca6 (patch) | |
| tree | 07800949230f13f91fec2eebbd94b8fbb00dd83f /src/nostr/policy | |
| parent | a12927181c571fc1641772ad44dd4c6a4ab209d9 (diff) | |
feat(config): add repository whitelist for curated GRASP-01 acceptance
Adds NGIT_REPOSITORY_WHITELIST option for curated relay operation that
accepts only whitelisted repositories while maintaining GRASP-01 compliance
(announcements must list the service). This differs from archive whitelist
which enables GRASP-05 mode and doesn't require service listing.
Key features:
- Supports three whitelist formats: npub, npub/identifier, identifier
- Enforces mutual exclusivity with archive read-only mode
- Updates NIP-11 curation field when whitelist is enabled
- Maintains GRASP-01 compliance (doesn't add GRASP-05 support)
Configuration synced across all four sources: src/config.rs, docs/reference/configuration.md,
nix/module.nix, and .env.example as required by AGENTS.md.
Diffstat (limited to 'src/nostr/policy')
| -rw-r--r-- | src/nostr/policy/announcement.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/nostr/policy/announcement.rs b/src/nostr/policy/announcement.rs index db87976..15a6e58 100644 --- a/src/nostr/policy/announcement.rs +++ b/src/nostr/policy/announcement.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use nostr_relay_builder::prelude::{Alphabet, Event, Filter, Kind, PublicKey, SingleLetterTag}; | 5 | use nostr_relay_builder::prelude::{Alphabet, Event, Filter, Kind, PublicKey, SingleLetterTag}; |
| 6 | 6 | ||
| 7 | use super::PolicyContext; | 7 | use super::PolicyContext; |
| 8 | use crate::config::ArchiveConfig; | 8 | use crate::config::Config; |
| 9 | use crate::nostr::events::{validate_announcement, RepositoryAnnouncement}; | 9 | use crate::nostr::events::{validate_announcement, RepositoryAnnouncement}; |
| 10 | 10 | ||
| 11 | /// Result of announcement policy evaluation | 11 | /// Result of announcement policy evaluation |
| @@ -25,15 +25,12 @@ pub enum AnnouncementResult { | |||
| 25 | #[derive(Clone)] | 25 | #[derive(Clone)] |
| 26 | pub struct AnnouncementPolicy { | 26 | pub struct AnnouncementPolicy { |
| 27 | ctx: PolicyContext, | 27 | ctx: PolicyContext, |
| 28 | archive_config: ArchiveConfig, | 28 | config: Config, |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | impl AnnouncementPolicy { | 31 | impl AnnouncementPolicy { |
| 32 | pub fn new(ctx: PolicyContext, archive_config: ArchiveConfig) -> Self { | 32 | pub fn new(ctx: PolicyContext, config: Config) -> Self { |
| 33 | Self { | 33 | Self { ctx, config } |
| 34 | ctx, | ||
| 35 | archive_config, | ||
| 36 | } | ||
| 37 | } | 34 | } |
| 38 | 35 | ||
| 39 | /// Validate a repository announcement event | 36 | /// Validate a repository announcement event |
| @@ -44,8 +41,7 @@ impl AnnouncementPolicy { | |||
| 44 | /// or `Reject` with reason. | 41 | /// or `Reject` with reason. |
| 45 | pub async fn validate(&self, event: &Event) -> AnnouncementResult { | 42 | pub async fn validate(&self, event: &Event) -> AnnouncementResult { |
| 46 | // First, try validation (GRASP-01 + GRASP-05) | 43 | // First, try validation (GRASP-01 + GRASP-05) |
| 47 | let validation_result = | 44 | let validation_result = validate_announcement(event, &self.config); |
| 48 | validate_announcement(event, &self.ctx.domain, &self.archive_config); | ||
| 49 | 45 | ||
| 50 | match validation_result { | 46 | match validation_result { |
| 51 | AnnouncementResult::Reject(reason) => { | 47 | AnnouncementResult::Reject(reason) => { |