State machine for verification requests. Things that differ based on what channel is used to send and receive verification events are put in InRoomChannel or ToDeviceChannel.

Avoid direct references: instead prefer Crypto.VerificationRequest.

Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

_cancellingUserId?: string
channel: C

Accessors

  • get initiatedByMe(): boolean
  • Whether this request was initiated by the syncing user. For InRoomChannel, this is who sent the .request event. For ToDeviceChannel, this is who sent the .start event

    Returns boolean

  • get transactionId(): undefined | string
  • Unique ID for this verification request.

    An ID isn't assigned until the first message is sent, so this may be undefined in the early phases.

    Returns undefined | string

Methods

  • Cancels the request, sending a cancellation to the other party

    Parameters

    • params: {
          code: undefined | string;
          reason: undefined | string;
      } = {}
      • code: undefined | string

        the error code to send the cancellation with

      • reason: undefined | string

        the error reason to send the cancellation with

    Returns Promise<void>

    resolves when the event has been sent.

  • Changes the state of the request and verifier in response to a key verification event.

    Parameters

    • type: string

      the "symbolic" event type, as returned by the getEventType function on the channel.

    • event: MatrixEvent

      the event to handle. Don't call getType() on it but use the type parameter instead.

    • isLiveEvent: boolean

      whether this is an even received through sync or not

    • isRemoteEcho: boolean

      whether this is the remote echo of an event sent by the same device

    • isSentByUs: boolean

      whether this event is sent by a party that can accept and/or observe the request like one of our peers. For InRoomChannel this means any device for the syncing user. For ToDeviceChannel, just the syncing device.

    Returns Promise<void>

    a promise that resolves when any requests as an answer to the passed-in event are sent.

  • Adds the listener function to the end of the listeners array for the event named event.

    No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times.

    By default, event listeners are invoked in the order they are added. The prependListener method can be used as an alternative to add the event listener to the beginning of the listeners array.

    Type Parameters

    Parameters

    Returns this

    a reference to the EventEmitter, so that calls can be chained.

  • Checks whether the other party supports a given verification method. This is useful when setting up the QR code UI, as it is somewhat asymmetrical: if the other party supports SCAN_QR, we should show a QR code in the UI, and vice versa. For methods that need to be supported by both ends, use the methods property.

    Parameters

    • method: string

      the method to check

    • force: boolean = false

      to check even if the phase is not ready or started yet, internal usage

    Returns boolean

    whether or not the other party said the supported the method

  • Stateless validation logic not specific to the channel. Invoked by the same static method in either channel.

    Parameters

    • type: string

      the "symbolic" event type, as returned by the getEventType function on the channel.

    • event: MatrixEvent

      the event to validate. Don't call getType() on it but use the type parameter instead.

    • client: MatrixClient

      the client to get the current user and device id from

    Returns boolean

    whether the event is valid and should be passed to handleEvent