reticulum-js
    Preparing search index...

    Class Destination

    Represents a Reticulum destination — an addressable endpoint that can announce, receive packets, encrypt/decrypt, and establish Links.

    Hierarchy

    • EventTarget
      • Destination
    Index
    • Low-level constructor. Prefer the static factories (Destination.IN, Destination.OUT, etc.) which also compute the destination hashes.

      Parameters

      • name: string

        The application name.

      • direction: number

        The direction of this destination.

      • type: number

        The type of this destination.

      • identity: Identity | null = null

        The identity associated with this destination.

      • interfaceLayer: Reticulum | null = null

        An object that manages destinations and dispatches link requests.

      Returns Destination

    destinationHash: Uint8Array<ArrayBufferLike> | null
    direction: number
    identity: Identity | null
    interfaceLayer: Reticulum | null
    latestRatchetTime: number
    name: string
    nameHash: Uint8Array<ArrayBufferLike> | null
    ratchetInterval: number
    ratchets: { privateKey: Uint8Array; publicKey: Uint8Array }[] | null
    ratchetsEnabled: boolean
    requestHandlers: Map<string, RequestHandler>

    Registered REQUEST handlers keyed by hex(SHA-256(path)[:16]) (PROTOCOL-SPEC.md §11.3). The path string itself is never sent on the wire — only its 16-byte truncated hash — so a client must already know the path to fetch the resource at it.

    type: number
    knownDestinations: Map<string, any[]> = ...

    Storage for known destinations.

    knownRatchets: Map<string, Uint8Array<ArrayBufferLike>[]> = ...

    Known ratchet X25519 public keys per destination (SPEC.md §4.5 step 6.2, §7.4). Maps hex destination hash → array of ratchet pubs (newest first). Populated from validated announces; consumed by the inbound-decrypt tolerance path once full ratchet support lands.

    MAX_RATCHETS: number = 128

    Maximum number of retained ratchet keys for decryption tolerance.

    RATCHET_INTERVAL_MS: number = ...

    Default ratchet rotation interval (Destination.RATCHET_INTERVAL = 30 min). A destination with ratchets enabled rotates its key at most this often.

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • Broadcasts an Announce packet advertising this destination's public key, name hash and signed metadata so peers can learn and remember it.

      Emits with context = NONE (a regular periodic announce). Use announcePathResponse to answer a path? request.

      Returns Promise<void>

    • Broadcasts a path-response announce — identical body to a regular announce (§4.1) but with the outer packet's context byte set to PATH_RESPONSE = 0x0B (§7.2.4). Emitted in answer to an inbound path? request so the requester can learn a route back to us. The announce body validates identically under §4.5; only the context byte distinguishes it.

      Returns Promise<void>

    • Initiates an encrypted link to this remote (OUT) destination.

      Delegates to Link.initiate, which generates the ephemeral keypair, builds and sends the LINKREQUEST, registers the link with the transport, and transitions to HANDSHAKE. This method then awaits Link.whenActive() so that the returned link is fully established (LRPROOF validated, session keys derived) and ready to carry application DATA — e.g. it is safe to call link.identify(...) immediately on the resolved value.

      Returns Promise<Link>

    • Decrypts data that was encrypted for this destination's identity.

      Tries each owned ratchet private key (newest first) before the long-term key (§7.4), so messages encrypted to a just-rotated ratchet still decrypt. Returns null when decryption fails (wrong recipient / unknown key).

      Parameters

      • data: Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike> | null>

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Enables forward-secrecy ratchets on this destination (§7.4).

      Generates the initial ratchet keypair. The newest ratchet public key is then embedded in subsequent announces, and inbound packets are decrypted against the private ring before the long-term key. Ratchet private keys are held in memory only for now (persistence lands with the storage layer); a restart therefore rotates the ratchet.

      Returns Promise<void>

    • Encrypts data for this destination's identity.

      Parameters

      • data: Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Gets the salt for key derivation.

      Returns Uint8Array<ArrayBufferLike>

    • Handles incoming packets routed to this destination.

      Parameters

      • packet: Packet
      • receivingInterface: Interface

      Returns Promise<void>

    • Registers a server-side REQUEST handler for a path string (PROTOCOL-SPEC.md §11.3, §11.4).

      The path is hashed to SHA-256(path)[:16] and stored keyed by that hash; the path string itself never appears on the wire. When a REQUEST arrives on a Link whose responder destination is this one, Link._handleRequest looks the handler up by the path hash, enforces the allow mode, and invokes responseGenerator to produce the response value.

      Parameters

      • path: string

        Opaque path token (e.g. "/page/index.mu").

      • options: {
            allow?: number;
            allowedList?: Uint8Array<ArrayBufferLike>[];
            autoCompress?: boolean;
            responseGenerator: RequestGenerator;
        }
        • Optionalallow?: number

          Authorization mode.

        • OptionalallowedList?: Uint8Array<ArrayBufferLike>[]

          Identity hashes permitted under Allow.LIST.

        • OptionalautoCompress?: boolean

          Hint for the (future) Resource response path.

        • responseGenerator: RequestGenerator

          Produces the response value.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      the 16-byte path hash the handler is keyed under.

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Removes a previously registered REQUEST handler.

      Parameters

      • path: string

      Returns Promise<boolean>

      true if a handler was removed.

    • Responds to an incoming LINKREQUEST by accepting the link.

      Delegates to Link.accept, which derives the link_id, generates the responder ephemeral key, derives the session keys, builds and sends the LRPROOF, and registers the link with the transport.

      Parameters

      Returns Promise<Link>

    • Rotates the ratchet ring when the interval has elapsed (Destination.RATCHET_INTERVAL), inserting the newest key at index 0 and capping the ring to Destination.MAX_RATCHETS. Pass force to generate a key unconditionally (used for the initial key).

      No-op when ratchets are not enabled.

      Parameters

      • Optionalforce: boolean = false

      Returns Promise<void>

    • Encrypts the packet payload for this destination and sends it via the bound transport.

      Parameters

      Returns Promise<void>

    • Static factory for creating a destination.

      Parameters

      • name: string
      • direction: number
      • type: number
      • identity: Identity | null = null
      • interfaceLayer: Reticulum | null = null

        An object that manages destinations and dispatches link requests.

      Returns Promise<Destination>

    • Creates an IN destination.

      Parameters

      • name: string
      • type: number
      • identity: Identity | null = null
      • interfaceLayer: Reticulum | null = null

        An object that manages destinations and dispatches link requests.

      Returns Promise<Destination>

    • Creates an OUT destination.

      Parameters

      • name: string
      • type: number
      • identity: Identity | null = null
      • interfaceLayer: Reticulum | null = null

        An object that manages destinations and dispatches link requests.

      Returns Promise<Destination>

    • Recall an identity for a destination or identity hash.

      Parameters

      • targetHash: Uint8Array<ArrayBufferLike>
      • fromIdentityHash: boolean = false

      Returns Promise<Identity | null>

    • Recalls the ratchet ring for a destination (newest first), or null.

      Consumed by the inbound-decrypt tolerance path (SPEC.md §7.4): a sender may have encrypted to a just-rotated previous ratchet, so the receiver tries each privkey in the ring before falling back to the long-term key.

      Parameters

      • destinationHash: Uint8Array<ArrayBufferLike>

      Returns Uint8Array<ArrayBufferLike>[] | null

    • Remember a destination.

      Parameters

      • packetHash: Uint8Array<ArrayBufferLike>
      • destinationHash: Uint8Array<ArrayBufferLike>
      • publicKey: Uint8Array<ArrayBufferLike>
      • appData: any = null

      Returns Promise<void>

    • Remembers a ratchet X25519 public key announced for a destination (SPEC.md §4.5 step 6.2). Called only for validated announces where context_flag was set and the ratchet is non-empty. Newest ratchets are prepended so the ring is newest-first; duplicates are skipped.

      Parameters

      • destinationHash: Uint8Array<ArrayBufferLike>
      • ratchet: Uint8Array<ArrayBufferLike>

        32-byte ratchet X25519 public key.

      Returns void