Documentation
    Preparing search index...

    Interface ReplayDetector

    Replay detection engine. Tracks seen event IDs and validates timestamps.

    const detector = createReplayDetector();
    const reason = detector.check(event);
    if (reason !== null) { // reject event }
    interface ReplayDetector {
        check(event: NostrEvent): string | null;
        clear(): void;
        commit(eventId: string): void;
        release(eventId: string): void;
        reserve(event: NostrEvent): string | null;
    }
    Index

    Methods

    • Check if an event should be rejected as a replay and record it as processed. Returns null if the event is valid, or a string reason if it should be rejected.

      Parameters

      Returns string | null

    • Commit a pending reservation as successfully processed.

      Parameters

      • eventId: string

        Reserved signed event ID

      Returns void

    • Release a pending reservation so a failed operation can be retried. Committed event IDs are never removed by this method.

      Parameters

      • eventId: string

        Reserved signed event ID

      Returns void

    • Check an event and atomically reserve its ID for pending processing. Call commit after processing succeeds or release after it fails.

      Parameters

      • event: NostrEvent

        Signed event whose ID should be reserved

      Returns string | null

      null if reserved, or a string reason if it should be rejected