reticulum-js
    Preparing search index...

    Class LXMessage

    Represents an LXMF message.

    Index
    • Constructs an LXMF message.

      Parameters

      • options: {
            content?: string;
            destinationHash: Uint8Array<ArrayBufferLike>;
            fields?: Record<string, any> | Map<string, any>;
            messageId?: Uint8Array<ArrayBufferLike>;
            signature?: Uint8Array<ArrayBufferLike>;
            signedPart?: Uint8Array<ArrayBufferLike>;
            sourceHash: Uint8Array<ArrayBufferLike>;
            stamp?: Uint8Array<ArrayBufferLike>;
            timestamp?: number;
            title?: string;
        }
        • Optionalcontent?: string
        • destinationHash: Uint8Array<ArrayBufferLike>
        • Optionalfields?: Record<string, any> | Map<string, any>
        • OptionalmessageId?: Uint8Array<ArrayBufferLike>

          SHA-256 of the hashed part (§5.5).

        • Optionalsignature?: Uint8Array<ArrayBufferLike>
        • OptionalsignedPart?: Uint8Array<ArrayBufferLike>
        • sourceHash: Uint8Array<ArrayBufferLike>
        • Optionalstamp?: Uint8Array<ArrayBufferLike>

          Optional proof-of-work stamp (§5.7).

        • Optionaltimestamp?: number
        • Optionaltitle?: string

      Returns LXMessage

    _decodedPayload: any[] | null
    content: string | undefined
    destinationHash: Uint8Array<ArrayBufferLike>
    fields: Record<string, any> | Map<string, any>
    messageId: Uint8Array<ArrayBufferLike> | null
    signature: Uint8Array<ArrayBufferLike> | undefined
    signedPart: Uint8Array<ArrayBufferLike> | undefined
    sourceHash: Uint8Array<ArrayBufferLike>
    stamp: Uint8Array<ArrayBufferLike> | null
    timestamp: number
    title: string | undefined
    • Serializes the Message into the LXMF wire format.

      If this.stamp is set (e.g. a proof-of-work stamp from the Stamper, or a ticket-derived stamp), it is appended as the 5th payload element. The signature and message_id are always computed over the 4-element payload (§5.5), so adding or removing a stamp never invalidates the signature.

      Parameters

      Returns Promise<{ messageId: Uint8Array; wireData: Uint8Array }>

    • Serializes and encrypts the message into the paper delivery form, ready to be encoded as an lxm:// URI or QR code (LXMessage.pack() PAPER branch).

      The encrypted paper payload must fit within PAPER_MDU bytes (the QR-code capacity); a TypeError is thrown otherwise, mirroring the Python reference.

      Parameters

      • sourceIdentity: Identity
      • outboundDestination: Destination

        recipient lxmf.delivery destination (Direction.OUT; holds the recipient public key + recalled ratchet).

      Returns Promise<
          { paperData: Uint8Array; transientId: Uint8Array; wireData: Uint8Array },
      >

      when the encrypted paper payload exceeds PAPER_MDU.

    • Serializes, encrypts, and encodes the message as an lxm:// URI (LXMessage.as_uri): the URL-safe base64 of the paper payload, padding stripped, prefixed with the lxm scheme.

      Parameters

      Returns Promise<string>

    • Packs this message into the propagation ("lxmf_data") form used when submitting to a propagation node or syncing between nodes (§5.3):

      lxmf_data = destination_hash(16) || E_outbound(source_hash(16) || signature(64) || payload)

      Only the leading destination hash is in cleartext (so the node can route by recipient and compute the dedup key); the body is encrypted to the recipient (using their recalled ratchet when one is known, §7.4). The transientId is SHA-256 over the whole lxmf_data and is the store/ dedup key (LXMRouter.lxmf_propagation).

      Serializes first if needed.

      Parameters

      • sourceIdentity: Identity
      • outboundDestination: Destination

        recipient lxmf.delivery destination (Direction.OUT; holds the recipient public key + recalled ratchet). Must share this message's destinationHash.

      Returns Promise<{ lxmfData: Uint8Array; transientId: Uint8Array; wireData: Uint8Array }>

    • Verifies the message signature against a sender identity, tolerating msgpack encoder variance per §5.6.

      Two candidate signed buffers are tried:

      1. this.signedPart — computed from the raw wire payload (unstamped) or the stamp-stripped re-pack (stamped).
      2. A freshly re-encoded 4-element payload, for messages that passed through a re-encoding relay whose bytes diverge from the signer's.

      Parameters

      • identity: Identity

        The sender's identity.

      Returns Promise<boolean>

    • Creates a Message from wire data.

      Accepts both the direct layout (dest+source+signature+payload) and the opportunistic layout (source+signature+payload, with the destination hash supplied separately via expectedDestinationHash).

      If the payload carries an optional 5th stamp element (§5.7.1), it is stripped and the first four elements are re-packed before the message_id and signed_part are computed — exactly matching the upstream Python unpack_from_bytes behaviour, so a stamp never invalidates the signature.

      Parameters

      • wireData: Uint8Array<ArrayBufferLike>
      • OptionalexpectedDestinationHash: Uint8Array<ArrayBufferLike>

        Required for opportunistic delivery.

      Returns Promise<LXMessage>

    • Decrypts and reconstructs an LXMF message from raw paper data. The paper form is byte-identical to the propagation lxmf_data form, so this delegates to Message.fromPropagationData (LXMRouter.lxmf_propagation with is_paper_message=True).

      Parameters

      • paperData: Uint8Array<ArrayBufferLike>
      • deliveryDestination: Destination

        recipient's inbound lxmf.delivery destination.

      Returns Promise<LXMessage | null>

      null when decryption fails (wrong recipient / unknown ratchet) or the input is too short.

    • Decrypts and reconstructs an LXMF message from its propagation ("lxmf_data") form (§5.3). The destination hash is taken from the leading 16 bytes; the remainder is decrypted with the recipient's inbound lxmf.delivery destination (long-term key + owned ratchet ring, §7.4).

      Parameters

      • lxmfData: Uint8Array<ArrayBufferLike>
      • deliveryDestination: Destination

        recipient's inbound lxmf.delivery destination.

      Returns Promise<LXMessage | null>

      null when decryption fails (wrong recipient / unknown ratchet) or the input is too short.

    • Parses an lxm:// URI back into the raw encrypted paper data (LXMRouter.ingest_lxm_uri). The scheme match is case-insensitive and any stray / characters in the body are tolerated, matching the Python reference's lenient decoding.

      Parameters

      • uri: string

      Returns Uint8Array<ArrayBufferLike>

      when the URI does not use the lxm scheme.

    • Formats raw paper data as an lxm:// URI.

      Parameters

      • paperData: Uint8Array<ArrayBufferLike>

      Returns string

    • Computes the propagation dedup key transient_id = SHA-256(lxmf_data) (LXMRouter.lxmf_propagation). Identical on both client and node.

      Parameters

      • lxmfData: Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>