TegKeychainConstants.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Foundation
  2. import Security
  3. /// Constants used by the library
  4. public struct KeychainSwiftConstants {
  5. /// Specifies a Keychain access group. Used for sharing Keychain items between apps.
  6. public static var accessGroup: String { return toString(kSecAttrAccessGroup) }
  7. /**
  8. A value that indicates when your app needs access to the data in a keychain item. The default value is AccessibleWhenUnlocked. For a list of possible values, see KeychainSwiftAccessOptions.
  9. */
  10. public static var accessible: String { return toString(kSecAttrAccessible) }
  11. /// Used for specifying a String key when setting/getting a Keychain value.
  12. public static var attrAccount: String { return toString(kSecAttrAccount) }
  13. /// Used for specifying synchronization of keychain items between devices.
  14. public static var attrSynchronizable: String { return toString(kSecAttrSynchronizable) }
  15. /// An item class key used to construct a Keychain search dictionary.
  16. public static var klass: String { return toString(kSecClass) }
  17. /// Specifies the number of values returned from the keychain. The library only supports single values.
  18. public static var matchLimit: String { return toString(kSecMatchLimit) }
  19. /// A return data type used to get the data from the Keychain.
  20. public static var returnData: String { return toString(kSecReturnData) }
  21. /// Used for specifying a value when setting a Keychain value.
  22. public static var valueData: String { return toString(kSecValueData) }
  23. /// Used for returning a reference to the data from the keychain
  24. public static var returnReference: String { return toString(kSecReturnPersistentRef) }
  25. static func toString(_ value: CFString) -> String {
  26. return value as String
  27. }
  28. }