Data for the QR code login mechanism.

The QrCodeData can be serialized and encoded as a QR code or it can be decoded from a QR code.

Constructors

  • Create new QrCodeData from a given public key, a rendezvous URL and, optionally, a server name for the homeserver.

    If a server name is given, then the QrCodeData mode will be QrCodeMode.Reciprocate, i.e. the QR code will contain data for the existing device to display the QR code.

    If no server name is given, the QrCodeData mode will be QrCodeMode.Login, i.e. the QR code will contain data for the new device to display the QR code.

    Parameters

    Returns QrCodeData

Properties

Get the mode of this QrCodeData instance.

Get the Curve25519 public key embedded in the QrCodeData.

This Curve25519 public key should be used to establish an ECIES (Elliptic Curve Integrated Encryption Scheme) channel with the other device.

rendezvousUrl: string

Get the URL of the rendezvous server which will be used to exchange messages between the two devices.

serverName: undefined | string

Get the server name of the homeserver which the new device will be logged in to.

This will be only available if the existing device has generated the QR code and the new device is the one scanning the QR code.

Methods

  • Returns void

  • Encode the QrCodeData into a string using base64.

    This format can be used for debugging purposes and the [QrcodeData::from_base64()] method can be used to parse the string again.

    Returns string

  • Encode the QrCodeData into a list of bytes.

    The list of bytes can be used by a QR code generator to create an image containing a QR code.

    Returns Uint8Array<ArrayBufferLike>

  • Attempt to decode a base64 encoded string into a QrCodeData object.

    Parameters

    • data: string

    Returns QrCodeData

  • Attempt to decode a slice of bytes into a QrCodeData object.

    The slice of bytes would generally be returned by a QR code decoder.

    Parameters

    • bytes: Uint8Array<ArrayBufferLike>

    Returns QrCodeData