2
0

Compare commits

...

10 Commits

Author SHA1 Message Date
Maarten Billemont
1651e9ad4a Automatic configuration cleanup. 2020-04-09 21:04:35 -04:00
Maarten Billemont
02c1e2af46 straf relies on a nil terminator. 2020-04-09 21:03:59 -04:00
Maarten Billemont
b275286b2d Consent and notification permissions on the main thread. 2020-04-09 21:03:11 -04:00
Maarten Billemont
7818feaf0b Disable the login field if login is generated. 2020-04-08 20:21:58 -04:00
Maarten Billemont
3970cd2eac Remove unused lvar. 2020-04-08 20:21:42 -04:00
Maarten Billemont
21b0053ccb Copy login name on shift & update UI to reflect it. 2020-04-08 19:36:19 -04:00
Maarten Billemont
6dd8790404 Enable/disable Sentry on iOS with sendInfo. 2020-04-07 16:05:53 -04:00
Maarten Billemont
508abec94e Toggle Sentry and Countly when sendInfo is enabled/disabled. 2020-04-07 16:04:17 -04:00
Maarten Billemont
b010432796 Toggle sendInfo through preferences & move user import/export. 2020-04-07 15:30:23 -04:00
Maarten Billemont
a91e65f72f Push notification support on macOS. 2020-04-06 23:11:36 -04:00
10 changed files with 119 additions and 66 deletions

View File

@@ -3370,8 +3370,6 @@
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = Source/Mac/MasterPassword.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
COMBINE_HIDPI_IMAGES = YES;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
@@ -3410,8 +3408,6 @@
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = Source/Mac/MasterPassword.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
COMBINE_HIDPI_IMAGES = YES;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12118"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -12,11 +12,14 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="AMainMenu" systemMenu="main" id="29"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<point key="canvasLocation" x="139" y="155"/>
</menu>
<customObject id="494" customClass="MPMacAppDelegate">
<connections>
<outlet property="createUserItem" destination="757" id="763"/>
<outlet property="deleteUserItem" destination="ZgZ-p2-463" id="smU-PF-mKA"/>
<outlet property="diagnosticsItem" destination="GSN-f0-q7s" id="kns-3O-fu0"/>
<outlet property="hidePasswordsItem" destination="9G7-17-PzY" id="qPX-VT-jVx"/>
<outlet property="lockItem" destination="720" id="726"/>
<outlet property="openAtLoginItem" destination="785" id="788"/>
@@ -33,7 +36,7 @@
<items>
<menuItem title="Users" id="755">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Users" id="756">
<menu key="submenu" title="Users" autoenablesItems="NO" id="756">
<items>
<menuItem title="New User" enabled="NO" toolTip="Creating users is not yet supported. Please use the iOS app with iCloud enabled to create users and sites." id="757">
<modifierMask key="keyEquivalentModifierMask"/>
@@ -47,6 +50,53 @@
<action selector="deleteUser:" target="494" id="eia-X5-QMc"/>
</connections>
</menuItem>
<menuItem title="Import User..." id="EFK-zt-EvJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="importSites:" target="494" id="CNv-4j-036"/>
</connections>
</menuItem>
<menuItem title="Export User" id="r1P-hr-mh5">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Export User" id="fnk-gK-yCi">
<items>
<menuItem title="Secure Export (recommended)" id="06i-og-eLt">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="exportSitesSecure:" target="494" id="LVH-es-imA"/>
</connections>
</menuItem>
<menuItem title="Your passwords are hidden." enabled="NO" id="ybY-P3-eao">
<attributedString key="attributedTitle">
<fragment content="Your passwords are not visible.">
<attributes>
<font key="NSFont" metaFont="user"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Reveal Passwords" id="fMG-TT-bTn">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="exportSitesReveal:" target="494" id="1IW-VT-Oeu"/>
</connections>
</menuItem>
<menuItem title="Handy for backups - keep it in a safe location!" enabled="NO" id="cQu-oR-SUa">
<attributedString key="attributedTitle">
<fragment content="Keep this file secure or delete it when you're done with it!">
<attributes>
<font key="NSFont" metaFont="user"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="759"/>
</items>
</menu>
@@ -152,53 +202,23 @@
</attributedString>
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Export Sites" id="r1P-hr-mh5">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Export Sites" id="fnk-gK-yCi">
<items>
<menuItem title="Secure Export" id="06i-og-eLt">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="exportSitesSecure:" target="494" id="LVH-es-imA"/>
</connections>
</menuItem>
<menuItem title="Your passwords are not visible." enabled="NO" id="ybY-P3-eao">
<attributedString key="attributedTitle">
<fragment content="Your passwords are not visible.">
<attributes>
<font key="NSFont" size="12" name="Helvetica"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Reveal Passwords" id="fMG-TT-bTn">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="exportSitesReveal:" target="494" id="1IW-VT-Oeu"/>
</connections>
</menuItem>
<menuItem title="Keep this file secure or delete it when you're done with it!" enabled="NO" id="cQu-oR-SUa">
<attributedString key="attributedTitle">
<fragment content="Keep this file secure or delete it when you're done with it!">
<attributes>
<font key="NSFont" size="12" name="Helvetica"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Import Sites..." id="EFK-zt-EvJ">
<menuItem title="Diagnostics" id="GSN-f0-q7s">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="importSites:" target="494" id="CNv-4j-036"/>
<action selector="togglePreference:" target="494" id="ZNq-yf-fxg"/>
</connections>
</menuItem>
<menuItem title="Crash and usage information is anonymized and sent to development." enabled="NO" id="WfD-lX-C93">
<attributedString key="attributedTitle">
<fragment content="Save the password in your keychain so you don't need to enter it again.">
<attributes>
<font key="NSFont" size="11" name="Helvetica"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" firstLineHeadIndent="8"/>
</attributes>
</fragment>
</attributedString>
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</menuItem>
@@ -221,6 +241,7 @@
</connections>
</menuItem>
</items>
<point key="canvasLocation" x="140" y="23"/>
</menu>
</objects>
</document>

