@@ -10,24 +10,26 @@ import {
10
10
import { KeeperEndpoint , KeeperEnvironment } from "./endpoint" ;
11
11
import { KeyWrapper , platform } from "./platform" ;
12
12
import {
13
- decryptFromStorage ,
14
- generateEncryptionKey , wrapPassword ,
13
+ generateEncryptionKey ,
15
14
generateUidBytes ,
16
- isTwoFactorResultCode ,
17
15
normal64 ,
18
16
normal64Bytes ,
19
17
resolvablePromise ,
20
- webSafe64 ,
21
- webSafe64FromBytes
18
+ webSafe64FromBytes ,
19
+ wrapPassword
22
20
} from "./utils" ;
23
21
import {
24
22
accountSummaryMessage ,
25
23
getEnterprisePublicKeyMessage ,
26
- logoutV3Message , NN ,
24
+ logoutV3Message ,
25
+ NN ,
27
26
requestCreateUserMessage ,
28
27
requestDeviceAdminApprovalMessage ,
29
- requestDeviceVerificationMessage , RestActionMessage , RestInMessage ,
30
- RestMessage , RestOutMessage ,
28
+ requestDeviceVerificationMessage ,
29
+ RestActionMessage ,
30
+ RestInMessage ,
31
+ RestMessage ,
32
+ RestOutMessage ,
31
33
ssoServiceProviderRequestMessage ,
32
34
startLoginMessage ,
33
35
startLoginMessageFromSessionToken ,
@@ -37,6 +39,8 @@ import {
37
39
validateDeviceVerificationCodeMessage
38
40
} from './restMessages'
39
41
import { AccountSummary , Authentication } from './proto' ;
42
+ import { RestCommand } from './commands'
43
+ import { CloseReason , createAsyncSocket , SocketListener } from './socket' ;
40
44
import IStartLoginRequest = Authentication . IStartLoginRequest ;
41
45
import ITwoFactorSendPushRequest = Authentication . ITwoFactorSendPushRequest ;
42
46
import TwoFactorExpiration = Authentication . TwoFactorExpiration ;
@@ -46,8 +50,6 @@ import ISsoServiceProviderRequest = Authentication.ISsoServiceProviderRequest;
46
50
import LoginType = Authentication . LoginType ;
47
51
import LoginMethod = Authentication . LoginMethod ;
48
52
import IAccountSummaryElements = AccountSummary . IAccountSummaryElements ;
49
- import { RestCommand } from './commands'
50
- import { CloseReason , createAsyncSocket , SocketListener } from './socket' ;
51
53
52
54
function unifyLoginError ( e : any ) : LoginError {
53
55
if ( e instanceof Error ) {
@@ -680,7 +682,14 @@ export class Auth {
680
682
const processPushNotification = ( wssRs : Record < string , any > ) => {
681
683
if ( wssRs . event === 'received_totp' ) {
682
684
const token = wssRs . encryptedLoginToken ? normal64Bytes ( wssRs . encryptedLoginToken ) : loginToken
683
- resumeWithToken ( token )
685
+ if ( wssRs . passcode ) {
686
+ const tfaChannel = channels . find ( x => x . channel === DeviceVerificationMethods . TFA )
687
+ if ( tfaChannel && tfaChannel . validateCode ) {
688
+ tfaChannel . validateCode ( wssRs . passcode )
689
+ }
690
+ } else {
691
+ resumeWithToken ( token )
692
+ }
684
693
} else if ( wssRs . message === 'device_approved' ) {
685
694
if ( wssRs . approved ) {
686
695
resumeWithToken ( loginToken )
0 commit comments