Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-3811] Passkeys unification #2774

Merged
merged 7 commits into from
Sep 22, 2023
2 changes: 1 addition & 1 deletion src/App/Pages/Vault/BaseCipherViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CipherView Cipher
set => SetProperty(ref _cipher, value, additionalPropertyNames: AdditionalPropertiesToRaiseOnCipherChanged);
}

public string CreationDate => string.Format(AppResources.CreatedX, Cipher.CreationDate.ToShortDateString());
public string CreationDate => string.Format(AppResources.CreatedXY, Cipher.CreationDate.ToShortDateString(), Cipher.CreationDate.ToShortTimeString());

public AsyncCommand CheckPasswordCommand { get; }

Expand Down
36 changes: 2 additions & 34 deletions src/App/Pages/Vault/CipherAddEditPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@
Margin="0,10,0,0"
IsVisible="{Binding ShowPasskeyInfo}"/>
<Entry
Text="{u:I18n AvailableForTwoStepLogin}"
Text="{Binding CreationDate}"
IsEnabled="False"
StyleClass="box-value,text-muted"
StyleClass="box-value,text-muted"
IsVisible="{Binding ShowPasskeyInfo}" />

<Grid StyleClass="box-row, box-row-input">
Expand Down Expand Up @@ -650,38 +650,6 @@
AutomationId="IdentityCountryEntry" />
</StackLayout>
</StackLayout>

<StackLayout IsVisible="{Binding IsFido2Key}" Spacing="0" Padding="0">
<Label
Text="{u:I18n Username}"
StyleClass="box-label"
Margin="0,10,0,0"/>
<Entry
x:Name="_fido2KeyUsernameEntry"
Text="{Binding Cipher.Fido2Key.UserName}"
StyleClass="box-value"
Grid.Row="1"/>
<Label
Text="{u:I18n Passkey}"
StyleClass="box-label"
Margin="0,10,0,0"/>
<Entry
Text="{Binding CreationDate}"
IsEnabled="False"
StyleClass="box-value,text-muted" />
<Label
Text="{u:I18n Application}"
StyleClass="box-label"
Margin="0,10,0,0"/>
<Entry
Text="{Binding Cipher.Fido2Key.LaunchUri}"
IsEnabled="False"
StyleClass="box-value,text-muted" />
<Label
Text="{u:I18n YouCannotEditPasskeyApplicationBecauseItWouldInvalidateThePasskey}"
StyleClass="box-sub-label" />
</StackLayout>

</StackLayout>
<StackLayout StyleClass="box" IsVisible="{Binding IsLogin}">
<StackLayout StyleClass="box-row-header">
Expand Down
5 changes: 2 additions & 3 deletions src/App/Pages/Vault/CipherAddEditPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ public bool HasCollections
public bool IsIdentity => Cipher?.Type == CipherType.Identity;
public bool IsCard => Cipher?.Type == CipherType.Card;
public bool IsSecureNote => Cipher?.Type == CipherType.SecureNote;
public bool IsFido2Key => Cipher?.Type == CipherType.Fido2Key;
public bool ShowUris => IsLogin && Cipher.Login.HasUris;
public bool ShowAttachments => Cipher.HasAttachments;
public string ShowPasswordIcon => ShowPassword ? BitwardenIcons.EyeSlash : BitwardenIcons.Eye;
Expand All @@ -309,7 +308,7 @@ public bool HasCollections
public string PasswordVisibilityAccessibilityText => ShowPassword ? AppResources.PasswordIsVisibleTapToHide : AppResources.PasswordIsNotVisibleTapToShow;
public bool HasTotpValue => IsLogin && !string.IsNullOrEmpty(Cipher?.Login?.Totp);
public string SetupTotpText => $"{BitwardenIcons.Camera} {AppResources.SetupTotp}";
public bool ShowPasskeyInfo => Cipher?.Login?.Fido2Key != null && !CloneMode;
public bool ShowPasskeyInfo => Cipher?.HasFido2Key == true && !CloneMode;