View File

@@ -34,6 +34,7 @@
@property(nonatomic, weak) IBOutlet NSMenuItem *openAtLoginItem;
@property(nonatomic, weak) IBOutlet NSMenuItem *showFullScreenItem;
@property(nonatomic, weak) IBOutlet NSMenuItem *savePasswordItem;
@property(nonatomic, weak) IBOutlet NSMenuItem *diagnosticsItem;
@property(nonatomic, weak) IBOutlet NSMenuItem *createUserItem;
@property(nonatomic, weak) IBOutlet NSMenuItem *deleteUserItem;
@property(nonatomic, weak) IBOutlet NSMenuItem *usersItem;

View File

@@ -29,6 +29,7 @@
#define LOGIN_HELPER_BUNDLE_ID @"com.lyndir.lhunath.MasterPassword.Mac.LoginHelper"
@implementation MPMacAppDelegate
#pragma clang diagnostic push
@@ -369,6 +370,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
- (IBAction)togglePreference:(id)sender {
if (sender == self.diagnosticsItem)
[MPConfig get].sendInfo = @(self.diagnosticsItem.state != NSOnState);
if (sender == self.hidePasswordsItem)
[MPConfig get].hidePasswords = @(self.hidePasswordsItem.state != NSOnState);
if (sender == self.rememberPasswordItem)
@@ -579,10 +582,13 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
- (void)updateUsers {
[[[self.usersItem submenu] itemArray] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if (idx > 2)
[[self.usersItem submenu] removeItem:obj];
}];
BOOL foundSeparator = NO;
for (NSMenuItem *item in [[self.usersItem submenu] itemArray]) {
if (foundSeparator)
[[self.usersItem submenu] removeItem:item];
else if (item.isSeparatorItem)
foundSeparator = YES;
}
NSManagedObjectContext *mainContext = [MPMacAppDelegate managedObjectContextForMainThreadIfReady];
if (!mainContext) {
@@ -712,6 +718,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
- (void)updateConfigKey:(NSString *)key {
PearlMainQueue( ^{
if (!key || [key isEqualToString:NSStringFromSelector( @selector( sendInfo ) )])
self.diagnosticsItem.state = [[MPConfig get].sendInfo boolValue]? NSOnState: NSOffState;
if (!key || [key isEqualToString:NSStringFromSelector( @selector( hidePasswords ) )])
self.hidePasswordsItem.state = [[MPConfig get].hidePasswords boolValue]? NSOnState: NSOffState;
if (!key || [key isEqualToString:NSStringFromSelector( @selector( rememberLogin ) )])
@@ -720,7 +728,10 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
// Send info
if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance giveConsentForAllFeatures];
PearlMainQueue( ^{
[Countly.sharedInstance giveConsentForAllFeatures];
[Countly.sharedInstance askForNotificationPermission];
});
if ([PearlLogger get].printLevel > PearlLogLevelInfo)
[PearlLogger get].printLevel = PearlLogLevelInfo;
@@ -738,13 +749,17 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
prefs[@"encrypted"] = @([PearlDeviceUtils isAppEncrypted]);
prefs[@"platform"] = [PearlDeviceUtils platform];
[SentrySDK.currentHub getClient].options.enabled = @YES;
[SentrySDK configureScope:^(SentryScope *scope) {
for (NSString *pref in prefs.allKeys)
[scope setExtraValue:prefs[pref] forKey:pref];
}];
}
else {
[Countly.sharedInstance cancelConsentForAllFeatures];
[SentrySDK.currentHub getClient].options.enabled = @NO;
PearlMainQueue( ^{
[Countly.sharedInstance cancelConsentForAllFeatures];
});
}
}

View File

@@ -270,7 +270,9 @@
PearlMainQueue( ^{
self.content = result;
self.displayedContent = displayResult;
if (!([NSEvent modifierFlags] & NSShiftKeyMask))
self.displayedContent = displayResult;
} );
}
@@ -278,6 +280,9 @@
PearlMainQueue( ^{
self.loginName = loginName;
if ([NSEvent modifierFlags] & NSShiftKeyMask)
self.displayedContent = loginName;
} );
}

