Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mssun committed Jan 20, 2018
2 parents c45a08b + 954888b commit 1eba23e
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode9
osx_image: xcode9.2
branches:
only:
- develop
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ platform :ios, '10.2'
use_frameworks!

target 'passKit' do
pod 'ObjectivePGP', :git => 'https://github.com/krzyzanowskim/ObjectivePGP.git', :tag => '0.9.0'
pod 'ObjectivePGP', :git => 'https://github.com/krzyzanowskim/ObjectivePGP.git', :tag => '0.10.0-beta2'
target 'pass' do
inherit! :search_paths
end
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane
update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
Expand Down
1 change: 1 addition & 0 deletions fastlane/travis.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

gem update fastlane
gem install xcodeproj
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
fastlane test;
else
Expand Down
184 changes: 90 additions & 94 deletions pass/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pass/Controllers/PasswordsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
}()
private lazy var searchBarView: UIView? = {
guard #available(iOS 11, *) else {
let uiView = UIView(frame: CGRect(x: 0, y: 64, width: self.view.bounds.width, height: 56))
let uiView = UIView(frame: CGRect(x: 0, y: 64, width: self.view.bounds.width, height: 44))
uiView.addSubview(self.searchController.searchBar)
return uiView
}
Expand Down Expand Up @@ -203,7 +203,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV

override func viewDidLoad() {
super.viewDidLoad()
tabBarController!.delegate = self
searchController.searchBar.delegate = self
tableView.delegate = self
tableView.dataSource = self
Expand All @@ -215,7 +214,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
navigationItem.hidesSearchBarWhenScrolling = false
} else {
// Fallback on earlier versions
tableView.contentInset = UIEdgeInsetsMake(56, 0, 0, 0)
tableView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0)
view.addSubview(searchBarView!)
}
tableView.refreshControl = syncControl
Expand All @@ -234,6 +233,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
tabBarController!.delegate = self
if let path = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: path, animated: false)
}
Expand All @@ -242,7 +242,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
guard #available(iOS 11, *) else {
searchBarView?.frame = CGRect(x: 0, y: navigationController!.navigationBar.bounds.size.height + UIApplication.shared.statusBarFrame.height, width: UIScreen.main.bounds.width, height: 56)
searchBarView?.frame = CGRect(x: 0, y: navigationController!.navigationBar.bounds.size.height + UIApplication.shared.statusBarFrame.height, width: UIScreen.main.bounds.width, height: 44)
searchController.searchBar.sizeToFit()
return
}
Expand Down Expand Up @@ -554,9 +554,9 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
self.tapTabBarTime = currentTime
if duration < 0.35 {
let topIndexPath = IndexPath(row: 0, section: 0)
if let _ = tableView.cellForRow(at: topIndexPath) {
tableView.scrollToRow(at: topIndexPath, at: .bottom, animated: true)
}
if tableView.numberOfSections > 0 {
tableView.scrollToRow(at: topIndexPath, at: .bottom, animated: true)
}
self.tapTabBarTime = 0
return
}
Expand Down
11 changes: 10 additions & 1 deletion pass/Controllers/SettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import PasscodeLock
import LocalAuthentication
import passKit

