Skip to content

Verifier

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

A Verifier is responsible for performing the verification using a particular method, such as via QR code or SAS (emojis).

A verifier object can be created by calling VerificationRequest.beginVerification; one is also created automatically when a m.key.verification.start event is received for an existing VerificationRequest.

Once a verifier object is created, the verification can be started by calling the Verifier#verify method.

get hasBeenCancelled(): boolean

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

Returns true if the verification has been cancelled, either by us or the other side.

boolean


get userId(): string

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

The ID of the other user in the verification process.

string

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]


addListener<T>(event, listener): this

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

Alias for on.

T extends EventEmitterEvents | VerifierEvent

T

Listener<VerifierEvent, VerifierEventHandlerMap, T>

this

TypedEventEmitter.addListener


cancel(e): void

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

Cancel a verification.

We will send an m.key.verification.cancel if the verification is still in flight. The verification promise will reject, and a VerifierEvent.Cancel will be emitted.

Error

the reason for the cancellation.

void


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 VerifierEvent

T

The name of the event to emit

Parameters<VerifierEventHandlerMap[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 VerifierEvent

T

The name of the event to emit

Parameters<VerifierEventHandlerMap[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 VerifierEvent

T

The name of the event to emit

Parameters<VerifierEventHandlerMap[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 VerifierEvent

T

The name of the event to emit

Parameters<VerifierEventHandlerMap[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


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


getReciprocateQrCodeCallbacks(): ShowQrCodeCallbacks | null

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

Get the details for reciprocating QR code verification, if one is in progress

Returns null, unless this verifier is for reciprocating a QR-code-based verification (ie, the other user has already scanned our QR code), and we are waiting for the user to confirm.

ShowQrCodeCallbacks | null


getShowSasCallbacks(): ShowSasCallbacks | null

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

Get the details for an SAS verification, if one is in progress

Returns null, unless this verifier is for a SAS-based verification and we are waiting for the user to confirm the SAS matches.

ShowSasCallbacks | null


listenerCount(event): number

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

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

EventEmitterEvents | VerifierEvent

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 | VerifierEvent

Function[]

TypedEventEmitter.listeners


off<T>(event, listener): this

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

Alias for removeListener

T extends EventEmitterEvents | VerifierEvent

T

Listener<VerifierEvent, VerifierEventHandlerMap, 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 | VerifierEvent

T

The name of the event.

Listener<VerifierEvent, VerifierEventHandlerMap, 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 | VerifierEvent

T

The name of the event.

Listener<VerifierEvent, VerifierEventHandlerMap, T>

The callback function

this

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

TypedEventEmitter.once


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 | VerifierEvent

T

The name of the event.

Listener<VerifierEvent, VerifierEventHandlerMap, 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 | VerifierEvent

T

The name of the event.

Listener<VerifierEvent, VerifierEventHandlerMap, 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 | VerifierEvent

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 | VerifierEvent

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 | VerifierEvent

T

Listener<VerifierEvent, VerifierEventHandlerMap, T>

this

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

TypedEventEmitter.removeListener


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


verify(): Promise<void>

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

Start the key verification, if it has not already been started.

This means sending a m.key.verification.start if we are the first responder, or a m.key.verification.accept if the other side has already sent a start event.

Promise<void>

Promise which resolves when the verification has completed, or rejects if the verification is cancelled or times out.