@@ -31,7 +31,7 @@ public LoginContext()
31
31
32
32
internal string V2TwoFactorToken { get ; set ; }
33
33
34
- public ECPrivateKeyParameters DeviceKey { get ; set ; }
34
+ public ECPrivateKeyParameters DeviceKey { get ; set ; }
35
35
36
36
public byte [ ] MessageSessionUid { get ; }
37
37
internal Queue < string > PasswordQueue { get ; } = new Queue < string > ( ) ;
@@ -199,7 +199,7 @@ private static async Task RegisterDeviceInRegion(this IAuth auth, IDeviceConfigu
199
199
#endif
200
200
try
201
201
{
202
- await auth . Endpoint . ExecuteRest ( "authentication/register_device_in_region" , new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
202
+ await auth . Endpoint . ExecuteRest ( "authentication/register_device_in_region" , new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
203
203
}
204
204
catch ( KeeperApiException kae )
205
205
{
@@ -234,7 +234,7 @@ private static async Task<IDeviceConfiguration> RegisterDevice(this IAuth auth)
234
234
#if DEBUG
235
235
Debug . WriteLine ( $ "REST Request: endpoint \" register_device\" : { request } ") ;
236
236
#endif
237
- var rs = await auth . Endpoint . ExecuteRest ( "authentication/register_device" , new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
237
+ var rs = await auth . Endpoint . ExecuteRest ( "authentication/register_device" , new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
238
238
var response = Device . Parser . ParseFrom ( rs ) ;
239
239
#if DEBUG
240
240
Debug . WriteLine ( $ "REST Response: endpoint \" register_device\" : { response } ") ;
@@ -264,7 +264,7 @@ private static async Task RequestDeviceVerification(this IAuth auth, LoginContex
264
264
Debug . WriteLine ( $ "REST Request: endpoint \" request_device_verification\" : { request } ") ;
265
265
#endif
266
266
await auth . Endpoint . ExecuteRest ( "authentication/request_device_verification" ,
267
- new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
267
+ new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
268
268
}
269
269
270
270
internal static async Task ValidateDeviceVerificationCode ( this IAuth auth , LoginContext v3 , string code )
@@ -281,7 +281,7 @@ internal static async Task ValidateDeviceVerificationCode(this IAuth auth, Login
281
281
Debug . WriteLine ( $ "REST Request: endpoint \" validate_device_verification_code\" : { request } ") ;
282
282
#endif
283
283
await auth . Endpoint . ExecuteRest ( "authentication/validate_device_verification_code" ,
284
- new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
284
+ new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
285
285
}
286
286
287
287
internal static Task < T > ResumeLogin < T > (
@@ -460,16 +460,16 @@ private static async Task<AuthContext> ExecuteValidatePassword(
460
460
}
461
461
462
462
private static async Task < AuthContext > ExecuteValidateAuthHash (
463
- this IAuth auth ,
464
- LoginContext v3 ,
463
+ this IAuth auth ,
464
+ LoginContext v3 ,
465
465
ValidateAuthHashRequest request ,
466
466
Func < EncryptedDataKeyType , byte [ ] , byte [ ] > dataKeyDecryptor )
467
467
{
468
468
#if DEBUG
469
469
Debug . WriteLine ( $ "REST Request: endpoint \" validate_auth_hash\" : { request } ") ;
470
470
#endif
471
471
var rs = await auth . Endpoint . ExecuteRest ( "authentication/validate_auth_hash" ,
472
- new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
472
+ new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
473
473
var response = LoginResponse . Parser . ParseFrom ( rs ) ;
474
474
#if DEBUG
475
475
Debug . WriteLine ( $ "REST response: endpoint \" validate_auth_hash\" : { response } ") ;
@@ -519,7 +519,7 @@ internal static MasterPasswordInfo ValidateAuthHashPrepare(
519
519
if ( saltInfo == null )
520
520
{
521
521
throw new KeeperStartLoginException (
522
- LoginState . RequiresAuthHash ,
522
+ LoginState . RequiresAuthHash ,
523
523
"Master Password has not been created." ) ;
524
524
}
525
525
@@ -653,7 +653,7 @@ bool NotificationCallback(NotificationEvent message)
653
653
auth . PushNotifications ? . RegisterCallback ( NotificationCallback ) ;
654
654
655
655
return Tuple . Create < IDeviceApprovalChannelInfo [ ] , Action > (
656
- new IDeviceApprovalChannelInfo [ ] { email , push , otp } ,
656
+ new IDeviceApprovalChannelInfo [ ] { email , push , otp } ,
657
657
( ) => { auth . PushNotifications ? . RemoveCallback ( NotificationCallback ) ; } ) ;
658
658
}
659
659
@@ -715,7 +715,7 @@ private static async Task ExecutePushAction(this IAuth auth, TwoFactorSendPushRe
715
715
#if DEBUG
716
716
Debug . WriteLine ( $ "REST Request: endpoint \" 2fa_send_push\" : { request } ") ;
717
717
#endif
718
- await auth . Endpoint . ExecuteRest ( "authentication/2fa_send_push" , new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
718
+ await auth . Endpoint . ExecuteRest ( "authentication/2fa_send_push" , new ApiRequestPayload { Payload = request . ToByteString ( ) } ) ;
719
719
}
720
720
721
721
private static async Task < TwoFactorValidateResponse > ExecuteTwoFactorValidateCode ( this IAuth auth , TwoFactorValidateRequest request )
@@ -792,15 +792,15 @@ TwoFactorCodeActionDelegate GetCodeDelegate(ITwoFactorAppCodeInfo channel, TwoFa
792
792
totp . InvokeTwoFactorCodeAction = GetCodeDelegate ( totp , ch ) ;
793
793
availableChannels . Add ( totp ) ;
794
794
}
795
- break ;
795
+ break ;
796
796
797
797
case TwoFactorChannelType . TwoFaCtRsa :
798
798
{
799
799
var rsa = new RsaSecurIdTwoFactorChannel ( ) ;
800
800
rsa . InvokeTwoFactorCodeAction = GetCodeDelegate ( rsa , ch ) ;
801
801
availableChannels . Add ( rsa ) ;
802
802
}
803
- break ;
803
+ break ;
804
804
805
805
case TwoFactorChannelType . TwoFaCtSms :
806
806
{
@@ -812,7 +812,7 @@ TwoFactorCodeActionDelegate GetCodeDelegate(ITwoFactorAppCodeInfo channel, TwoFa
812
812
sms . InvokeTwoFactorCodeAction = GetCodeDelegate ( sms , ch ) ;
813
813
availableChannels . Add ( sms ) ;
814
814
}
815
- break ;
815
+ break ;
816
816
817
817
case TwoFactorChannelType . TwoFaCtDuo :
818
818
{
@@ -842,7 +842,7 @@ TwoFactorCodeActionDelegate GetCodeDelegate(ITwoFactorAppCodeInfo channel, TwoFa
842
842
duoTfa . InvokeTwoFactorCodeAction = GetCodeDelegate ( duoTfa , ch ) ;
843
843
availableChannels . Add ( duoTfa ) ;
844
844
}
845
- break ;
845
+ break ;
846
846
847
847
case TwoFactorChannelType . TwoFaCtDna :
848
848
{
@@ -854,30 +854,31 @@ TwoFactorCodeActionDelegate GetCodeDelegate(ITwoFactorAppCodeInfo channel, TwoFa
854
854
dna2Fa . InvokeTwoFactorCodeAction = GetCodeDelegate ( dna2Fa , ch ) ;
855
855
availableChannels . Add ( dna2Fa ) ;
856
856
}
857
- break ;
857
+ break ;
858
858
859
- case TwoFactorChannelType . TwoFaCtU2F :
859
+ case TwoFactorChannelType . TwoFaCtWebauthn :
860
860
if ( auth . AuthCallback is IAuthSecurityKeyUI keyUi )
861
861
{
862
862
try
863
863
{
864
- var rqs = JsonUtils . ParseJson < SecurityKeyRequest > ( Encoding . UTF8 . GetBytes ( ch . Challenge ) ) ;
865
- var key2Fa = new TwoFactorSecurityKeyChannel ( ) ;
866
- key2Fa . InvokeTwoFactorPushAction = ( action ) =>
864
+ var rqs = JsonUtils . ParseJson < KeeperWebAuthnRequest > ( Encoding . UTF8 . GetBytes ( ch . Challenge ) ) ;
865
+ var key2Fa = new TwoFactorSecurityKeyChannel
867
866
{
868
- return Task . Run ( async ( ) =>
867
+ InvokeTwoFactorPushAction = async ( action ) =>
869
868
{
870
- var signature = await keyUi . AuthenticateRequests ( rqs . authenticateRequests ) ;
869
+ var signature = keyUi . AuthenticatePublicKeyRequest ( rqs . publicKeyCredentialRequestOptions ) . GetAwaiter ( ) . GetResult ( ) ;
870
+
871
871
var request = new TwoFactorValidateRequest
872
872
{
873
+ ChannelUid = ch . ChannelUid ,
873
874
EncryptedLoginToken = loginToken ,
874
875
ExpireIn = TwoFactorExpiration . TwoFaExpImmediately ,
875
- ValueType = ch . ChannelType == TwoFactorChannelType . TwoFaCtWebauthn ? TwoFactorValueType . TwoFaRespWebauthn : TwoFactorValueType . TwoFaRespU2F ,
876
+ ValueType = TwoFactorValueType . TwoFaRespWebauthn ,
876
877
Value = signature ,
877
878
} ;
878
879
var validateRs = await auth . ExecuteTwoFactorValidateCode ( request ) ;
879
880
onLoginToken ( validateRs . EncryptedLoginToken ) ;
880
- } ) ;
881
+ }
881
882
} ;
882
883
availableChannels . Add ( key2Fa ) ;
883
884
}
@@ -888,7 +889,8 @@ TwoFactorCodeActionDelegate GetCodeDelegate(ITwoFactorAppCodeInfo channel, TwoFa
888
889
}
889
890
890
891
break ;
891
- case TwoFactorChannelType . TwoFaCtWebauthn :
892
+
893
+ case TwoFactorChannelType . TwoFaCtU2F :
892
894
case TwoFactorChannelType . TwoFaCtKeeper :
893
895
break ;
894
896
}
@@ -1109,7 +1111,7 @@ public static async Task RequestCreateUser(this IAuth auth, LoginContext v3, str
1109
1111
{
1110
1112
Payload = request . ToByteString ( )
1111
1113
} ;
1112
-
1114
+
1113
1115
Debug . WriteLine ( $ "REST Request: endpoint \" request_create_user\" : { request } ") ;
1114
1116
await auth . Endpoint . ExecuteRest ( "authentication/request_create_user" , apiRequest ) ;
1115
1117
}
@@ -1156,7 +1158,7 @@ private static async Task<DeviceVerificationResponse> RequestDeviceAdminApproval
1156
1158
#if DEBUG
1157
1159
Debug . WriteLine ( $ "REST Request: endpoint \" request_device_admin_approval\" : { request } ") ;
1158
1160
#endif
1159
- var payload = new ApiRequestPayload { Payload = request . ToByteString ( ) } ;
1161
+ var payload = new ApiRequestPayload { Payload = request . ToByteString ( ) } ;
1160
1162
var rs = await auth . Endpoint . ExecuteRest ( "authentication/request_device_admin_approval" , payload ) ;
1161
1163
DeviceVerificationResponse response = null ;
1162
1164
if ( rs ? . Length > 0 )
@@ -1218,7 +1220,7 @@ bool ProcessDataKeyRequest(NotificationEvent message)
1218
1220
auth . PushNotifications ? . RegisterCallback ( ProcessDataKeyRequest ) ;
1219
1221
1220
1222
return Tuple . Create < IDataKeyChannelInfo [ ] , Action > (
1221
- new IDataKeyChannelInfo [ ] { pushChannel , adminChannel } ,
1223
+ new IDataKeyChannelInfo [ ] { pushChannel , adminChannel } ,
1222
1224
( ) => { auth . PushNotifications ? . RemoveCallback ( ProcessDataKeyRequest ) ; }
1223
1225
) ;
1224
1226
}
0 commit comments