public void Init()
{
Expand Down Expand Up @@ -371,7 +370,7 @@ public async Task<bool> LoadAsync(AppOptions appOptions = null)
if (Cipher.Type == CipherType.Login)
{
// passkeys can't be cloned
Cipher.Login.Fido2Key = null;
Cipher.Login.Fido2Keys = null;
}
}
if (appOptions?.OtpData != null && Cipher.Type == CipherType.Login)
Expand Down
64 changes: 3 additions & 61 deletions src/App/Pages/Vault/CipherDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@
Text="{u:I18n Passkey}"
StyleClass="box-label"
Margin="0,10,0,0"
IsVisible="{Binding Cipher.Login.Fido2Key, Converter={StaticResource notNull}}"/>
IsVisible="{Binding Cipher.Login.MainFido2Key, Converter={StaticResource notNull}}"/>
<Entry
Text="{u:I18n AvailableForTwoStepLogin}"
Text="{Binding CreationDate}"
IsEnabled="False"
StyleClass="box-value,text-muted"
IsVisible="{Binding Cipher.Login.Fido2Key, Converter={StaticResource notNull}}" />
IsVisible="{Binding Cipher.Login.MainFido2Key, Converter={StaticResource notNull}}" />
<Grid StyleClass="box-row"
IsVisible="{Binding ShowTotp}"
AutomationId="ItemRow">
Expand Down Expand Up @@ -579,64 +579,6 @@
</StackLayout>
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowIdentityAddress}" />
</StackLayout>
<StackLayout
IsVisible="{Binding IsFido2Key}"
Spacing="0"
Padding="0"
Margin="0,10,0,0">
<Label
Text="{u:I18n Username}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Fido2Key.UserName, Mode=OneWay}"
StyleClass="box-value" />
<BoxView StyleClass="box-row-separator" Margin="0,10,0,0" />
<Label
Text="{u:I18n Passkey}"
StyleClass="box-label"
Margin="0,10,0,0" />
<Label
Text="{Binding CreationDate, Mode=OneWay}"
StyleClass="box-value" />
<BoxView StyleClass="box-row-separator" Margin="0,10,0,0" />
<Grid
StyleClass="box-row"
RowDefinitions="Auto,*,Auto"
ColumnDefinitions="*,Auto,Auto">
<Label
Text="{u:I18n Application}"
StyleClass="box-label" />
<Label
Grid.Row="1"
Text="{Binding Cipher.Fido2Key.LaunchUri, Mode=OneWay}"
StyleClass="box-value" />
<controls:IconButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding Source={x:Static core:BitwardenIcons.ShareSquare}}"
Command="{Binding LaunchUriCommand}"
CommandParameter="{Binding Cipher.Fido2Key}"
Grid.Column="1"
Grid.RowSpan="2"
VerticalOptions="End"
IsVisible="{Binding Cipher.Fido2Key.CanLaunch, Mode=OneWay}"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n Launch}" />
<controls:IconButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding Source={x:Static core:BitwardenIcons.Clone}}"
Command="{Binding CopyCommand}"
CommandParameter="Fido2KeyApplication"
Grid.Column="2"
Grid.RowSpan="2"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n CopyApplication}" />
<BoxView
StyleClass="box-row-separator"
Margin="0,3,0,0"
Grid.Row="2"
Grid.ColumnSpan="3" />
</Grid>
</StackLayout>
</StackLayout>
<StackLayout StyleClass="box" IsVisible="{Binding ShowUris}">
<StackLayout StyleClass="box-row-header">
Expand Down
18 changes: 3 additions & 15 deletions src/App/Pages/Vault/CipherDetailsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public bool ShowCardCode
public bool IsIdentity => Cipher?.Type == Core.Enums.CipherType.Identity;
public bool IsCard => Cipher?.Type == Core.Enums.CipherType.Card;
public bool IsSecureNote => Cipher?.Type == Core.Enums.CipherType.SecureNote;
public bool IsFido2Key => Cipher?.Type == Core.Enums.CipherType.Fido2Key;
public FormattedString ColoredPassword => GeneratedValueFormatter.Format(Cipher.Login.Password);
public FormattedString UpdatedText
{
Expand Down Expand Up @@ -649,11 +648,6 @@ private async Task CopyAsync(string id, string text = null)
text = Cipher.Card.Code;
name = AppResources.SecurityCode;
}
else if (id == "Fido2KeyApplication")
{
text = Cipher.Fido2Key?.LaunchUri;
name = AppResources.Application;
}

if (text != null)
{
Expand Down Expand Up @@ -708,18 +702,12 @@ public async Task<bool> PromptPasswordAsync()

private async Task<bool> CanCloneAsync()
{
if (Cipher.Type == CipherType.Fido2Key)
{
await _platformUtilsService.ShowDialogAsync(AppResources.PasskeyWillNotBeCopied);
return false;
}

if (Cipher.Type == CipherType.Login && Cipher.Login?.Fido2Key != null)
if (!Cipher.HasFido2Key)
{
return await _platformUtilsService.ShowDialogAsync(AppResources.ThePasskeyWillNotBeCopiedToTheClonedItemDoYouWantToContinueCloningThisItem, AppResources.PasskeyWillNotBeCopied, AppResources.Yes, AppResources.No);
return true;
}

return true;
return await _platformUtilsService.ShowDialogAsync(AppResources.ThePasskeyWillNotBeCopiedToTheClonedItemDoYouWantToContinueCloningThisItem, AppResources.PasskeyWillNotBeCopied, AppResources.Yes, AppResources.No);
}
}
}
6 changes: 0 additions & 6 deletions src/App/Pages/Vault/GroupingsPage/GroupingsPageListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public string Name
case CipherType.Identity:
_name = AppResources.TypeIdentity;
break;
case CipherType.Fido2Key:
_name = AppResources.Passkey;
break;
default:
break;
}
Expand Down Expand Up @@ -111,9 +108,6 @@ public string Icon
case CipherType.Identity:
_icon = BitwardenIcons.IdCard;
break;
case CipherType.Fido2Key:
_icon = BitwardenIcons.Passkey;
break;
default:
_icon = BitwardenIcons.Globe;
break;
Expand Down
6 changes: 2 additions & 4 deletions src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ private async Task LoadDataAsync()
{
Filter = c => !c.IsDeleted
&&
Type.Value.IsEqualToOrCanSignIn(c.Type);
Type.Value == c.Type;
}
else if (FolderId != null)
{
Expand Down Expand Up @@ -636,9 +636,7 @@ private async Task LoadDataAsync()
NoFolderCiphers.Add(c);
}

// Fido2Key ciphers should be counted as Login ciphers
var countType = c.Type == CipherType.Fido2Key ? CipherType.Login : c.Type;
_typeCounts[countType] = _typeCounts.TryGetValue(countType, out var currentTypeCount)
_typeCounts[c.Type] = _typeCounts.TryGetValue(c.Type, out var currentTypeCount)
? currentTypeCount + 1
: 1;
}
Expand Down
Loading