Skip to content

Commit 6ef2c92

Browse files
authored
BE-6600 The loginV3 function blocks account linking for YubiKey 2FA accounts if disableLinkingForAccountWithYubikey2fa is set (#88)
* The loginV3 function blocks account linking for YubiKey 2FA accounts if disableLinkingForAccountWithYubikey2fa is set * v16.0.87 * added a comment to the disableLinkingForAccountWithYubikey2fa prop
1 parent c187eec commit 6ef2c92

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

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.86",
4+
"version": "16.0.87",
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: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export type LoginPayload = {
8181
givenSessionToken?: string
8282
ecOnly?: boolean
8383
primaryAccountSessionTokenForLinking?: Uint8Array | null
84+
disableLinkingForAccountWithYubikey2fa?: boolean
8485
}
8586

8687
export enum UserType {
@@ -116,6 +117,7 @@ export type EncryptionKeys = {
116117
export const enum LoginV3ResultEnum {
117118
NOT_LOGGED_IN = 'notLoggedin',
118119
LINKING_BLOCKED_BY_CROSS_REGION = 'linkingBlockedByCrossRegion',
120+
LINKING_BLOCKED_BY_YUBIKEY_2FA = 'linkingBlockedByYubikey2fa',
119121
}
120122

121123
export class Auth {
@@ -269,7 +271,13 @@ export class Auth {
269271
}
270272

271273
/**
272-
* useAlternate is to pass to the next function to use an alternate method, for testing a different path.
274+
* @param {LoginPayload} payload - Options for login.
275+
* @param {boolean} [payload.disableLinkingForAccountWithYubikey2fa] -
276+
* Opt-out flag for linking YubiKey 2FA accounts.
277+
* Normally, these accounts can be linked, but some clients
278+
* have technical issues that prevent them from supporting
279+
* the linking flow. When true, `loginV3` will block the
280+
* linking attempt and return `LINKING_BLOCKED_BY_YUBIKEY_2FA`.
273281
*/
274282
async loginV3(
275283
{
@@ -282,7 +290,13 @@ export class Auth {
282290
resumeSessionOnly = false,
283291
givenSessionToken = undefined,
284292
ecOnly = false,
285-
primaryAccountSessionTokenForLinking = undefined
293+
primaryAccountSessionTokenForLinking = undefined,
294+
/*
295+
* Prevents linking YubiKey 2FA accounts.
296+
* Normally, these accounts can be linked, but some clients have technical issues
297+
* that prevent them from supporting the linking flow, so they can opt out via this flag.
298+
*/
299+
disableLinkingForAccountWithYubikey2fa,
286300
}: Partial<LoginPayload>
287301
): Promise<{result: LoginV3ResultEnum} | undefined> {
288302
this._username = username || this.options.sessionStorage?.lastUsername || ''
@@ -468,6 +482,11 @@ export class Auth {
468482
break;
469483
case Authentication.LoginState.REQUIRES_2FA:
470484
try{
485+
if (!!disableLinkingForAccountWithYubikey2fa && !!primaryAccountSessionTokenForLinking) {
486+
return {
487+
result: LoginV3ResultEnum.LINKING_BLOCKED_BY_YUBIKEY_2FA,
488+
}
489+
}
471490
loginToken = await this.handleTwoFactor(loginResponse)
472491
} catch(e: any){
473492
if (e?.message && e.message == 'push_declined'){

0 commit comments

Comments
 (0)