Skip to content

Commit 7cafaf5

Browse files
author
Corentin Mors
authored
Prevent API call non-interactive device login (#225)
The call to `Get2FAStatusUnauthenticated` has a very strong rate limit and was called for non-interactive device, which was unnecessary.
1 parent c8732ff commit 7cafaf5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/modules/crypto/keychainManager.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ const getLocalConfigurationWithoutDB = async (
104104
});
105105

106106
// Get the authentication type (mainly to identify if the user is with OTP2)
107-
const { type } = await get2FAStatusUnauthenticated({ login });
107+
// if non-interactive device, we consider it as email_token, so we don't need to call the API
108+
const { type } = deviceCredentials ? { type: 'email_token' } : await get2FAStatusUnauthenticated({ login });
108109

109110
let masterPassword = '';
110111
const masterPasswordEnv = process.env.DASHLANE_MASTER_PASSWORD;
@@ -114,10 +115,8 @@ const getLocalConfigurationWithoutDB = async (
114115
// In case of SSO
115116
if (isSSO) {
116117
masterPassword = decryptSsoRemoteKey({ ssoServerKey, ssoSpKey, remoteKeys });
117-
} else if (masterPasswordEnv) {
118-
masterPassword = masterPasswordEnv;
119118
} else {
120-
masterPassword = await askMasterPassword();
119+
masterPassword = masterPasswordEnv ?? (await askMasterPassword());
121120

122121
// In case of OTP2
123122
if (type === 'totp_login' && serverKey) {

0 commit comments

Comments
 (0)