AppleSauce
    Preparing search index...

    Extended relay class for interacting with the vertex relay

    Hierarchy

    • Relay
      • Vertex
    Index

    Constructors

    • Parameters

      • signer: ISigner
      • relay: string = VERTEX_RELAY
      • Optionalopts: RelayOptions

      Returns Vertex

    Properties

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

    How many times the relay has tried to reconnect

    authenticated$: Observable<boolean>

    Boolean authentication state (will be false if auth failed)

    authenticationResponse$: BehaviorSubject<PublishResponse | null>

    The response to the last AUTH message sent to the relay

    authRequiredForPublish$: Observable<boolean>
    authRequiredForRead$: Observable<boolean>
    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 unsubscription

    connected$: BehaviorSubject<boolean>

    Whether the relay is connected

    eoseTimeout: number

    If an EOSE message is not seen in this time, emit one locally (default 10s)

    error$: BehaviorSubject<Error | null>

    The last connection error

    eventTimeout: number

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

    information$: Observable<RelayInformation | null>

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

    keepAlive: number

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

    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

    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

    open$: Subject<Event>

    An observable that emits when underlying websocket is opened

    publishTimeout: number

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

    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>
    supported$: Observable<number[] | null>

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

    url: string
    userSearchCache: LRU<ProfilePointer[]> = ...
    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

    • get authenticated(): boolean

      Returns boolean

    • get authenticationResponse(): PublishResponse | null

      Returns PublishResponse | null

    • get challenge(): string | null

      Returns string | null

    • get connected(): boolean

      Returns boolean

    • get information(): RelayInformation | null

      Returns RelayInformation | null

    • get notices(): string[]

      Returns string[]

    Methods

    • send and AUTH message

      Parameters

      • event: Event

      Returns Promise<PublishResponse>

    • Authenticate with the relay using a signer

      Parameters

      • signer: AuthSigner

      Returns Promise<PublishResponse>

    • Create a COUNT observable that emits a single count response

      Parameters

      Returns Observable<CountResponse>

    • Internal operator for creating the repeat() operator

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • times: number | boolean | RepeatConfig | undefined

      Returns MonoTypeOperatorFunction<T>

    • Internal operator for creating the retry() operator

      Type Parameters

      • T extends unknown = unknown

      Parameters

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

      Returns MonoTypeOperatorFunction<T>

    • Internal operator for creating the timeout() operator

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • timeout: number | boolean | undefined
      • defaultTimeout: number

      Returns MonoTypeOperatorFunction<T>

    • Send an EVENT or AUTH message and return an observable of PublishResponse that completes or errors

      Parameters

      • event: Event
      • Optionalverb: "EVENT" | "AUTH"

      Returns Observable<PublishResponse>

    • Method to get credit balance on vertex

      Returns Promise<number>

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

      Returns Promise<RelayInformation | null>

    • 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>

    • Internal operator for handling auth-required errors from REQ/COUNT operations

      Parameters

      • operation: "REQ" | "COUNT"

      Returns MonoTypeOperatorFunction<any>

    • 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
      • close: () => any
      • filter: (message: any) => boolean

      Returns Observable<T>

    • Negentropy sync event ids with the relay and an event store

      Parameters

      Returns Promise<boolean>

    • Publishes an event to the relay and retries when relay errors or responds with auth-required ( default 3 retries )

      Parameters

      • event: Event
      • Optionalopts: PublishOptions

      Returns Promise<PublishResponse>

    • Create a REQ observable that emits events or "EOSE" or errors

      Parameters

      • filters: FilterInput
      • Optionalid: string

      Returns Observable<SubscriptionResponse>

    • Makes a single request that retires on errors and completes on EOSE

      Parameters

      • filters: FilterInput
      • Optionalopts: SubscriptionOptions

      Returns Observable<Event>

    • Returns void

    • Send a message to the relay

      Parameters

      • message: any

      Returns void

    • Set ready = false and start the reconnect timer

      Parameters

      • error: Error | CloseEvent

      Returns void

    • Creates a REQ that retries when relay errors ( default 3 retries )

      Parameters

      • filters: FilterInput
      • Optionalopts: SubscriptionOptions

      Returns Observable<SubscriptionResponse>

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

      Type Parameters

      • T extends unknown = unknown

      Parameters

      Returns Observable<T>

    • Wait for the relay to be ready to accept connections

      Type Parameters

      • T extends unknown = unknown

      Parameters

      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<RelayInformation | null>