Skip to content

Commit

Permalink
PM-15593
Browse files Browse the repository at this point in the history
- Added conditional statement for text displayed in the totp code span
- Added styling to the returned text
  • Loading branch information
dan-livefront committed Dec 17, 2024
1 parent 5172698 commit 91ff855
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "lit/polyfill-support.js";

import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { EVENTS, UPDATE_PASSKEYS_HEADINGS_ON_SCROLL } from "@bitwarden/common/autofill/constants";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherRepromptType, CipherType } from "@bitwarden/common/vault/enums";

import { InlineMenuCipherData } from "../../../../background/abstractions/overlay.background";
import { InlineMenuFillTypes } from "../../../../enums/autofill-overlay.enum";
Expand Down Expand Up @@ -1163,7 +1163,7 @@ export class AutofillInlineMenuList extends AutofillInlineMenuPageElement {
}

if (cipher.login?.totpField && cipher.login?.totp) {
return this.buildTotpElement(cipher.login?.totp, cipher.login?.username);
return this.buildTotpElement(cipher.login?.totp, cipher.login?.username, cipher.reprompt);
}
const subTitleText = this.getSubTitleText(cipher);
const cipherSubtitleElement = this.buildCipherSubtitleElement(subTitleText);
Expand Down Expand Up @@ -1191,7 +1191,11 @@ export class AutofillInlineMenuList extends AutofillInlineMenuPageElement {
* @param totp - The TOTP code to display.
*/

private buildTotpElement(totpCode: string, username: string): HTMLDivElement | null {
private buildTotpElement(
totpCode: string,
username: string,
reprompt: CipherRepromptType,
): HTMLDivElement | null {
if (!totpCode) {
return null;
}
Expand All @@ -1213,8 +1217,9 @@ export class AutofillInlineMenuList extends AutofillInlineMenuPageElement {
}

const totpCodeSpan = document.createElement("span");
totpCodeSpan.classList.add("cipher-subtitle");
totpCodeSpan.textContent = formattedTotpCode;
totpCodeSpan.classList.toggle("cipher-subtitle");
totpCodeSpan.classList.toggle("masked-totp", !!reprompt);
totpCodeSpan.textContent = reprompt ? "●".repeat(totpCode.length) : formattedTotpCode;
totpCodeSpan.setAttribute("aria-label", this.getTranslation("totpCodeAria"));
totpCodeSpan.setAttribute("data-testid", "totp-code");
containerElement.appendChild(totpCodeSpan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ body * {
color: themed("mutedTextColor");
}

&.masked-totp {
font-size: 0.875rem;
letter-spacing: 0.2rem;
}

&--passkey {
display: flex;
align-content: center;
Expand Down

0 comments on commit 91ff855

Please sign in to comment.