@@ -969,15 +969,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
969
969
) ;
970
970
return requests
971
971
. filter ( ( request ) => request . roomId === undefined )
972
- . map (
973
- ( request ) =>
974
- new RustVerificationRequest (
975
- this . olmMachine ,
976
- request ,
977
- this . outgoingRequestProcessor ,
978
- this . _supportedVerificationMethods ,
979
- ) ,
980
- ) ;
972
+ . map ( ( request ) => this . makeVerificationRequest ( request ) ) ;
981
973
}
982
974
983
975
/**
@@ -1002,12 +994,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
1002
994
const request = requests . find ( ( request ) => request . roomId ?. toString ( ) === roomId ) ;
1003
995
1004
996
if ( request ) {
1005
- return new RustVerificationRequest (
1006
- this . olmMachine ,
1007
- request ,
1008
- this . outgoingRequestProcessor ,
1009
- this . _supportedVerificationMethods ,
1010
- ) ;
997
+ return this . makeVerificationRequest ( request ) ;
1011
998
}
1012
999
}
1013
1000
@@ -1038,12 +1025,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
1038
1025
new RustSdkCryptoJs . EventId ( eventId ) ,
1039
1026
methods ,
1040
1027
) ;
1041
- return new RustVerificationRequest (
1042
- this . olmMachine ,
1043
- request ,
1044
- this . outgoingRequestProcessor ,
1045
- this . _supportedVerificationMethods ,
1046
- ) ;
1028
+ return this . makeVerificationRequest ( request ) ;
1047
1029
} finally {
1048
1030
userIdentity . free ( ) ;
1049
1031
}
@@ -1114,12 +1096,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
1114
1096
this . _supportedVerificationMethods . map ( verificationMethodIdentifierToMethod ) ,
1115
1097
) ;
1116
1098
await this . outgoingRequestProcessor . makeOutgoingRequest ( outgoingRequest ) ;
1117
- return new RustVerificationRequest (
1118
- this . olmMachine ,
1119
- request ,
1120
- this . outgoingRequestProcessor ,
1121
- this . _supportedVerificationMethods ,
1122
- ) ;
1099
+ return this . makeVerificationRequest ( request ) ;
1123
1100
} finally {
1124
1101
userIdentity . free ( ) ;
1125
1102
}
@@ -1152,12 +1129,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
1152
1129
this . _supportedVerificationMethods . map ( verificationMethodIdentifierToMethod ) ,
1153
1130
) ;
1154
1131
await this . outgoingRequestProcessor . makeOutgoingRequest ( outgoingRequest ) ;
1155
- return new RustVerificationRequest (
1156
- this . olmMachine ,
1157
- request ,
1158
- this . outgoingRequestProcessor ,
1159
- this . _supportedVerificationMethods ,
1160
- ) ;
1132
+ return this . makeVerificationRequest ( request ) ;
1161
1133
} finally {
1162
1134
device . free ( ) ;
1163
1135
}
@@ -1667,15 +1639,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
1667
1639
) ;
1668
1640
1669
1641
if ( request ) {
1670
- this . emit (
1671
- CryptoEvent . VerificationRequestReceived ,
1672
- new RustVerificationRequest (
1673
- this . olmMachine ,
1674
- request ,
1675
- this . outgoingRequestProcessor ,
1676
- this . _supportedVerificationMethods ,
1677
- ) ,
1678
- ) ;
1642
+ this . emit ( CryptoEvent . VerificationRequestReceived , this . makeVerificationRequest ( request ) ) ;
1679
1643
} else {
1680
1644
// There are multiple reasons this can happen; probably the most likely is that the event is an
1681
1645
// in-room event which is too old.
@@ -1685,6 +1649,17 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
1685
1649
}
1686
1650
}
1687
1651
1652
+ /** Utility function to wrap a rust `VerificationRequest` with our own {@link VerificationRequest}. */
1653
+ private makeVerificationRequest ( request : RustSdkCryptoJs . VerificationRequest ) : VerificationRequest {
1654
+ return new RustVerificationRequest (
1655
+ this . logger ,
1656
+ this . olmMachine ,
1657
+ request ,
1658
+ this . outgoingRequestProcessor ,
1659
+ this . _supportedVerificationMethods ,
1660
+ ) ;
1661
+ }
1662
+
1688
1663
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1689
1664
//
1690
1665
// Other public functions
0 commit comments