2015-01-25 20:21:50 +11:00
2015-01-25 18:54:03 +11:00
2015-01-25 18:54:03 +11:00
2015-01-25 18:54:03 +11:00
2015-01-25 20:23:55 +11:00

Locksmith

A sane way to work with the iOS Keychain in Swift.

CI Status Version License Platform

Installation

Locksmith is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Locksmith"

Quick Start

Save Data

Locksmith.saveData(["some key": "some value"], inService: "myService", forUserAccount: "myUserAccount")

Load Data

let (dictionary, error) = Locksmith.loadData(inService: "myService", forUserAccount: "myUserAccount")

Update Data

Locksmith.updateData(["some key": "another value"], inService: "myService", forUserAccount: "myUserAccount")

Delete Data

Locksmith.deleteData(inService: "myService", forUserAccount: "myUserAccount")

Custom Requests

To create custom keychain requests, you first have to instantiate a LocksmithRequest. This request can be customised as much as required. Then callLocksmith.performRequest on that request.

Saving

let saveRequest = LocksmithRequest(service: service, userAccount: userAccount, data: ["some key": "some value"])
// Customize the request
saveRequest.synchronizable = true
Locksmith.performRequest(saveRequest)

Reading

let readRequest = LocksmithRequest(service: service, userAccount: userAccount)
let (dictionary, error) = Locksmith.performRequest(readRequest)

Deleting

let deleteRequest = LocksmithRequest(service: service, userAccount: userAccount, requestType: .Delete)
Locksmith.performRequest(deleteRequest)

LocksmithRequest

Use these attributes to customize your LocksmithRequest instance.

If you need any more custom attributes, either create a pull request or open an issue.

Required

var service: String
var userAccount: String
var type: RequestType             // Defaults to .Read

Optional

var group: String?                // Used for keychain sharing
var data: NSDictionary?           // Used only for write requests
var matchLimit: MatchLimit        // Defaults to .One
var securityClass: SecurityClass  // Defaults to .GenericPassword
var synchronizable: Bool          // Defaults to false

Author

matthewpalmer, matt@matthewpalmer.net

License

Locksmith is available under the MIT license. See the LICENSE file for more info.

S
Description
A powerful, protocol-oriented library for working with the keychain in Swift.
Readme MIT
834 KiB
Languages
Swift 97.9%
Ruby 1.9%
Objective-C 0.2%