Skip to content
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

Add support for accessGroup #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Source/Locksmith.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,49 @@ public typealias PerformRequestClosureType = (_ requestReference: CFDictionary,

// MARK: - Locksmith
public struct Locksmith {
public static func loadDataForUserAccount(userAccount: String, inService service: String = LocksmithDefaultService) -> [String: Any]? {
public static func loadDataForUserAccount(userAccount: String, inService service: String = LocksmithDefaultService, accessGroup: String? = nil) -> [String: Any]? {
struct ReadRequest: GenericPasswordSecureStorable, ReadableSecureStorable {
let service: String
let account: String
let accessGroup: String?
}

let request = ReadRequest(service: service, account: userAccount)
let request = ReadRequest(service: service, account: userAccount, accessGroup: accessGroup)
return request.readFromSecureStore()?.data
}

public static func saveData(data: [String: Any], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService) throws {
public static func saveData(data: [String: Any], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService, accessGroup: String? = nil) throws {
struct CreateRequest: GenericPasswordSecureStorable, CreateableSecureStorable {
let service: String
let account: String
let data: [String: Any]
let accessGroup: String?
}

let request = CreateRequest(service: service, account: userAccount, data: data)
let request = CreateRequest(service: service, account: userAccount, data: data, accessGroup: accessGroup)
return try request.createInSecureStore()
}

public static func deleteDataForUserAccount(userAccount: String, inService service: String = LocksmithDefaultService) throws {
public static func deleteDataForUserAccount(userAccount: String, inService service: String = LocksmithDefaultService, accessGroup: String? = nil) throws {
struct DeleteRequest: GenericPasswordSecureStorable, DeleteableSecureStorable {
let service: String
let account: String
let accessGroup: String?
}

let request = DeleteRequest(service: service, account: userAccount)
let request = DeleteRequest(service: service, account: userAccount, accessGroup: accessGroup)
return try request.deleteFromSecureStore()
}

public static func updateData(data: [String: Any], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService) throws {
public static func updateData(data: [String: Any], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService, accessGroup: String? = nil) throws {
struct UpdateRequest: GenericPasswordSecureStorable, CreateableSecureStorable {
let service: String
let account: String
let data: [String: Any]
let accessGroup: String?
}

let request = UpdateRequest(service: service, account: userAccount, data: data)
let request = UpdateRequest(service: service, account: userAccount, data: data, accessGroup: accessGroup)
try request.updateInSecureStore()
}
}
Expand Down