Skip to content

VerificationRequest

Defined in: src/crypto-api/verification.ts:23

An incoming, or outgoing, request to verify a user or a device via cross-signing.

get accepting(): boolean

Defined in: src/crypto-api/verification.ts:70

True if we have started the process of sending an m.key.verification.ready (but have not necessarily received the remote echo which causes a transition to VerificationPhase.Ready.

boolean


get cancellationCode(): string | null

Defined in: src/crypto-api/verification.ts:161

If this request has been cancelled, the cancellation code (e.g m.user) which is responsible for cancelling this verification.

string | null


get cancellingUserId(): string | undefined

Defined in: src/crypto-api/verification.ts:168

The id of the user that cancelled the request.

Only defined when phase is Cancelled

string | undefined


get chosenMethod(): string | null

Defined in: src/crypto-api/verification.ts:89

the method picked in the .start event

string | null


get declining(): boolean

Defined in: src/crypto-api/verification.ts:76

True if we have started the process of sending an m.key.verification.cancel (but have not necessarily received the remote echo which causes a transition to VerificationPhase.Cancelled).

boolean


get initiatedByMe(): boolean

Defined in: src/crypto-api/verification.ts:47

True if this request was initiated by the local client.

For in-room verifications, the initiator is who sent the m.key.verification.request event. For to-device verifications, the initiator is who sent the m.key.verification.start event.

boolean


get isSelfVerification(): boolean

Defined in: src/crypto-api/verification.ts:56

True if the other party in this request is one of this user’s own devices.

boolean


get methods(): string[]

Defined in: src/crypto-api/verification.ts:86

once the phase is Started (and !initiatedByMe) or Ready: common methods supported by both sides

string[]


get otherDeviceId(): string | undefined

Defined in: src/crypto-api/verification.ts:53

For verifications via to-device messages: the ID of the other device. Otherwise, undefined.

string | undefined


get otherUserId(): string

Defined in: src/crypto-api/verification.ts:50

The user id of the other party in this request

string


get pending(): boolean

Defined in: src/crypto-api/verification.ts:64

True if the request has sent its initial event and needs more events to complete (ie it is in phase Requested, Ready or Started).

boolean


get phase(): VerificationPhase

Defined in: src/crypto-api/verification.ts:59

current phase of the request.

VerificationPhase


get roomId(): string | undefined

Defined in: src/crypto-api/verification.ts:39

For an in-room verification, the ID of the room.

For to-device verifictions, undefined.

string | undefined


get timeout(): number | null

Defined in: src/crypto-api/verification.ts:83

The remaining number of ms before the request will be automatically cancelled.

null indicates that there is no timeout

number | null


get transactionId(): string | undefined

Defined in: src/crypto-api/verification.ts:32

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.

string | undefined


get verifier(): Verifier | undefined

Defined in: src/crypto-api/verification.ts:147

The verifier which is doing the actual verification, once the method has been established. Only defined when the phase is Started.

Verifier | undefined

optional [captureRejectionSymbol]<K>(error, event, …args): void

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:103

K

Error

string | symbol

AnyRest

void

TypedEventEmitter.[captureRejectionSymbol]


accept(): Promise<void>

Defined in: src/crypto-api/verification.ts:107

Accepts the request, sending a .ready event to the other party

Promise<void>

Promise which resolves when the event has been sent.


addListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:70

Alias for on.

T extends EventEmitterEvents | Change

T

Listener<Change, VerificationRequestEventHandlerMap, T>

this

TypedEventEmitter.addListener


cancel(params?): Promise<void>

Defined in: src/crypto-api/verification.ts:117

Cancels the request, sending a cancellation to the other party

Details for the cancellation, including reason (defaults to “User declined”), and code (defaults to m.user). Deprecated: this parameter is ignored by the Rust cryptography implementation.

string

string

Promise<void>

Promise which resolves when the event has been sent.


emit<T>(event, …args): boolean

Defined in: src/models/typed-event-emitter.ts:86

Synchronously calls each of the listeners registered for the event named event, in the order they were registered, passing the supplied arguments to each.

T extends Change

T

The name of the event to emit

Parameters<VerificationRequestEventHandlerMap[T]>

Arguments to pass to the listener

boolean

true if the event had listeners, false otherwise.

TypedEventEmitter.emit

emit<T>(event, …args): boolean

Defined in: src/models/typed-event-emitter.ts:87

Synchronously calls each of the listeners registered for the event named event, in the order they were registered, passing the supplied arguments to each.

T extends Change

T

The name of the event to emit

Parameters<VerificationRequestEventHandlerMap[T]>

Arguments to pass to the listener

boolean

true if the event had listeners, false otherwise.

TypedEventEmitter.emit


emitPromised<T>(event, …args): Promise<boolean>

Defined in: src/models/typed-event-emitter.ts:98

Similar to emit but calls all listeners within a Promise.all and returns the promise chain

T extends Change

T

The name of the event to emit

Parameters<VerificationRequestEventHandlerMap[T]>

Arguments to pass to the listener

Promise<boolean>

true if the event had listeners, false otherwise.

TypedEventEmitter.emitPromised

emitPromised<T>(event, …args): Promise<boolean>

Defined in: src/models/typed-event-emitter.ts:102

Similar to emit but calls all listeners within a Promise.all and returns the promise chain

T extends Change

T

The name of the event to emit

Parameters<VerificationRequestEventHandlerMap[T]>

Arguments to pass to the listener

Promise<boolean>

true if the event had listeners, false otherwise.

TypedEventEmitter.emitPromised


eventNames(): (string | symbol)[]

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:967

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]

