Adopted KeePassKit attribute keys and stripped our custom ones

This commit is contained in:
Michael Starke
2020-12-01 13:38:34 +01:00
parent 9716bfc8e8
commit 1c76e50192
5 changed files with 19 additions and 67 deletions

View File

@@ -1,4 +1,4 @@
github "sparkle-project/Sparkle" ~> 1.22
github "mattt/TransformerKit" ~> 1.1.1
github "MacPass/KeePassKit" "958637c267d29d4db59773d215d08e52b18442c0"
github "MacPass/KeePassKit" "27cd293a067aa99de0874a33ef0d10dd27c6d08c"
github "mstarke/HNHUi" ~> 4.0

View File

@@ -1,4 +1,4 @@
github "MacPass/KeePassKit" "958637c267d29d4db59773d215d08e52b18442c0"
github "MacPass/KeePassKit" "27cd293a067aa99de0874a33ef0d10dd27c6d08c"
github "mattt/TransformerKit" "1.1.1"
github "mstarke/HNHUi" "4.0.2"
github "robbiehanson/KissXML" "5.3.2"

View File

@@ -10,12 +10,6 @@
NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXTERN NSString *const MPHMACOTPSeedAttributeKey;
FOUNDATION_EXTERN NSString *const MPHMACOTPConfigAttributeKey;
FOUNDATION_EXTERN NSString *const MPTOTPAuthAttributeKey;
FOUNDATION_EXTERN NSString *const MPTOTPSeedAttributeKey;
FOUNDATION_EXTERN NSString *const MPTOTPConfigAttributeKey;
@interface KPKEntry (OTP)
@property (readonly, assign, nonatomic) BOOL hasTOTP;

View File

@@ -10,20 +10,14 @@
@implementation KPKEntry (OTP)
NSString *const MPHMACOTPSeedAttributeKey = @"HMACOTP-Seed";
NSString *const MPHMACOTPConfigAttributeKey = @"HMACOTP-Config";
NSString *const MPTOTPAuthAttributeKey = @"otp";
NSString *const MPTOTPSeedAttributeKey = @"TOTP Seed";
NSString *const MPTOTPConfigAttributeKey = @"OTP Settings";
+ (NSSet<NSString *> *)keyPathsForValuesAffectingHasTOTP {
return [NSSet setWithObject:NSStringFromSelector(@selector(attributes))];
}
- (BOOL)hasTOTP {
BOOL hasURLKey = [self hasAttributeWithKey:MPTOTPAuthAttributeKey];
BOOL hasSeedKey = [self hasAttributeWithKey:MPTOTPSeedAttributeKey];
BOOL hasSettingsKey = [self hasAttributeWithKey:MPTOTPConfigAttributeKey];
BOOL hasURLKey = [self hasAttributeWithKey:kKPKAttributeKeyOTPOAuthURL];
BOOL hasSeedKey = [self hasAttributeWithKey:kKPKAttributeKeyTimeOTPSeed];
BOOL hasSettingsKey = [self hasAttributeWithKey:kKPKAttributeKeyTimeOTPSettings];
return(hasURLKey || (hasSeedKey && hasSettingsKey));
}

View File

@@ -26,13 +26,13 @@
#import "KPKEntry+OTP.h"
/*
HmacOtp-Secret (the UTF-8 representation of the value is the secret),
HmacOtp-Secret-Hex (secret as hex string),
HmacOtp-Secret-Base32 (secret as Base32 string)
HmacOtp-Secret-Base64 (secret as Base64 string)
HmacOtp-Secret (the UTF-8 representation of the value is the secret),
HmacOtp-Secret-Hex (secret as hex string),
HmacOtp-Secret-Base32 (secret as Base32 string)
HmacOtp-Secret-Base64 (secret as Base64 string)
HmacOtp-Counter field.
*/
HmacOtp-Counter field.
*/
@interface MPAddCustomFieldContextMenuDelegate ()
@property (readonly, nonatomic) KPKEntry *entry;
@@ -56,59 +56,23 @@ HmacOtp-Counter field.
/* HMAC OTP */
- (void)_setupHOTPMenuItemsToMenu:(NSMenu *)menu {
BOOL hasConfigAttribute = nil != [self.entry customAttributeWithKey:MPHMACOTPConfigAttributeKey];
if(!hasConfigAttribute) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_CUSTOM_ATTRIBUTE_HMACOTP_CONFIG", @"Menu item title for adding an hmacotp config attribute") action:@selector(_addHMACConfig:) keyEquivalent:@""];
item.target = self;
[menu addItem:item];
}
BOOL hasSeedAttribute = nil != [self.entry customAttributeWithKey:MPHMACOTPSeedAttributeKey];
if(!hasSeedAttribute) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_CUSTOM_ATTRIBUTE_HMACOTP_SEED", @"Menu item title for adding an hmacotp seed attribute") action:@selector(_addHMACSeed:) keyEquivalent:@""];
item.target = self;
[menu addItem:item];
}
}
- (IBAction)_setupHMACConfig:(id)sender {}
- (IBAction)_delteHMACConfig:(id)sender {}
- (IBAction)_addHMACConfig:(id)sender {
[self.entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:MPHMACOTPConfigAttributeKey value:@"<config>"]];
- (IBAction)_setupHMACConfig:(id)sender {
}
- (IBAction)_addHMACSeed:(id)sender {
[self.entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:MPHMACOTPSeedAttributeKey value:@"<seed>"]];
- (IBAction)_delteHMACConfig:(id)sender {
}
/* Time OPT*/
- (void)_setupTOTPMenuItemsToMenu:(NSMenu *)menu {
BOOL hasTOTPAuthAttribute = nil != [self.entry customAttributeWithKey:MPTOTPAuthAttributeKey];
BOOL hasTOTPSeedAttribute = nil != [self.entry customAttributeWithKey:MPTOTPSeedAttributeKey];
BOOL hasTOTPSettingsAttribute = nil != [self.entry customAttributeWithKey:MPTOTPSeedAttributeKey];
BOOL hasValidSettings = hasTOTPAuthAttribute || (hasTOTPSeedAttribute && hasTOTPSettingsAttribute);
if(hasValidSettings) {
// Edit
NSMenuItem *editItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_TOTP_SETTINGS", @"Menu item title editing TOTP settings") action:@selector(_editTOTPSettings:) keyEquivalent:@""];
editItem.target = self;
[menu addItem:editItem];
// Delete
NSMenuItem *deleteItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE_TOTP_SETTINGS", @"Menu item title for deleting TOTP settings") action:@selector(_deleteTOTPSettings:) keyEquivalent:@""];
deleteItem.target = self;
[menu addItem:deleteItem];
}
else {
// Setup
NSMenuItem *setupItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SETUP_TOTP_SETTINGS", @"Menu item title editing TOTP settings") action:@selector(_setupTOTPSettings:) keyEquivalent:@""];
setupItem.target = self;
[menu addItem:setupItem];
}
NSMenuItem *setupItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SETUP_TOTP_SETTINGS", @"Menu item title editing TOTP settings") action:@selector(_setupTOTPSettings:) keyEquivalent:@""];
setupItem.target = self;
[menu addItem:setupItem];
}
- (IBAction)_setupTOTPSettings:(id)sender {}
- (IBAction)_editTOTPSettings:(id)sender {}
- (IBAction)_deleteTOTPSettings:(id)sender {}
@end