mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1fgdl5qqnh3k3f2xkqrvt7cujalhm623x4s7fdjdj5yrtp5fzjl9qrjpucw <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@sprout-oss.stage.blox.sqprod.co>
74 lines
2.6 KiB
Rust
74 lines
2.6 KiB
Rust
#![deny(unsafe_code)]
|
|
#![warn(missing_docs)]
|
|
//! `buzz-core` — zero-I/O foundation types for the Buzz relay.
|
|
//!
|
|
//! Provides [`StoredEvent`], filter matching, kind constants, and event
|
|
//! verification. All other Buzz crates depend on this one.
|
|
|
|
/// NIP-AM: Agent Turn Metric — payload type and encrypt/decrypt helpers.
|
|
pub mod agent_turn_metric;
|
|
/// Channel and membership enums shared across crates.
|
|
pub mod channel;
|
|
/// NIP-AE Agent Engrams — slug grammar, conversation key, d-tag derivation,
|
|
/// body parse/serialize, envelope build/validate, head selection.
|
|
pub mod engram;
|
|
/// Relay-side error types.
|
|
pub mod error;
|
|
/// Relay-side event wrapper with verification tracking.
|
|
pub mod event;
|
|
/// NIP-01 subscription filter matching.
|
|
pub mod filter;
|
|
/// Git permission types — ref patterns, protection rules, policy evaluation.
|
|
pub mod git_perms;
|
|
/// Buzz kind number registry — custom event type constants.
|
|
pub mod kind;
|
|
/// Network utilities — SSRF-safe IP classification.
|
|
pub mod network;
|
|
/// Agent observer frame helpers.
|
|
pub mod observer;
|
|
/// NIP-AB device pairing — crypto primitives, message types, and errors.
|
|
pub mod pairing;
|
|
/// Presence status types shared across crates.
|
|
pub mod presence;
|
|
/// Tenant identity — the server-resolved community key carried on scoped paths.
|
|
pub mod tenant;
|
|
/// Schnorr signature and event ID verification.
|
|
pub mod verification;
|
|
|
|
pub use error::VerificationError;
|
|
pub use event::StoredEvent;
|
|
pub use nostr::{Event, EventId, Filter, Keys, Kind, PublicKey};
|
|
pub use presence::PresenceStatus;
|
|
pub use tenant::{normalize_host, CommunityId, TenantContext};
|
|
pub use verification::verify_event;
|
|
|
|
#[cfg(any(test, feature = "test-utils"))]
|
|
/// Test helper utilities for creating events and stored events.
|
|
pub mod test_helpers {
|
|
use crate::StoredEvent;
|
|
use chrono::Utc;
|
|
use nostr::{EventBuilder, Keys, Kind};
|
|
|
|
/// Create a signed test event with the given kind and random keys.
|
|
pub fn make_event(kind: Kind) -> nostr::Event {
|
|
let keys = Keys::generate();
|
|
EventBuilder::new(kind, "test")
|
|
.tags([])
|
|
.sign_with_keys(&keys)
|
|
.expect("sign")
|
|
}
|
|
|
|
/// Create a signed test event with the given keys and kind.
|
|
pub fn make_event_with_keys(keys: &Keys, kind: Kind) -> nostr::Event {
|
|
EventBuilder::new(kind, "test")
|
|
.tags([])
|
|
.sign_with_keys(keys)
|
|
.expect("sign")
|
|
}
|
|
|
|
/// Create a [`StoredEvent`] wrapper around a test event.
|
|
pub fn make_stored_event(kind: Kind, channel_id: Option<uuid::Uuid>) -> StoredEvent {
|
|
StoredEvent::with_received_at(make_event(kind), Utc::now(), channel_id, true)
|
|
}
|
|
}
|