Skip to content

Commit

Permalink
fixed Xcode 15 compatibility by bumping deployment target to 10.13
Browse files Browse the repository at this point in the history
  • Loading branch information
mstarke committed Nov 13, 2023
1 parent 789f86d commit 09cdd54
Show file tree
Hide file tree
Showing 18 changed files with 296 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "MacPass/KissXML" "933f04fe5ad95c2be07ec0c2f801e140007f20fa"
github "MacPass/KissXML" "503fc012b73a4507965019720cbf1c157e849657"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "MacPass/KissXML" "933f04fe5ad95c2be07ec0c2f801e140007f20fa"
github "MacPass/KissXML" "503fc012b73a4507965019720cbf1c157e849657"
72 changes: 64 additions & 8 deletions KeePassKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
52 changes: 52 additions & 0 deletions KeePassKit/Core/KPKSynchronizationChangesItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// KPKSynchronizationChangesItem.h
// KeePassKit
//
// Created by Michael Starke on 05.10.22.
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, KPKSynchronizationChangeType) {
KPKSynchronizationChangeTypeAddedNode,
KPKSynchronizationChangeTypeRemovedNode,
KPKSynchronizationChangeTypeMovedNode,
KPKSynchronizationChangeTypeChangedNodeAttribute, // Node attributes have changed
KPKSynchronizationChangeTypeAddedNodeAttribute, // Node attributes where added - valid only for entries
KPKSynchronizationChangeTypeRemovedNodeAttribute, // Node attributes where removed - valid only for entries
KPKSynchronizationChangeTypeAddedIcon,
KPKSynchronizationChangeTypeRemovedIcon,
KPKSynchronizationChangeTypeChangedIcon,
KPKSynchronizationChangeTypeChangedMetaData, // Any changes in inner settings e.g. Templates, Recycle Bin, History, Name, Color
};

@class KPKNode;
@class KPKGroup;
@class KPKAttribute;

@interface KPKSynchronizationChangesItem : NSObject

@property (readonly) KPKSynchronizationChangeType changeType;

@property (readonly, copy) NSUUID *uuid; // the uuid of the affected node

+ (instancetype)itemWithChangedAttributeKey:(NSString *)key localValue:(NSString *)localValue remoteValue:(NSString *)remoteValue;
+ (instancetype)itemWithAddedNode:(KPKNode *)node parent:(KPKGroup *)group;
+ (instancetype)itemWithRemovedNode:(KPKNode *)node;

- (instancetype)init NS_UNAVAILABLE;

@end

@interface KPKSynchronizationAttributeChangesItem : KPKSynchronizationChangesItem

@property (readonly, copy) NSString *key;
@property (readonly, copy) NSString *localValue;
@property (readonly, copy) NSString *remoteValue;

@end

NS_ASSUME_NONNULL_END
13 changes: 13 additions & 0 deletions KeePassKit/Core/KPKSynchronizationChangesItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// KPKSynchronizationChangesItem.m
// KeePassKit
//
// Created by Michael Starke on 05.10.22.
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
//

#import "KPKSynchronizationChangesItem.h"

@implementation KPKSynchronizationChangesItem

@end
32 changes: 32 additions & 0 deletions KeePassKit/Core/KPKSynchronizationChangesStore.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// KPKSynchronizationChangesStore.h
// KeePassKit
//
// Created by Michael Starke on 02.10.22.
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class KPKGroup;
@class KPKNode;
@class KPKAttribute;
@class KPKSynchronizationChangesItem;

@interface KPKSynchronizationChangesStore : NSObject

@property (readonly, copy, nonatomic) NSArray<KPKSynchronizationChangesItem *> *allChanges;

@property (readonly, copy, nonatomic) NSArray<KPKSynchronizationChangesItem *> *addedNodes;
@property (readonly, copy, nonatomic) NSArray<KPKSynchronizationChangesItem *> *removedNodes;

- (NSArray<KPKSynchronizationChangesItem *> *)changesForUUID:(NSUUID *)uuid;
// icons
// metadata
// attributes

@end

NS_ASSUME_NONNULL_END
77 changes: 77 additions & 0 deletions KeePassKit/Core/KPKSynchronizationChangesStore.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// KPKSynchronizationChangesStore.m
// KeePassKit
//
// Created by Michael Starke on 02.10.22.
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
//

#import "KPKSynchronizationChangesStore.h"
#import "KPKSynchronizationChangesStore_Private.h"
#import "KPKSynchronizationChangesItem.h"

@implementation KPKSynchronizationChangesStore

@dynamic addedNodes;
@dynamic removedNodes;
@dynamic allChanges;

