From 37f1a7087e251750c1094cb04a8d69d637a40e5f Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Wed, 10 May 2023 16:59:49 +0200 Subject: [PATCH] [PM-1748] Fix Watch TOTP details on Always On Display (#2515) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PM-1748 Fix watchOS issue where the TOTP code wasn't being regenerated after always on display. Also, blurred totp code and timer value when entering in Always On Display * Fixed PR labeler for WatchOS changes * PM-1748 watchOS made username privacy sensitive for always on display * Revert "Fixed PR labeler for WatchOS changes" This reverts commit 3c55f380696ee0d6a6a363bcf4603bdae59c7d19. --------- Co-authored-by: Álison Fernandes --- .../Models/Mocks/CipherMock.swift | 2 +- .../ViewModels/CipherDetailsViewModel.swift | 24 +++++++++++-------- .../Views/CipherDetailsView.swift | 9 +++++++ .../Views/CipherItemView.swift | 1 + .../Views/CipherListView.swift | 1 + 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift b/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift index 543e6a99e..7d22dc39a 100644 --- a/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift +++ b/src/watchOS/bitwarden/bitwarden WatchKit Extension/Models/Mocks/CipherMock.swift @@ -2,7 +2,7 @@ import Foundation struct CipherMock { static let ciphers:[Cipher] = [ - Cipher(id: "0", name: "1933", userId: "123123", login: Login(username: "thisisatest@testing.com", totp: "otpauth://account?period=10&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), + Cipher(id: "0", name: "MySite", userId: "123123", login: Login(username: "test@testing.com", totp: "otpauth://account?period=10&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), Cipher(id: "1", name: "GitHub", userId: "123123", login: Login(username: "thisisatest@testing.com", totp: "LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), Cipher(id: "2", name: "No user", userId: "123123", login: Login(username: nil, totp: "otpauth://account?period=10&digits=8&algorithm=sha256&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), Cipher(id: "3", name: "Site 2", userId: "123123", login: Login(username: "longtestemail000000@fastmailasdfasdf.com", totp: "otpauth://account?period=10&digits=7&algorithm=sha512&secret=LLLLLLLLLLLLLLLL", uris: cipherLoginUris)), diff --git a/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift b/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift index bfed0a30b..41663d9dd 100644 --- a/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift +++ b/src/watchOS/bitwarden/bitwarden WatchKit Extension/ViewModels/CipherDetailsViewModel.swift @@ -34,30 +34,34 @@ class CipherDetailsViewModel: ObservableObject{ self.counter = self.period - mod self.progress = Double(self.counter) / Double(self.period) } + if mod == 0 || self.totpFormatted == "" { do { - var totpF = try TotpService.shared.GetCodeAsync(key: self.key) ?? "" - if totpF.count > 4 { - let halfIndex = totpF.index(totpF.startIndex, offsetBy: totpF.count / 2) - totpF = "\(totpF[totpF.startIndex.. 4 { + let halfIndex = totpF.index(totpF.startIndex, offsetBy: totpF.count / 2) + totpF = "\(totpF[totpF.startIndex..