View File

@@ -66,7 +66,7 @@
[self updateUser];
} );
[self observeKeyPath:@"sitesController.selection" withBlock:^(id from, id to, NSKeyValueChange cause, id self) {
[self updateSelection];
[self updateTable];
}];
prof_rewind( @"observers" );
@@ -105,14 +105,18 @@
- (void)flagsChanged:(NSEvent *)theEvent {
BOOL shiftPressed = (theEvent.modifierFlags & NSShiftKeyMask) != 0;
if (shiftPressed != self.shiftPressed)
if (shiftPressed != self.shiftPressed) {
self.shiftPressed = shiftPressed;
[self.selectedSite updateContent];
[self updateSelection];
}
BOOL alternatePressed = (theEvent.modifierFlags & NSAlternateKeyMask) != 0;
if (alternatePressed != self.alternatePressed) {
self.alternatePressed = alternatePressed;
self.showVersionContainer = self.alternatePressed || self.selectedSite.outdated;
[self.selectedSite updateContent];
[self updateSelection];
if (self.locked) {
NSTextField *passwordField = self.securePasswordField;
@@ -261,6 +265,9 @@
[alert setInformativeText:strf( @"Your login name for: %@", self.selectedSite.name )];
NSTextField *loginField = [NSTextField new];
[loginField bind:@"value" toObject:self.selectedSite withKeyPath:@"loginName" options:nil];
[loginField bind:@"enabled" toObject:self.selectedSite withKeyPath:@"loginGenerated" options:@{
NSValueTransformerNameBindingOption: NSNegateBooleanTransformerName
}];
NSButton *generatedField = [NSButton new];
[generatedField setButtonType:NSSwitchButton];
[generatedField bind:@"value" toObject:self.selectedSite withKeyPath:@"loginGenerated" options:nil];
@@ -477,7 +484,7 @@
}
// Performing action while content is available. Copy it.
[self copyContent:self.shiftPressed? selectedSite.answer: selectedSite.content];
[self copyContent:self.shiftPressed? selectedSite.loginName: selectedSite.content];
[NSApp hide:nil];
NSUserNotification *notification = [NSUserNotification new];
@@ -582,7 +589,7 @@
}];
}
- (void)updateSelection {
- (void)updateTable {
[self.siteTable scrollRowToVisible:(NSInteger)self.sitesController.selectionIndex];
@@ -596,8 +603,13 @@
(__bridge id)[NSColor colorWithDeviceWhite:1 alpha:gradientOpacity].CGColor
];
[self updateSelection];
}
- (void)updateSelection {
self.showVersionContainer = self.alternatePressed || self.selectedSite.outdated;
[self.sitePasswordTipField setAttributedStringValue:straf( @"Your password for %@:", self.selectedSite.displayedName )];
[self.sitePasswordTipField setAttributedStringValue:
straf( @"Your %@ for %@:", self.shiftPressed? @"login": @"password", self.selectedSite.displayedName, nil )];
}
- (void)createNewSite:(NSString *)siteName {

View File

@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>

View File

@@ -681,12 +681,14 @@
prefs[@"reviewedVersion"] = @(YES);
#endif
[SentrySDK.currentHub getClient].options.enabled = @YES;
[SentrySDK configureScope:^(SentryScope *scope) {
for (NSString *pref in prefs.allKeys)
[scope setExtraValue:prefs[pref] forKey:pref];
}];
}
else {
[SentrySDK.currentHub getClient].options.enabled = @NO;
[Countly.sharedInstance cancelConsentForAllFeatures];
}
}

View File

@@ -122,7 +122,6 @@ const char *mpw_site_result(
return NULL;
}
char *sitePassword = NULL;
if (resultType & MPResultTypeClassTemplate) {
switch (algorithmVersion) {
case MPAlgorithmVersionV0:
@@ -172,7 +171,7 @@ const char *mpw_site_result(
err( "Unsupported password type: %d", resultType );
}
return sitePassword;
return NULL;
}
const char *mpw_site_state(