mirror of
https://github.com/bitwarden/mobile
synced 2025-12-25 20:53:25 +00:00
action extension project
This commit is contained in:
50
src/iOS.Core/Models/AppExtensionContext.cs
Normal file
50
src/iOS.Core/Models/AppExtensionContext.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.iOS.Core.Models
|
||||
{
|
||||
public class AppExtensionContext
|
||||
{
|
||||
private string _uriString;
|
||||
|
||||
public Uri Uri
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(UrlString) || !Uri.TryCreate(UrlString, UriKind.Absolute, out Uri uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
public string UrlString
|
||||
{
|
||||
get
|
||||
{
|
||||
return _uriString;
|
||||
}
|
||||
set
|
||||
{
|
||||
_uriString = value;
|
||||
if(string.IsNullOrWhiteSpace(_uriString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!_uriString.StartsWith(Bit.Core.Constants.iOSAppProtocol) && _uriString.Contains("."))
|
||||
{
|
||||
if(!_uriString.Contains("://") && !_uriString.Contains(" "))
|
||||
{
|
||||
_uriString = string.Concat("http://", _uriString);
|
||||
}
|
||||
}
|
||||
if(!_uriString.StartsWith("http") && !_uriString.StartsWith(Bit.Core.Constants.iOSAppProtocol))
|
||||
{
|
||||
_uriString = string.Concat(Bit.Core.Constants.iOSAppProtocol, _uriString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PasswordGenerationOptions PasswordOptions { get; set; }
|
||||
}
|
||||
}
|
||||
42
src/iOS.Core/Models/CipherViewModel.cs
Normal file
42
src/iOS.Core/Models/CipherViewModel.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.iOS.Core.Models
|
||||
{
|
||||
public class CipherViewModel
|
||||
{
|
||||
public CipherViewModel(CipherView cipher)
|
||||
{
|
||||
Id = cipher.Id;
|
||||
Name = cipher.Name;
|
||||
Username = cipher.Login?.Username;
|
||||
Password = cipher.Login?.Password;
|
||||
Totp = cipher.Login?.Totp;
|
||||
Uris = cipher.Login?.Uris?.Select(u => new LoginUriModel(u)).ToList();
|
||||
Fields = cipher.Fields?.Select(f => new Tuple<string, string>(f.Name, f.Value)).ToList();
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public List<LoginUriModel> Uris { get; set; }
|
||||
public string Totp { get; set; }
|
||||
public List<Tuple<string, string>> Fields { get; set; }
|
||||
|
||||
public class LoginUriModel
|
||||
{
|
||||
public LoginUriModel(LoginUriView data)
|
||||
{
|
||||
Uri = data?.Uri;
|
||||
Match = data?.Match;
|
||||
}
|
||||
|
||||
public string Uri { get; set; }
|
||||
public UriMatchType? Match { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
13
src/iOS.Core/Models/PasswordGenerationOptions.cs
Normal file
13
src/iOS.Core/Models/PasswordGenerationOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.iOS.Core.Models
|
||||
{
|
||||
public class PasswordGenerationOptions
|
||||
{
|
||||
public int MinLength { get; set; }
|
||||
public int MaxLength { get; set; }
|
||||
public bool RequireDigits { get; set; }
|
||||
public bool RequireSymbols { get; set; }
|
||||
public string ForbiddenCharacters { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user