Skip to content

Commit 6a7c943

Browse files
authored
fix handling for 2FA device approval via Duo Push (#42)
1 parent 0c11534 commit 6a7c943

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

keeperapi/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.52",
4+
"version": "16.0.53",
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: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,14 +684,19 @@ export class Auth {
684684

685685
const processPushNotification = (wssRs: Record<string, any>) => {
686686
if (wssRs.event === 'received_totp') {
687-
const token = wssRs.encryptedLoginToken ? normal64Bytes(wssRs.encryptedLoginToken) : loginToken
688-
if (wssRs.passcode) {
687+
// Duo
688+
if (wssRs.encryptedLoginToken) {
689+
const token = normal64Bytes(wssRs.encryptedLoginToken)
690+
resumeWithToken(token)
691+
}
692+
// DNA
693+
else if (wssRs.passcode) {
689694
const tfaChannel = channels.find(x => x.channel === DeviceVerificationMethods.TFA)
690695
if (tfaChannel && tfaChannel.validateCode) {
691696
tfaChannel.validateCode(wssRs.passcode)
692697
}
693698
} else {
694-
resumeWithToken(token)
699+
// do nothing, we don't leak rejection during device approvals
695700
}
696701
} else if (wssRs.message === 'device_approved') {
697702
if (wssRs.approved) {
@@ -871,10 +876,13 @@ export class Auth {
871876

872877
const processPushNotification = (wssRs: Record<string, any>) => {
873878
if (wssRs.event === 'received_totp') {
879+
// Duo
874880
if (wssRs.encryptedLoginToken) {
875881
const token = normal64Bytes(wssRs.encryptedLoginToken)
876882
resumeWithToken(token)
877-
} else if (wssRs.passcode) {
883+
}
884+
// DNA
885+
else if (wssRs.passcode) {
878886
(async () => {
879887
await submitCode(lastPushChannel, wssRs.passcode)
880888
})()

0 commit comments

Comments
 (0)