mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-18 23:09:21 +00:00
Filling the OTP Setup view works
QR Image parsing and update works as well. Save to entry and other updates still missing
This commit is contained in:
2
Cartfile
2
Cartfile
@@ -1,4 +1,4 @@
|
||||
github "sparkle-project/Sparkle" ~> 1.22
|
||||
github "MacPass/TransformerKit" "a8b5bb73cc327ec6798569b865c32fec5eb2289f"
|
||||
github "MacPass/KeePassKit" "8ce0fda4ca10c41f022da3d9e3539e1686aa4460"
|
||||
github "MacPass/KeePassKit" "61bcb5718ea6f09725595f7e1f1b31ded0bb704e"
|
||||
github "mstarke/HNHUi" ~> 4.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
github "MacPass/KeePassKit" "8ce0fda4ca10c41f022da3d9e3539e1686aa4460"
|
||||
github "MacPass/KeePassKit" "61bcb5718ea6f09725595f7e1f1b31ded0bb704e"
|
||||
github "MacPass/KissXML" "933f04fe5ad95c2be07ec0c2f801e140007f20fa"
|
||||
github "MacPass/TransformerKit" "a8b5bb73cc327ec6798569b865c32fec5eb2289f"
|
||||
github "mstarke/HNHUi" "4.0.4"
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<rect key="frame" x="20" y="26" width="233" height="396"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="F3N-QI-Di5">
|
||||
<rect key="frame" x="1" y="1" width="231" height="394"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="36" rowSizeStyle="automatic" viewBased="YES" id="137">
|
||||
<rect key="frame" x="0.0" y="0.0" width="231" height="394"/>
|
||||
@@ -792,7 +792,7 @@
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="SelectedCell" translatesAutoresizingMaskIntoConstraints="NO" id="196" customClass="MPCustomFieldTableCellView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="227" height="53"/>
|
||||
<rect key="frame" x="1" y="1" width="227" height="53"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="199" customClass="HNHUISecureTextField">
|
||||
<rect key="frame" x="3" y="10" width="114" height="21"/>
|
||||
|
||||
@@ -151,12 +151,10 @@ typedef NS_ENUM(NSUInteger, MPOTPType) {
|
||||
MPOTPUpdateSourceTimeSlice,
|
||||
MPOTPUpdateSourceType,
|
||||
MPOTPUpdateSourceEntry
|
||||
|
||||
*/
|
||||
if(!self.generator) {
|
||||
self.generator = [[KPKTimeOTPGenerator alloc] initWithAttributes:((KPKEntry *)self.representedObject).attributes];
|
||||
if(source != MPOTPUpdateSourceEntry) {
|
||||
NSAssert(self.generator, @"OTP Generator needs to be set when change source is not entry");
|
||||
}
|
||||
|
||||
switch(source) {
|
||||
case MPOTPUpdateSourceQRImage: {
|
||||
NSString *qrCodeString = self.qrCodeImageView.image.QRCodeString;
|
||||
@@ -169,47 +167,51 @@ typedef NS_ENUM(NSUInteger, MPOTPType) {
|
||||
self.generator = [[KPKTimeOTPGenerator alloc] initWithURL:self.urlTextField.stringValue];
|
||||
break;
|
||||
|
||||
case MPOTPUpdateSourceEntry:
|
||||
if(self.representedEntry.hasTimeOTP) {
|
||||
self.generator = [[KPKTimeOTPGenerator alloc] initWithAttributes:self.representedEntry.attributes];
|
||||
}
|
||||
else {
|
||||
self.generator = [[KPKTimeOTPGenerator alloc] init];
|
||||
}
|
||||
break;
|
||||
case MPOTPUpdateSourceSecret:
|
||||
self.generator.key = [NSData dataWithBase32EncodedString:self.secretTextField.stringValue];
|
||||
break;
|
||||
case MPOTPUpdateSourceAlgorithm:
|
||||
//self.generator.hashAlgorithm =
|
||||
self.generator.hashAlgorithm = (KPKOTPHashAlgorithm)self.algorithmPopUpButton.selectedTag;
|
||||
break;
|
||||
case MPOTPUpdateSourceTimeSlice:
|
||||
//self.generator.timeSlice =
|
||||
break;
|
||||
case MPOTPUpdateSourceEntry:
|
||||
self.generator.timeSlice = self.timeStepTextField.integerValue;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
/* FIXME: update correct values based on changes */
|
||||
/*
|
||||
The KPKTimeOTPGenerator is the sole data source. We do not need to query anything else
|
||||
*/
|
||||
|
||||
/* URL and QR code */
|
||||
KPKEntry *entry = self.representedObject;
|
||||
NSString *url = [entry attributeWithKey:kKPKAttributeKeyOTPOAuthURL].value;
|
||||
|
||||
self.urlTextField.stringValue = @"";
|
||||
|
||||
if(url) {
|
||||
NSURL *authURL = [NSURL URLWithString:url];
|
||||
if(authURL.isTimeOTPURL) {
|
||||
self.urlTextField.stringValue = authURL.absoluteString;
|
||||
self.qrCodeImageView.image = [NSImage QRCodeImageWithString:authURL.absoluteString];
|
||||
}
|
||||
if(!self.generator) {
|
||||
// display issues!
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// generate the URL
|
||||
|
||||
NSURL *authURL = [NSURL URLWithTimeOTPKey:self.generator.data algorithm:self.generator.hashAlgorithm issuer:self.representedEntry.title period:self.generator.timeSlice digits:self.generator.numberOfDigits];
|
||||
if(!authURL || !authURL.isTimeOTPURL) {
|
||||
// display issues
|
||||
return;
|
||||
}
|
||||
|
||||
self.urlTextField.stringValue = authURL.absoluteString;
|
||||
self.qrCodeImageView.image = [NSImage QRCodeImageWithString:authURL.absoluteString];
|
||||
|
||||
/* secret */
|
||||
NSString *secret = [self.generator.key base32EncodedStringWithOptions:0];
|
||||
self.secretTextField.stringValue = secret ? secret : @"";
|
||||
[self.algorithmPopUpButton selectItemWithTag:self.generator.hashAlgorithm];
|
||||
[self.digitCountPopUpButton selectItemWithTag:self.generator.numberOfDigits];
|
||||
self.timeSlice = self.generator.timeSlice;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user