1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-25 20:53:25 +00:00

action extension project

This commit is contained in:
Kyle Spearrin
2019-06-26 20:28:23 -04:00
parent a158021f46
commit 79746efa2d
33 changed files with 725 additions and 23 deletions

View 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; }
}
}

View 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; }
}
}
}

View 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; }
}
}