- (instancetype)init {
self = [super init];
if(self) {
self.mutableChanges = [[NSMutableArray alloc] init];
self.recordingChanges = NO;
}
return self;
}

- (void)_beginRecordingChanges {
[self.mutableChanges removeAllObjects];
self.recordingChanges = YES;
}

- (void)_endRecordingChanges {
self.recordingChanges = NO;
}

- (void)_addChange:(KPKSynchronizationChangesItem *)changeItem {
NSAssert(self.isRecordingChanges, @"Change recording is only possible while in active recording");
[self.mutableChanges addObject:changeItem];
}

- (NSArray<KPKSynchronizationChangesItem *> *)allChanges {
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
return [self.mutableChanges copy];
}

- (NSArray<KPKSynchronizationChangesItem *> *)addedNodes {
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
NSPredicate *addedNodesPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
KPKSynchronizationChangesItem *item = (KPKSynchronizationChangesItem *)evaluatedObject;
return (item.changeType == KPKSynchronizationChangeTypeAddedNode);

}];
return [self.mutableChanges filteredArrayUsingPredicate:addedNodesPredicate];
}

- (NSArray<KPKSynchronizationChangesItem *> *)removedNodes {
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
NSPredicate *addedNodesPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
KPKSynchronizationChangesItem *item = (KPKSynchronizationChangesItem *)evaluatedObject;
return (item.changeType == KPKSynchronizationChangeTypeRemovedNode);

}];
return [self.mutableChanges filteredArrayUsingPredicate:addedNodesPredicate];
}

- (NSArray<KPKSynchronizationChangesItem *> *)changesForUUID:(NSUUID *)uuid {
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
NSPredicate *addedNodesPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
KPKSynchronizationChangesItem *item = (KPKSynchronizationChangesItem *)evaluatedObject;
return ([item.uuid isEqual:uuid]);
}];
return [self.mutableChanges filteredArrayUsingPredicate:addedNodesPredicate];

}

@end
26 changes: 26 additions & 0 deletions KeePassKit/Core/KPKSynchronizationChangesStore_Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// KPKSynchronizationChangesStore+Private.h
// KeePassKit
//
// Created by Michael Starke on 05.10.22.
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
//

#import <KeePassKit/KeePassKit.h>
#import "KPKSynchronizationChangesStore.h"
#import "KPKSynchronizationChangesItem.h"

NS_ASSUME_NONNULL_BEGIN

@interface KPKSynchronizationChangesStore ()

@property (strong) NSMutableArray *mutableChanges;
@property (assign, getter=isRecordingChanges) BOOL recordingChanges;

- (void)_beginRecordingChanges;
- (void)_endRecordingChanges;
- (void)_addChange:(KPKSynchronizationChangesItem *)changeItem;

@end

NS_ASSUME_NONNULL_END
13 changes: 9 additions & 4 deletions KeePassKit/Core/KPKTree+Synchronization.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#import "KPKNode.h"
#import "KPKNode_Private.h"
#import "KPKScopedSet.h"
#import "KPKSynchronizationChangesItem.h"
#import "KPKSynchronizationChangesStore_Private.h"
#import "KPKTimeInfo.h"
#import "KPKTree_Private.h"

Expand All @@ -41,8 +43,11 @@
@implementation KPKTree (Synchronization)

- (void)synchronizeWithTree:(KPKTree *)tree mode:(KPKSynchronizationMode)mode options:(KPKSynchronizationOptions)options {

if(options & KPKSynchronizationOptionCreateNewUuids) {
KPKSynchronizationChangesStore *changesStore;
if([tree.delegate respondsToSelector:@selector(synchronizationChangeStoreForTree:)]) {
changesStore = [tree.delegate synchronizationChangeStoreForTree:tree];
}
if(!(options & KPKSynchronizationOptionDryRun) && (options & KPKSynchronizationOptionCreateNewUuids)) {
/* create new uuid in the sourc tree */
[tree.root _regenerateUUIDs];
}
Expand All @@ -57,6 +62,7 @@ - (void)synchronizeWithTree:(KPKTree *)tree mode:(KPKSynchronizationMode)mode op
7) update deleted information
8) reapply deletions to ensure entries and groups are at final place
*/
[changesStore _beginRecordingChanges];
[self _mergeNodes:[@[tree.root] arrayByAddingObjectsFromArray:tree.allGroups] mode:mode options:options];
[self _mergeNodes:tree.allEntries mode:mode options:options];
[self _mergeLocationFromNodes:tree.allEntries options:options];
Expand All @@ -67,8 +73,7 @@ - (void)synchronizeWithTree:(KPKTree *)tree mode:(KPKSynchronizationMode)mode op
[self _reapplyNodeDeletions:self.root];
[self _reapplyIconDeletions];
}

