@@ -81,6 +81,7 @@ export type LoginPayload = {
8181 givenSessionToken ?: string
8282 ecOnly ?: boolean
8383 primaryAccountSessionTokenForLinking ?: Uint8Array | null
84+ disableLinkingForAccountWithYubikey2fa ?: boolean
8485}
8586
8687export enum UserType {
@@ -116,6 +117,7 @@ export type EncryptionKeys = {
116117export const enum LoginV3ResultEnum {
117118 NOT_LOGGED_IN = 'notLoggedin' ,
118119 LINKING_BLOCKED_BY_CROSS_REGION = 'linkingBlockedByCrossRegion' ,
120+ LINKING_BLOCKED_BY_YUBIKEY_2FA = 'linkingBlockedByYubikey2fa' ,
119121}
120122
121123export 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