class SettingsTableViewController: UITableViewController {
class SettingsTableViewController: UITableViewController, UITabBarControllerDelegate {

lazy var touchIDSwitch: UISwitch = {
let uiSwitch = UISwitch(frame: CGRect.zero)
Expand All @@ -29,6 +29,10 @@ class SettingsTableViewController: UITableViewController {
let passwordStore = PasswordStore.shared
var passcodeLockConfig = PasscodeLockConfiguration.shared

func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
navigationController?.popViewController(animated: true)
}

@IBAction func savePGPKey(segue: UIStoryboardSegue) {
if let controller = segue.source as? PGPKeySettingTableViewController {
SharedDefaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!)
Expand Down Expand Up @@ -140,6 +144,11 @@ class SettingsTableViewController: UITableViewController {
setPasscodeLockTouchIDCells()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
tabBarController!.delegate = self
}

private func hasTouchID() -> Bool {
let context = LAContext()
var error: NSError?
Expand Down
12 changes: 6 additions & 6 deletions pass/Views/LabelTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -19,17 +19,17 @@
<rect key="frame" x="0.0" y="0.0" width="333" height="58.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="content" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yyr-cF-QN0">
<rect key="frame" x="8" y="27" width="305" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="content" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yyr-cF-QN0">
<rect key="frame" x="16" y="27" width="297" height="21"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="21" id="pgw-DF-LQa"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" text="title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dqz-7n-uEZ">
<rect key="frame" x="8" y="11" width="317" height="13"/>
<rect key="frame" x="16" y="11" width="301" height="13"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="12"/>
<color key="textColor" red="0.0" green="0.47843137254901957" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
Expand Down
29 changes: 16 additions & 13 deletions passKit/Models/PasswordStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class PasswordStore {
}
}

public var pgp: ObjectivePGP = ObjectivePGP()
public let keyring = ObjectivePGP.defaultKeyring

public var pgpKeyPassphrase: String? {
set {
Expand Down Expand Up @@ -192,7 +192,7 @@ public class PasswordStore {
try initPGPKey(.secret)
}

public func initPGPKey(_ keyType: PGPPartialKeyType) throws {
public func initPGPKey(_ keyType: PGPKeyType) throws {
switch keyType {
case .public:
let keyPath = Globals.pgpPublicKeyPath
Expand All @@ -211,7 +211,7 @@ public class PasswordStore {
}
}

public func initPGPKey(from url: URL, keyType: PGPPartialKeyType) throws {
public func initPGPKey(from url: URL, keyType: PGPKeyType) throws {
var pgpKeyLocalPath = ""
if keyType == .public {
pgpKeyLocalPath = Globals.pgpPublicKeyPath
Expand All @@ -223,7 +223,7 @@ public class PasswordStore {
try initPGPKey(keyType)
}

public func initPGPKey(with armorKey: String, keyType: PGPPartialKeyType) throws {
public func initPGPKey(with armorKey: String, keyType: PGPKeyType) throws {
var pgpKeyLocalPath = ""
if keyType == .public {
pgpKeyLocalPath = Globals.pgpPublicKeyPath
Expand All @@ -237,8 +237,8 @@ public class PasswordStore {

private func importKey(from keyPath: String) -> Key? {
if fm.fileExists(atPath: keyPath) {
let keys = ObjectivePGP.readKeys(from: keyPath)
pgp.import(keys: keys)
let keys = try! ObjectivePGP.readKeys(fromPath: keyPath)
keyring.import(keys: keys)
if !keys.isEmpty {
return keys.first
}
Expand All @@ -247,7 +247,7 @@ public class PasswordStore {
}

public func getPgpPrivateKey() -> Key {
return pgp.keys.filter({$0.secretKey != nil})[0]
return keyring.keys.filter({$0.secretKey != nil})[0]
}

public func repositoryExisted() -> Bool {
Expand Down Expand Up @@ -840,20 +840,23 @@ public class PasswordStore {
if passphrase == nil {
passphrase = requestPGPKeyPassphrase()
}
let decryptedData = try PasswordStore.shared.pgp.decrypt(encryptedData, passphrase: passphrase)
let decryptedData = try ObjectivePGP.decrypt(encryptedData, andVerifySignature: false, using: keyring.keys, passphraseForKey: {(_) in passphrase})
let plainText = String(data: decryptedData, encoding: .utf8) ?? ""
let escapedPath = passwordEntity.path!.stringByAddingPercentEncodingForRFC3986() ?? ""
return Password(name: passwordEntity.name!, url: URL(string: escapedPath), plainText: plainText)
}

public func encrypt(password: Password) throws -> Data {
let publicKey = pgp.keys.filter({$0.publicKey != nil})
guard publicKey.count > 0 else {
guard keyring.keys.count > 0 else {
throw AppError.PGPPublicKeyNotExistError
}
let plainData = password.getPlainData()
let encryptedData = try pgp.encrypt(plainData, using: Array(publicKey), armored: SharedDefaults[.encryptInArmored])
return encryptedData
let encryptedData = try ObjectivePGP.encrypt(plainData, addSignature: false, using: keyring.keys, passphraseForKey: nil)
if SharedDefaults[.encryptInArmored] {
return Armor.armored(encryptedData, as: .message).data(using: .utf8)!
} else {
return encryptedData
}
}

public func removePGPKeys() {
Expand All @@ -865,7 +868,7 @@ public class PasswordStore {
SharedDefaults.remove(.pgpPrivateKeyURL)
SharedDefaults.remove(.pgpPublicKeyURL)
Utils.removeKeychain(name: ".pgpKeyPassphrase")
pgp = ObjectivePGP()
keyring.deleteAll()
publicKey = nil
privateKey = nil
}
Expand Down

0 comments on commit 1eba23e

Please sign in to comment.