(string | symbol)[]

v6.0.0

TypedEventEmitter.eventNames


generateQRCode(): Promise<Uint8ClampedArray<ArrayBufferLike> | undefined>

Defined in: src/crypto-api/verification.ts:155

Generate the data for a QR code allowing the other device to verify this one, if it supports it.

Only returns data once phase is VerificationPhase.Ready and the other party can scan a QR code; otherwise returns undefined.

Promise<Uint8ClampedArray<ArrayBufferLike> | undefined>


getMaxListeners(): number

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:819

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.

number

v1.0.0

TypedEventEmitter.getMaxListeners


listenerCount(event): number

Defined in: src/models/typed-event-emitter.ts:115

Returns the number of listeners listening to the event named event.

EventEmitterEvents | Change

The name of the event being listened for

number

TypedEventEmitter.listenerCount


listeners(event): Function[]

Defined in: src/models/typed-event-emitter.ts:122

Returns a copy of the array of listeners for the event named event.

EventEmitterEvents | Change

Function[]

TypedEventEmitter.listeners


off<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:129

Alias for removeListener

T extends EventEmitterEvents | Change

T

Listener<Change, VerificationRequestEventHandlerMap, T>

this

TypedEventEmitter.off


on<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:150

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.

T extends EventEmitterEvents | Change

T

The name of the event.

Listener<Change, VerificationRequestEventHandlerMap, T>

The callback function

this

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

TypedEventEmitter.on


once<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:169

Adds a one-time listener function for the event named event. The next time event is triggered, this listener is removed and then invoked.

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

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

T extends EventEmitterEvents | Change

T

The name of the event.

Listener<Change, VerificationRequestEventHandlerMap, T>

The callback function

this

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

TypedEventEmitter.once


otherPartySupportsMethod(method): boolean

Defined in: src/crypto-api/verification.ts:100

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.

string

the method to check

boolean

true if the other party said they supported the method


prependListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:186

Adds the listener function to the beginning 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.

T extends EventEmitterEvents | Change

T

The name of the event.

Listener<Change, VerificationRequestEventHandlerMap, T>

The callback function

this

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

TypedEventEmitter.prependListener


prependOnceListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:202

Adds a one-timelistener function for the event named event to the beginning of the listeners array. The next time event is triggered, this listener is removed, and then invoked.

T extends EventEmitterEvents | Change

T

The name of the event.

Listener<Change, VerificationRequestEventHandlerMap, T>

The callback function

this

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

TypedEventEmitter.prependOnceListener


rawListeners(event): Function[]

Defined in: src/models/typed-event-emitter.ts:243

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

EventEmitterEvents | Change

Function[]

TypedEventEmitter.rawListeners


removeAllListeners(event?): this

Defined in: src/models/typed-event-emitter.ts:219

Removes all listeners, or those of the specified event.

It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

EventEmitterEvents | Change

The name of the event. If undefined, all listeners everywhere are removed.

this

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

TypedEventEmitter.removeAllListeners


removeListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:232

Removes the specified listener from the listener array for the event named event.

T extends EventEmitterEvents | Change

T

Listener<Change, VerificationRequestEventHandlerMap, T>

this

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

TypedEventEmitter.removeListener


scanQRCode(qrCodeData): Promise<Verifier>

Defined in: src/crypto-api/verification.ts:141

Start a QR code verification by providing a scanned QR code for this verification flow.

Validates the QR code, and if it is ok, sends an m.key.verification.start event with method set to m.reciprocate.v1, to tell the other side the scan was successful.

See also VerificationRequest#startVerification which can be used to start other verification methods.

Uint8ClampedArray

the decoded QR code.

Promise<Verifier>

A verifier; call .verify() on it to wait for the other side to complete the verification flow.


setMaxListeners(n): this

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:813

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

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

number

this

v0.3.5

TypedEventEmitter.setMaxListeners


startVerification(method): Promise<Verifier>

Defined in: src/crypto-api/verification.ts:128

Send an m.key.verification.start event to start verification via a particular method.

This is normally used when starting a verification via emojis (ie, method is set to m.sas.v1).

string

the name of the verification method to use.

Promise<Verifier>

The verifier which will do the actual verification.