mirror of
https://github.com/block/buzz.git
synced 2026-11-01 06:51:17 +00:00
Cumulative PR layer #1476. Integrates the reviewed authorization foundation, provider-neutral verification backend, loopback fixture repair, public dependency-source normalization, and the advisory-free Mesh revision. Neighbor disclosure: bounded audit capacity remains in #3564; lifecycle and canonical admission remain in #4772; protected and status consumers remain in the later cumulative layers. Signed-off-by: Cea Stapleton Cordasco <261786559+cea@users.noreply.github.com>
86 lines
3.1 KiB
Rust
86 lines
3.1 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;
|
|
/// Provider-free authorization fences and privacy-safe binding evidence.
|
|
pub mod authorization;
|
|
/// 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;
|
|
/// Shared invite-link contract constants.
|
|
pub mod invite;
|
|
/// 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;
|
|
/// NIP-PMA owner-encrypted private managed-agent wire codec.
|
|
pub mod private_managed_agent;
|
|
/// Canonical relay runtime identities.
|
|
pub mod relay;
|
|
/// 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 authorization::{
|
|
AuthorizationLeaseFence, AuthorizationLeaseFenceError, CanonicalCurrentBindingEvidence,
|
|
CurrentBindingEvidenceError,
|
|
};
|
|
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)
|
|
}
|
|
}
|