Skip to content

Commit

Permalink
fix handling for 2FA device approval via Duo Push (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerccarson authored Feb 7, 2024
1 parent 0c11534 commit 6a7c943
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions keeperapi/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion keeperapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@keeper-security/keeperapi",
"description": "Keeper API Javascript SDK",
"version": "16.0.52",
"version": "16.0.53",
"browser": "dist/index.es.js",
"main": "dist/index.cjs.js",
"types": "dist/node/index.d.ts",
Expand Down
16 changes: 12 additions & 4 deletions keeperapi/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,19 @@ export class Auth {

const processPushNotification = (wssRs: Record<string, any>) => {
if (wssRs.event === 'received_totp') {
const token = wssRs.encryptedLoginToken ? normal64Bytes(wssRs.encryptedLoginToken) : loginToken
if (wssRs.passcode) {
// Duo
if (wssRs.encryptedLoginToken) {
const token = normal64Bytes(wssRs.encryptedLoginToken)
resumeWithToken(token)
}
// DNA
else if (wssRs.passcode) {
const tfaChannel = channels.find(x => x.channel === DeviceVerificationMethods.TFA)
if (tfaChannel && tfaChannel.validateCode) {
tfaChannel.validateCode(wssRs.passcode)
}
} else {
resumeWithToken(token)
// do nothing, we don't leak rejection during device approvals
}
} else if (wssRs.message === 'device_approved') {
if (wssRs.approved) {
Expand Down Expand Up @@ -871,10 +876,13 @@ export class Auth {

const processPushNotification = (wssRs: Record<string, any>) => {
if (wssRs.event === 'received_totp') {
// Duo
if (wssRs.encryptedLoginToken) {
const token = normal64Bytes(wssRs.encryptedLoginToken)
resumeWithToken(token)
} else if (wssRs.passcode) {
}
// DNA
else if (wssRs.passcode) {
(async () => {
await submitCode(lastPushChannel, wssRs.passcode)
})()
Expand Down

0 comments on commit 6a7c943

Please sign in to comment.