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
    _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 (will be false if auth failed)

    authenticatedAs$: Observable<string | null>

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

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

    The authentication event sent to the relay

    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 unsubscribe or complete

    connected$: BehaviorSubject<boolean>

    Whether the relay is connected

    enablePing: boolean

    Enable/disable ping functionality (default false)

    error$: BehaviorSubject<Error | null>

    The last connection error

    eventTimeout: number

    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

    keepAlive: number

    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

    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

    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

    How often to send pings in milliseconds (default 29000)

    pingTimeout: number

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

    publishRetry: RetryConfig

    Default retry config for publish() method

    publishTimeout: number

    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

    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

    reqs$: BehaviorSubject<Record<string, Filter[]>>

    Tracks active req() operations by subscription ID

    requestReconnect: RetryConfig

    Default reconnect config for request() method

    socket: WebSocketSubject<any>
    status$: Observable<RelayStatus>

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

    subscriptionReconnect: RetryConfig

    Default reconnect config for subscription() method

    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 authenticatedAs(): string | null

      Returns string | null

    • get authentication(): KnownEvent<22242> | null

      Returns KnownEvent<22242> | null

    • 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 lastMessageAt(): number

      Returns number

    • get notices(): string[]

      Returns string[]

    • get ready(): boolean

      Returns boolean

    • get reqs(): Record<string, Filter[]>

      Returns Record<string, Filter[]>

    Methods

    • send and AUTH message

      Parameters

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

    • Internal operator for creating the repeat() operator for resubscribing

      Type Parameters

      • T extends unknown = unknown

      Parameters

      • times: number | boolean | RepeatConfig | undefined

      Returns MonoTypeOperatorFunction<T>

    • Internal operator for creating the retry() operator for reconnecting to the websocket

      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

      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>

    • 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

      • store: NegentropyReadStore
      • filter: Filter
      • reconcile: ReconcileFunction
      • Optionalopts: NegentropySyncOptions

      Returns Promise<boolean>

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

      Parameters

      Returns Promise<PublishResponse>

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

      Parameters

      • filters: FilterInput
      • Optionalopts: RelayReqOptions

      Returns Observable<RelayReqMessage>

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

      Parameters

      • filters: FilterInput
      • Optionalopts: RelayRequestOptions

      Returns Observable<NostrEvent>

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

      Returns Observable<RelaySubscriptionResponse>

    • Negentropy sync events with the relay and an event store

      Parameters

      • store: NegentropySyncStore
      • filters: Filter
      • Optionaldirection: SyncDirection

      Returns Observable<NostrEvent>

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

    • A complete condition that waits for the subscription to open

      Parameters

      • condition: RelayRequestCompleteOperator

      Returns RelayRequestCompleteOperator

    • An AND complete condition, that completes when all conditions are truthy

      Parameters

      • ...conditions: RelayRequestCompleteOperator[]

      Returns RelayRequestCompleteOperator

    • An OR complete condition, that completes when either condition is truthy

      Parameters

      • ...conditions: RelayRequestCompleteOperator[]

      Returns RelayRequestCompleteOperator

    • Static method to create a reconnection method for each relay

      Parameters

      • _relay: string

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

    • A default complete condition that waits for the subscription to open and then completes after a timeout

      Parameters

      • timeout: number
      • OptionalafterOpen: number

      Returns RelayRequestCompleteOperator

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

      Parameters

      • url: string

      Returns Observable<RelayInformation | null>