BioPass 2.3.1

BioPass 2.3.1

Linus Unnebäck 维护。



 
依赖项
PromiseKit~> 6.0
Valet~> 3.0
 

BioPass 2.3.1

  • 作者
  • Linus Unnebäck

BioPass

在生物特征认证的背后存储密码。

这是一个微型的库,用于在密钥链中存储密码,并指示密钥链只有在用户先使用 TouchID 或 FaceID 进行身份验证后才能提供密码。

BioPass 内部使用 Valet,但提供了一个更简单的使用 PromiseKit 的 API,所以您不需要考虑在哪个线程上调用。

注意:为了确保您的用户不会收到不支持 Face ID 的提示,您必须在您的应用程序的 Info.plist 中设置 Privacy - Face ID Usage Description (NSFaceIDUsageDescription) 键的值。

注意:BioPass 支持 iOS 9.0 和 macOS 10.12.1。

安装

SwiftPM

dependencies: [
    .package(url: "https://github.com/LinusU/BioPass", from: "2.0.0"),
]

Carthage

github "LinusU/BioPass" ~> 2.0.0

手动

如果您已安装了 ValetPromiseKit,您可以简单地将单个源文件 BioPass.swift 拖放到您的项目中。

用法

import BioPass
import PromiseKit

let bioPass = BioPass()

// Store a password for future retreival
firstly {
    bioPass.store("secret")
}.done {
    print("Password stored!")
}.catch { err in
    print("Failed to store password: \(err)")
}

// Retreive a stored password (will trigger TouchID / FaceID prompt)
firstly {
    bioPass.retreive(withPrompt: "Give us the secret password!")
}.done { password in
  print("The password was: \(password)")
}.catch { err in
    print("Failed to retreive password: \(err)")
}

// Delete the stored password
firstly {
    bioPass.delete()
}.done {
    print("Password deleted!")
}.catch { err in
    print("Failed to delete password: \(err)")
}

API

BioPass(_ serviceName: String = Bundle.main.bundleIdentifier!)

创建一个新的 BioPass 对象,可选地传入一个服务名称以存储密码。如果没有提供服务名称,它将默认为 Bundle.main.bundleIdentifier!

BioPass(withSharedAccessGroup sharedAccessGroupName: String)

创建一个新的 BioPass 对象,该对象将在共享密钥存储访问组中存储数据。`sharedAccessGroupName` 应该与开发者文件《keychain-access-groups》权限下的某个名称匹配(不需包含 10 个字符的 Bundle Seed ID,这部分将自动添加)。

.store(_ password: String) -> Promise

存储密码以便稍后检索。返回一个 Promise,当密码保存时将解决。

.retreive(withPrompt prompt: String) -> Promise<String?>

获取先前存储的密码。返回一个将兑现为密码的 Promise。如果用户取消认证或未存储密码,则 Promise 将以 nil 结算。

.delete() -> Promise<Void>

删除存储的密码。返回一个将在密码已删除时兑现的 Promise

黑客攻击

Xcode项目是由project.yml通过XcodeGen自动生成的。它仅因为Carthage需要它而提交,请不要手动编辑它。