Refactor and merge code of extensions

This commit is contained in:
Mingshen Sun 2021-01-10 13:40:17 -08:00
parent 87d1dd5be1
commit 776884e894
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
13 changed files with 391 additions and 446 deletions

View file

@ -7,7 +7,7 @@
//
// This file contains constants from https://github.com/agilebits/onepassword-app-extension/
enum OnePasswordExtensionActions {
enum PassExtensionActions {
static let findLogin = "org.appextension.find-login-action"
static let saveLogin = "org.appextension.save-login-action"
static let changePassword = "org.appextension.change-password-action"
@ -15,8 +15,8 @@ enum OnePasswordExtensionActions {
static let fillBrowser = "org.appextension.fill-browser-action"
}
enum OnePasswordExtensionKey {
// Login Dictionary keys - Used to get or set the properties of a 1Password Login
enum PassExtensionKey {
// Login Dictionary keys
static let URLStringKey = "url_string"
static let usernameKey = "username"
static let passwordKey = "password"
@ -29,23 +29,10 @@ enum OnePasswordExtensionKey {
static let oldPasswordKey = "old_password"
static let passwordGeneratorOptionsKey = "password_generator_options"
// Password Generator options - Used to set the 1Password Password Generator options when saving a new Login or when changing the password for for an existing Login
// Password Generator options
static let generatedPasswordMinLengthKey = "password_min_length"
static let generatedPasswordMaxLengthKey = "password_max_length"
static let generatedPasswordRequireDigitsKey = "password_require_digits"
static let generatedPasswordRequireSymbolsKey = "password_require_symbols"
static let generatedPasswordForbiddenCharactersKey = "password_forbidden_characters"
}
// Errors codes
enum OnePasswordExtensionError {
static let errorDomain = "OnePasswordExtension"
static let errorCodeCancelledByUser = 0
static let errorCodeAPINotAvailable = 1
static let errorCodeFailedToContactExtension = 2
static let errorCodeFailedToLoadItemProviderData = 3
static let errorCodeCollectFieldsScriptFailed = 4
static let errorCodeFillFieldsScriptFailed = 5
static let errorCodeUnexpectedData = 6
static let errorCodeFailedToObtainURLStringFromWebView = 7 // swiftlint:disable:this identifier_name
}