AppleSauce
    Preparing search index...

    Implements

    Index

    Constructors

    Properties

    _nip11: null | RelayInformation = null
    attempts$: BehaviorSubject<number> = ...

    How many times the relay has tried to reconnect

    authenticated$: BehaviorSubject<boolean> = ...

    Whether the client is authenticated with the relay

    authRequiredForEvent: Observable<boolean>
    authRequiredForReq: Observable<boolean>
    challenge$: BehaviorSubject<null | string> = ...

    The authentication challenge string from the relay

    connected$: BehaviorSubject<boolean> = ...

    Whether the relay is connected

    eoseTimeout: number = 10_000

    If an EOSE message is not seen in this time, emit one locally

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

    The last connection error

    eventTimeout: number = 10_000

    How long to wait for an OK message from the relay

    information$: Observable<null | RelayInformation>

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

    keepAlive: number = 30_000

    How long to keep the connection alive after nothing is subscribed

    limitations$: Observable<undefined | null | Partial<Limitations>>

    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

    notice$: Observable<string>

    A passive observable of NOTICE messages from the relay

    Subscribing to this will not connect to the relay

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

    The notices from the relay

    ready$: BehaviorSubject<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

    receivedAuthRequiredForEvent: BehaviorSubject<boolean> = ...
    receivedAuthRequiredForReq: BehaviorSubject<boolean> = ...
    reconnectTimer: (
        error: Error | CloseEvent,
        attempts: number,
    ) => Observable<number>

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

    socket: WebSocketSubject<any>
    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

    Accessors

    Methods

    • Creates an Observable, that when subscribed to, sends a message, defined by the subMsg function, to the server over the socket to begin a subscription to data over that socket. Once data arrives, the messageFilter argument will be used to select the appropriate data for the resulting Observable. When finalization occurs, either due to unsubscription, completion, or error, a message defined by the unsubMsg argument will be sent to the server over the WebSocketSubject.

      Type Parameters

      • T

      Parameters

      • open: () => any

        A function to generate the subscription message to be sent to the server. This will still be processed by the serializer in the WebSocketSubject's config. (Which defaults to JSON serialization)

      • close: () => any

        A function to generate the unsubscription message to be sent to the server at finalization. This will still be processed by the serializer in the WebSocketSubject's config.

      • filter: (message: any) => boolean

        A predicate for selecting the appropriate messages from the server for the output stream.

      Returns Observable<T>

    • Set ready = false and start the reconnect timer

      Parameters

      • error: Error | CloseEvent

      Returns void

    • Wait for authentication state, make connection and then wait for authentication if required

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • requireAuth: Observable<boolean>
      • observable: Observable<T>

      Returns Observable<T>

    • Wait for the relay to be ready to accept connections

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • observable: Observable<T>

      Returns Observable<T>

    • Static method to create a reconnection method for each relay

      Parameters

      • _relay: string

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

    • Static method to fetch the NIP-11 information document for a relay

      Parameters

      • url: string

      Returns Observable<null | RelayInformation>