Skip to content

Commit

Permalink
Merge pull request #133 from mattrubin/keychain-cleanup
Browse files Browse the repository at this point in the history
Assorted Keychain cleanup
  • Loading branch information
mattrubin authored Feb 10, 2017
2 parents db49797 + 538abfd commit 7a6804d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public final class Keychain {
/// - throws: A `Keychain.Error` if an error occurred.
/// - returns: The persistent token, or `nil` if no token matched the given identifier.
public func persistentToken(withIdentifier identifier: Data) throws -> PersistentToken? {
return try keychainItem(forPersistentRef: identifier).flatMap(PersistentToken.init)
return try keychainItem(forPersistentRef: identifier).flatMap(PersistentToken.init(keychainDictionary:))
}

/// Returns the set of all persistent tokens found in the keychain.
///
/// - throws: A `Keychain.Error` if an error occurred.
public func allPersistentTokens() throws -> Set<PersistentToken> {
return Set(try allKeychainItems().flatMap(PersistentToken.init))
return Set(try allKeychainItems().flatMap(PersistentToken.init(keychainDictionary:)))
}

// MARK: Write
Expand Down Expand Up @@ -111,9 +111,7 @@ private let urlStringEncoding = String.Encoding.utf8
private extension Token {
func keychainAttributes() throws -> [String: AnyObject] {
let url = try self.toURL()
// This line supports the different optionality of `absoluteString` between Xcode 7 and 8
let urlString: String? = url.absoluteString
guard let data = urlString?.data(using: urlStringEncoding) else {
guard let data = url.absoluteString.data(using: urlStringEncoding) else {
throw Keychain.Error.tokenSerializationFailure
}
return [
Expand Down

0 comments on commit 7a6804d

Please sign in to comment.