Skip to content

Commit

Permalink
Document KeychainStore methods using the itemName parameter (google#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmathias authored Jan 18, 2023
1 parent f34be7a commit 139ae32
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions GTMAppAuth/Sources/KeychainStore/KeychainStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ public final class KeychainStore: NSObject, AuthSessionStore {
)
}

/// Saves the provided `AuthSession` using the provided item name.
///
/// - Parameters:
/// - authSession: An instance of `AuthSession` to save.
/// - itemName: A `String` name to use for the save that is different than the name given during
/// initialization.
/// - Throws: Any error that may arise during the save.
@objc(saveAuthSession:withItemName:error:)
public func save(authSession: AuthSession, withItemName itemName: String) throws {
let authSessionData = try authSessionData(fromAuthSession: authSession)
Expand Down Expand Up @@ -138,6 +145,12 @@ public final class KeychainStore: NSObject, AuthSessionStore {
return keyedArchiver.encodedData
}

/// Removes the stored `AuthSession` matching the provided item name.
///
/// - Parameters:
/// - itemName: A `String` name to use for the removal different than what was given during
/// initialization.
/// - Throws: Any error that may arise during the removal.
@objc public func removeAuthSession(withItemName itemName: String) throws {
try keychainHelper.removePassword(forService: itemName)
}
Expand All @@ -163,6 +176,12 @@ public final class KeychainStore: NSObject, AuthSessionStore {
return keyedUnarchiver
}

/// Retrieves the stored `AuthSession` matching the provided item name.
///
/// - Parameters:
/// - itemName: A `String` name for the item to retrieve different than what was given during
/// initialization.
/// - Throws: Any error that may arise during the retrieval.
@objc public func retrieveAuthSession(withItemName itemName: String) throws -> AuthSession {
let passwordData = try keychainHelper.passwordData(forService: itemName)

Expand Down

0 comments on commit 139ae32

Please sign in to comment.