Applesauce
    Preparing search index...

    Class Relay

    Index
    _nip11: RelayInformation | null = null
    _ready$: BehaviorSubject<boolean> = ...

    Internal subject that tracks the ready state of the relay

    attempts$: BehaviorSubject<number> = ...

    How many times the relay has tried to reconnect

    authenticated$: Observable<boolean>

    Boolean authentication state (true if at least one pubkey is authenticated)

    authenticatedAs$: Observable<string | null>

    The pubkey of the most recently authenticated user, or null if not authenticated

    use authenticatedPubkeys$ instead

    authenticatedPubkeys$: Observable<string[]>

    The pubkeys that are currently authenticated on the connection, ordered oldest to most recent

    authentication$: BehaviorSubject<KnownEvent<22242> | null> = ...

    The last authentication event sent to the relay

    use authentications$ instead

    authenticationResponse$: BehaviorSubject<PublishResponse | null> = ...

    The response to the last AUTH message sent to the relay

    use authentications$ instead

    authentications$: BehaviorSubject<Record<string, RelayAuthState>> = ...

    All AUTH attempts on this connection keyed by pubkey (NIP-42 supports multiple authenticated users per connection)

    authLog: Debugger = ...

    D-13/D-20: the relay's NIP-42 lines, re-derived in the constructor as Relay:auth:<url>.

    challenge$: BehaviorSubject<string | null> = ...

    The authentication challenge string from the relay

    close$: Subject<CloseEvent> = ...

    An observable that emits when underlying websocket is closed

    closing$: Subject<void> = ...

    An observable that emits when underlying websocket is closing due to unsubscribe or complete

    connected$: BehaviorSubject<boolean> = ...

    Whether the relay is connected

    countTimeout: number = 10_000

    Whole logical COUNT request timeout (default 10s)

    destroy$: ReplaySubject<void> = ...

    Fires when the relay is closed. Used to cancel the watchTower's keepAlive reset timer. A ReplaySubject so a reset timer armed after close() is torn down immediately.

    enablePing: boolean = false

    Enable/disable ping functionality (default false)

    error$: BehaviorSubject<Error | null> = ...

    The last connection error

    eventTimeout: number = 10_000

    How long to wait for an OK message from the relay (default 10s)

    icon$: Observable<string | undefined>

    An observable that emits the icon URL for the relay, or the favicon.ico URL for the relay

    information$: Observable<RelayInformation | null>

    An observable that emits the NIP-11 information document for the relay

    internalSubscriptions: Subscription = ...

    Long-lived state-watcher subscriptions created in the constructor (open/close/auth)

    keepAlive: number = 30_000

    How long to keep the connection alive after nothing is subscribed (default 30s)

    lastMessageAt$: Observable<number> = ...
    limitations$: Observable<Partial<Limitations> | null | undefined>

    An observable that emits the limitations for the relay

    log: Debugger = ...
    message$: Observable<any>

    A passive observable of all messages from the relay

    Subscribing to this will not connect to the relay

    name$: Observable<string>

    An observable that emits the NIP-11 name of the relay, or its URL until the information document loads

    notice$: Observable<string>

    A passive observable of NOTICE messages from the relay

    Subscribing to this will not connect to the relay

    noticeLimit: number

    The constructor-configured maximum number of retained notices

    notices$: BehaviorSubject<string[]> = ...

    The retained notices from the current relay connection, ordered oldest to newest

    onUnresponsive?: (
        info: {
            attempts: number;
            lastMessageAt: number;
            now: number;
            url: string;
        },
    ) => "reconnect"
    | "close"
    | "ignore"

    Policy hook for unresponsive connections

    open$: Subject<Event> = ...

    An observable that emits when underlying websocket is opened

    pingFrequency: number = 29_000

    How often to send pings in milliseconds (default 29000)

    pingTimeout: number = 20_000

    How long to wait for EOSE response in milliseconds (default 20000)

    publishRetry: RetryConfig

    Default retry config for publish() method

    publishTimeout: number = 30_000

    How long to wait for a publish to complete (default 30s)

    ready$: Observable<boolean> = ...

    Whether the relay is ready for subscriptions or event publishing. setting this to false will cause all .req and .event observables to hang until the relay is ready

    reconnectSubscription: Subscription | null = null

    The currently armed reconnect timer subscription, if any

    reconnectTimer: (
        error: Error | CloseEvent,
        attempts: number,
    ) => Observable<number>

    A method that returns an Observable that emits when the relay should reconnect

    reqs$: ReqsSubject = ...

    Tracks active req() operations by subscription ID

    requestReconnect: RetryConfig

    Default retry config for request() connection errors

    router: SocketRouter

    Routes subscription and OK replies to their listeners by id

    socket: WebSocketSubject<any>

    Observable of relay status (connection, authentication, and ready state)

    subscriptionReconnect: RetryConfig

    Default retry config for subscription() connection errors

    supported$: Observable<number[] | null>

    An array of supported NIPs from the NIP-11 information document

    url: string
    watchTower: Observable<never>

    An internal observable that is responsible for watching all messages and updating state, subscribing to it will trigger a connection to the relay

    • An observable that emits whether a specific pubkey (or all of an array of pubkeys) is authenticated

      Parameters

      • pubkeys: string | string[]

      Returns Observable<boolean>

    • Returns the shared authRetry operator configured from an operation's auth options. AuthRequiredError triggers an auth phase, and the three terminal auth errors are what it gives up with.

      Type Parameters

      • T extends unknown = unknown

      Parameters

      Returns MonoTypeOperatorFunction<T>

    • Force close the connection and tear down all internal subscriptions and timers.

      Returns void

      This is a terminal operation; the relay should be discarded after calling it.

    • Internal operator for retrying connection failures without retrying relay CLOSED errors

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • times: number | boolean | RetryConfig | undefined
      • Optionalbase: RetryConfig

      Returns MonoTypeOperatorFunction<T>

    • Internal operator for creating the repeat() operator, optionally gated by a condition

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • times: number | boolean | RepeatConfig | undefined
      • Optionalcondition: () => boolean

      Returns MonoTypeOperatorFunction<T>

    • Classifier-supplied retry policy shared by the high-level publish and COUNT families. Each caller supplies a positive allow-list; all other failures are re-thrown immediately. The call-scoped auth counter persists across transient resubscriptions, enforcing the additive 1 + authRetries + retries EVENT-write bound.

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • times: number | boolean | RetryConfig | undefined
      • Optionalbase: RetryConfig
      • classifier: (error: unknown) => boolean = isRetryablePublishError

      Returns MonoTypeOperatorFunction<T>

    • Internal operator for creating a suspendable timeout() operator whose countdown does not advance while gate is in an auth phase (D-15) — used by publish() so publishTimeout gets its full budget for the real work once the auth phase closes, rather than racing authTimeout. Preserves the same false/true/number semantics the prior bare-timeout helper had. Do NOT "simplify" this back to a bare rxjs timeout(), which cannot pause. firstWhen is required (CR-01/WR-01) — the sole caller states what counts as progress for its own stream shape; there is no permissive default.

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • timeout: number | boolean | undefined
      • defaultTimeout: number
      • gate: AuthPhaseGate
      • firstWhen: ProgressPredicate<T>

      Returns MonoTypeOperatorFunction<T>

    • An async method that returns the NIP-11 limitations for the relay

      Returns Promise<Partial<Limitations> | null | undefined>

    • An async method that returns the supported NIPs for the relay

      Returns Promise<number[] | null>

    • Whether a specific pubkey (or all of an array of pubkeys) is authenticated on the connection

      Parameters

      • pubkeys: string | string[]

      Returns boolean

    • Compute the pubkeys not yet authenticated for an AuthRequirement, for RelayAuthContext.missingPubkeys. true returns null (any authenticated user satisfies it, so no specific pubkeys are "missing"). A single pubkey returns an empty array when already authenticated, a one-element array otherwise. An array returns only the entries isAuthenticated reports false for.

      Parameters

      Returns string[] | null

    • Type Parameters

      • T

      Parameters

      • open: () => any
      • close: () => any
      • filter: (message: any) => boolean

      Returns Observable<T>

    • D-08: compute the pubkeys that currently satisfy an AuthRequirement — the join key an operation track hangs its "now waiting for …" line off. true is satisfied by any authenticated pubkey, so the whole current set is returned wholesale. A string or array requirement returns only the required pubkeys that are already authenticated.

      Parameters

      Returns string[]

    • Set ready = false and start the reconnect timer

      Parameters

      • error: Error | CloseEvent

      Returns void

    • Static method to create a reconnection method for each relay

      Parameters

      • _relay: string

      Returns (_error?: Error | CloseEvent, tries?: number) => Observable<0>