-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 3 function names #80
Changes from all commits
3938c8f
d901c06
99f58cb
9cfa146
5b59ab0
893a163
7a34f87
fa65b0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,8 @@ 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 persistentTokenWithIdentifier(_ identifier: Data) throws -> PersistentToken? { | ||
return try keychainItemForPersistentRef(identifier).flatMap(PersistentToken.init) | ||
public func persistentToken(withIdentifier identifier: Data) throws -> PersistentToken? { | ||
return try keychainItem(forPersistentRef: identifier).flatMap(PersistentToken.init) | ||
} | ||
|
||
/// Returns the set of all persistent tokens found in the keychain. | ||
|
@@ -58,9 +58,9 @@ public final class Keychain { | |
/// | ||
/// - throws: A `Keychain.Error` if the token was not added successfully. | ||
/// - returns: The new persistent token. | ||
public func addToken(_ token: Token) throws -> PersistentToken { | ||
public func add(_ token: Token) throws -> PersistentToken { | ||
let attributes = try token.keychainAttributes() | ||
let persistentRef = try addKeychainItemWithAttributes(attributes) | ||
let persistentRef = try addKeychainItem(withAttributes: attributes) | ||
return PersistentToken(token: token, identifier: persistentRef) | ||
} | ||
|
||
|
@@ -71,11 +71,9 @@ public final class Keychain { | |
/// | ||
/// - throws: A `Keychain.Error` if the update did not succeed. | ||
/// - returns: The updated persistent token. | ||
public func updatePersistentToken(_ persistentToken: PersistentToken, | ||
withToken token: Token) throws -> PersistentToken | ||
{ | ||
public func update(_ persistentToken: PersistentToken, with token: Token) throws -> PersistentToken { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line Length Violation: Line should be 100 characters or less: currently 105 characters (line_length) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Barely over the limit, and definitely more readable on one line. |
||
let attributes = try token.keychainAttributes() | ||
try updateKeychainItemForPersistentRef(persistentToken.identifier, | ||
try updateKeychainItem(forPersistentRef: persistentToken.identifier, | ||
withAttributes: attributes) | ||
return PersistentToken(token: token, identifier: persistentToken.identifier) | ||
} | ||
|
@@ -88,8 +86,8 @@ public final class Keychain { | |
/// - parameter persistentToken: The persistent token to delete. | ||
/// | ||
/// - throws: A `Keychain.Error` if the deletion did not succeed. | ||
public func deletePersistentToken(_ persistentToken: PersistentToken) throws { | ||
try deleteKeychainItemForPersistentRef(persistentToken.identifier) | ||
public func delete(_ persistentToken: PersistentToken) throws { | ||
try deleteKeychainItem(forPersistentRef: persistentToken.identifier) | ||
} | ||
|
||
// MARK: Errors | ||
|
@@ -139,7 +137,7 @@ private extension PersistentToken { | |
} | ||
} | ||
|
||
private func addKeychainItemWithAttributes(_ attributes: [String: AnyObject]) throws -> Data { | ||
private func addKeychainItem(withAttributes attributes: [String: AnyObject]) throws -> Data { | ||
var mutableAttributes = attributes | ||
mutableAttributes[kSecClass as String] = kSecClassGenericPassword | ||
mutableAttributes[kSecReturnPersistentRef as String] = kCFBooleanTrue | ||
|
@@ -163,7 +161,7 @@ private func addKeychainItemWithAttributes(_ attributes: [String: AnyObject]) th | |
return persistentRef | ||
} | ||
|
||
private func updateKeychainItemForPersistentRef(_ persistentRef: Data, | ||
private func updateKeychainItem(forPersistentRef persistentRef: Data, | ||
withAttributes attributesToUpdate: [String: AnyObject]) throws | ||
{ | ||
let queryDict: [String : AnyObject] = [ | ||
|
@@ -178,7 +176,7 @@ private func updateKeychainItemForPersistentRef(_ persistentRef: Data, | |
} | ||
} | ||
|
||
private func deleteKeychainItemForPersistentRef(_ persistentRef: Data) throws { | ||
private func deleteKeychainItem(forPersistentRef persistentRef: Data) throws { | ||
let queryDict: [String : AnyObject] = [ | ||
kSecClass as String: kSecClassGenericPassword, | ||
kSecValuePersistentRef as String: persistentRef as NSData, | ||
|
@@ -191,7 +189,7 @@ private func deleteKeychainItemForPersistentRef(_ persistentRef: Data) throws { | |
} | ||
} | ||
|
||
private func keychainItemForPersistentRef(_ persistentRef: Data) throws -> NSDictionary? { | ||
private func keychainItem(forPersistentRef persistentRef: Data) throws -> NSDictionary? { | ||
let queryDict: [String : AnyObject] = [ | ||
kSecClass as String: kSecClassGenericPassword, | ||
kSecValuePersistentRef as String: persistentRef as NSData, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ extension Token { | |
|
||
/// Attempts to initialize a token represented by the give URL. | ||
public init?(url: URL, secret: Data? = nil) { | ||
if let token = tokenFromURL(url, secret: secret) { | ||
if let token = token(from: url, secret: secret) { | ||
self = token | ||
} else { | ||
return nil | ||
|
@@ -117,7 +117,7 @@ private func urlForToken(name: String, issuer: String, factor: Generator.Factor, | |
return url | ||
} | ||
|
||
private func tokenFromURL(_ url: URL, secret externalSecret: Data? = nil) -> Token? { | ||
private func token(from url: URL, secret externalSecret: Data? = nil) -> Token? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function Body Length Violation: Function body should span 40 lines or less excluding comments and whitespace: currently spans 46 lines (function_body_length) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignoring these warnings, as the represent issues that already exist and aren't being exacerbated by this PR. |
||
guard url.scheme == kOTPAuthScheme else { | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid Docs Violation: Documented declarations should be valid. (valid_docs)