@@ -15,8 +15,67 @@ limitations under the License.
15
15
*/
16
16
17
17
import { MatrixEvent } from "../models/event" ;
18
+ import { TypedEventEmitter } from "../models/typed-event-emitter" ;
18
19
19
- /** Events emitted by `Verifier`. */
20
+ /**
21
+ * A `Verifier` is responsible for performing the verification using a particular method, such as via QR code or SAS
22
+ * (emojis).
23
+ *
24
+ * A verifier object can be created by calling `VerificationRequest.beginVerification`; one is also created
25
+ * automatically when a `m.key.verification.start` event is received for an existing VerificationRequest.
26
+ *
27
+ * Once a verifier object is created, the verification can be started by calling the {@link Verifier#verify} method.
28
+ */
29
+ export interface Verifier extends TypedEventEmitter < VerifierEvent , VerifierEventHandlerMap > {
30
+ /**
31
+ * Returns true if the verification has been cancelled, either by us or the other side.
32
+ */
33
+ get hasBeenCancelled ( ) : boolean ;
34
+
35
+ /**
36
+ * The ID of the other user in the verification process.
37
+ */
38
+ get userId ( ) : string ;
39
+
40
+ /**
41
+ * Start the key verification, if it has not already been started.
42
+ *
43
+ * This means sending a `m.key.verification.start` if we are the first responder, or a `m.key.verification.accept`
44
+ * if the other side has already sent a start event.
45
+ *
46
+ * @returns Promise which resolves when the verification has completed, or rejects if the verification is cancelled
47
+ * or times out.
48
+ */
49
+ verify ( ) : Promise < void > ;
50
+
51
+ /**
52
+ * Cancel a verification.
53
+ *
54
+ * We will send an `m.key.verification.cancel` if the verification is still in flight. The verification promise
55
+ * will reject, and a {@link Crypto.VerifierEvent#Cancel} will be emitted.
56
+ *
57
+ * @param e - the reason for the cancellation.
58
+ */
59
+ cancel ( e : Error ) : void ;
60
+
61
+ /**
62
+ * Get the details for an SAS verification, if one is in progress
63
+ *
64
+ * Returns `null`, unless this verifier is for a SAS-based verification and we are waiting for the user to confirm
65
+ * the SAS matches.
66
+ */
67
+ getShowSasCallbacks ( ) : ShowSasCallbacks | null ;
68
+
69
+ /**
70
+ * Get the details for a QR code verification, if one is in progress
71
+ *
72
+ * Returns `null`, unless this verifier is for a QR-code-based verification and we are waiting for the user to
73
+ * confirm a match.
74
+ */
75
+ getShowQrCodeCallbacks ( ) : ShowQrCodeCallbacks | null ;
76
+ }
77
+
78
+ /** Events emitted by {@link Verifier} */
20
79
export enum VerifierEvent {
21
80
/**
22
81
* The verification has been cancelled, by us or the other side.
@@ -29,7 +88,7 @@ export enum VerifierEvent {
29
88
/**
30
89
* SAS data has been exchanged and should be displayed to the user.
31
90
*
32
- * The payload is the {@link ShowQrCodeCallbacks } object.
91
+ * The payload is the {@link ShowSasCallbacks } object.
33
92
*/
34
93
ShowSas = "show_sas" ,
35
94
0 commit comments