;
[changesStore _endRecordingChanges];
/* clear undo stack since merge is not supposed to be undoable */
[self.undoManager removeAllActions];
}
Expand Down
6 changes: 6 additions & 0 deletions KeePassKit/Core/KPKTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import <Foundation/Foundation.h>
#import <KeePassKit/KPKFormat.h>
#import <KeePassKit/KPKSynchronizationOptions.h>
#import <KeePassKit/KPKSynchronizationChangesStore.h>
#import <KeePassKit/KPKNode.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -98,6 +99,11 @@ FOUNDATION_EXTERN NSString *const KPKEntryKey;
*/
- (BOOL)tree:(KPKTree *)tree resolveUnknownPlaceholdersInString:(NSMutableString *)string forEntry:(KPKEntry *)entry;

/// Allows the delegate to supply a changesStore to retrieve any changes when a synchonization is done.
/// Run the synchronization in dry mode to retriefe those changes before applying the merge
/// - Parameter tree: the tree to supply the store for
- (KPKSynchronizationChangesStore *)synchronizationChangeStoreForTree:(KPKTree *)tree;

@end

@class KPKGroup;
Expand Down
3 changes: 2 additions & 1 deletion KeePassKit/Format/KPKSynchronizationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ typedef NS_ENUM(NSUInteger, KPKSynchronizationMode) {

typedef NS_OPTIONS(NSUInteger, KPKSynchronizationOptions) {
KPKSynchronizationOptionCreateNewUuids = 1 << 0, // generate new UUIDs in source tree before merging it into target
KPKSynchronizationOptionMatchGroupsByTitleOnly = 1 << 1 // match groups by title not by UUID. This is usefull when trying to merge KDB trees since only entry retain their UUID after save and load
KPKSynchronizationOptionMatchGroupsByTitleOnly = 1 << 1, // match groups by title not by UUID. This is usefull when trying to merge KDB trees since only entry retain their UUID after save and load
KPKSynchronizationOptionDryRun = 1 << 2 // do not make any real changes, just run a dry run
};

#endif /* KPKSynchronizationOptions_h */
2 changes: 1 addition & 1 deletion KeePassKit/IO/KDB/KPKKdbTreeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)initWithTree:(KPKTree *)tree;

- (NSData *)treeDataWithHeaderHash:(NSData *)hash;
- (NSData * _Nullable)treeDataWithHeaderHash:(NSData *)hash;

@end

Expand Down
2 changes: 2 additions & 0 deletions KeePassKit/KeePassKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ FOUNDATION_EXPORT const unsigned char KeePassKitVersionString[];

#import <KeePassKit/KPKModificationRecording.h>
#import <KeePassKit/KPKCommandEvaluationContext.h>
#import <KeePassKit/KPKSynchronizationChangesStore.h>

#import <KeePassKit/KPKErrors.h>

Expand All @@ -77,6 +78,7 @@ FOUNDATION_EXPORT const unsigned char KeePassKitVersionString[];
#import <KeePassKit/NSString+KPKCommands.h>
#import <KeePassKit/NSString+KPKEmpty.h>
#import <KeePassKit/NSString+KPKXmlUtilities.h>
#import <KeePassKit/NSString+KPKHexData.h>
#import <KeePassKit/NSUUID+KPKAdditions.h>
#import <KeePassKit/NSUIColor+KPKAdditions.h>
#import <KeePassKit/NSUIImage+KPKAdditions.h>
Expand Down
8 changes: 6 additions & 2 deletions KeePassKitTests/KPKTestOTP.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ - (void)testHmacOTP {
}
}

- (void)testHmacOTPWithEmpyKey {
- (void)testHmacOTPWithEmptyKey {
KPKHmacOTPGenerator *generator = [[KPKHmacOTPGenerator alloc] init];
NSString *string = generator.string;
XCTAssertNotNil(string);
Expand Down Expand Up @@ -258,7 +258,7 @@ - (void)testHmacCounterUpdate {

}

- (void)testEntryOTPproperties {
- (void)testEntryOTPProperties {
KPKEntry *entry = [[KPKEntry alloc] init];
KPKAttribute *otpAttribute = [[KPKAttribute alloc] initWithKey:kKPKAttributeKeyOTPOAuthURL value:@"This-is-no-valid-URL"];
[entry addCustomAttribute:otpAttribute];
Expand All @@ -267,6 +267,10 @@ - (void)testEntryOTPproperties {
XCTAssertFalse(entry.hasHmacOTP);
}

- (void)testEntryOTPPropertiesUpdate {
XCTFail();
}

/*
- (void)testTimeOTPEntry {
KPKEntry *entry = [[KPKEntry alloc] init];
Expand Down

0 comments on commit 09cdd54

Please sign in to comment.