Skip to content

Commit bc524f2

Browse files
authored
BE-5264 - DNA never did device approval (#37)
1 parent 5fad05a commit bc524f2

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

keeperapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@keeper-security/keeperapi",
33
"description": "Keeper API Javascript SDK",
4-
"version": "16.0.47",
4+
"version": "16.0.48",
55
"browser": "dist/index.es.js",
66
"main": "dist/index.cjs.js",
77
"types": "dist/node/index.d.ts",

keeperapi/src/auth.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ import {
1010
import {KeeperEndpoint, KeeperEnvironment} from "./endpoint";
1111
import {KeyWrapper, platform} from "./platform";
1212
import {
13-
decryptFromStorage,
14-
generateEncryptionKey, wrapPassword,
13+
generateEncryptionKey,
1514
generateUidBytes,
16-
isTwoFactorResultCode,
1715
normal64,
1816
normal64Bytes,
1917
resolvablePromise,
20-
webSafe64,
21-
webSafe64FromBytes
18+
webSafe64FromBytes,
19+
wrapPassword
2220
} from "./utils";
2321
import {
2422
accountSummaryMessage,
2523
getEnterprisePublicKeyMessage,
26-
logoutV3Message, NN,
24+
logoutV3Message,
25+
NN,
2726
requestCreateUserMessage,
2827
requestDeviceAdminApprovalMessage,
29-
requestDeviceVerificationMessage, RestActionMessage, RestInMessage,
30-
RestMessage, RestOutMessage,
28+
requestDeviceVerificationMessage,
29+
RestActionMessage,
30+
RestInMessage,
31+
RestMessage,
32+
RestOutMessage,
3133
ssoServiceProviderRequestMessage,
3234
startLoginMessage,
3335
startLoginMessageFromSessionToken,
@@ -37,6 +39,8 @@ import {
3739
validateDeviceVerificationCodeMessage
3840
} from './restMessages'
3941
import {AccountSummary, Authentication} from './proto';
42+
import {RestCommand} from './commands'
43+
import {CloseReason, createAsyncSocket, SocketListener} from './socket';
4044
import IStartLoginRequest = Authentication.IStartLoginRequest;
4145
import ITwoFactorSendPushRequest = Authentication.ITwoFactorSendPushRequest;
4246
import TwoFactorExpiration = Authentication.TwoFactorExpiration;
@@ -46,8 +50,6 @@ import ISsoServiceProviderRequest = Authentication.ISsoServiceProviderRequest;
4650
import LoginType = Authentication.LoginType;
4751
import LoginMethod = Authentication.LoginMethod;
4852
import IAccountSummaryElements = AccountSummary.IAccountSummaryElements;
49-
import {RestCommand} from './commands'
50-
import {CloseReason, createAsyncSocket, SocketListener} from './socket';
5153

5254
function unifyLoginError(e: any): LoginError {
5355
if (e instanceof Error) {
@@ -680,7 +682,14 @@ export class Auth {
680682
const processPushNotification = (wssRs: Record<string, any>) => {
681683
if (wssRs.event === 'received_totp') {
682684
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+
}
684693
} else if (wssRs.message === 'device_approved') {
685694
if (wssRs.approved) {
686695
resumeWithToken(loginToken)

0 commit comments

Comments
 (0)