SmartCredentialsLibrary 5.3.5

SmartCredentialsLibrary 5.3.5

Catalin HaidauCamelia Ignat 维护。



  • 德意志电信 AG

telekom/SmartCredentials-SDK-ios

Smart Credentials 是一个具有多个通用功能的库。重点是拥有非特定应用组件,以便它们可以轻松地集成到多个应用中。

在 SmartCredentialsLibrary 中使用的对象称为凭证。"物品"术语也用于指代凭证或其他可存储在库中的通用类型的对象。SmartCredentials 是一个通用库,旨在通过在凭证上启用不同的操作以及尽可能地保持它们通用,从而使凭证更加智能化。所以,项目是引用智能凭证对象的更通用的名称。

该库的一个目的是帮助应用程序检索和存储与用户相关的数据。该库本身是无数据类型的,可以处理敏感和普通用户数据。根据数据定义,该库具有内部机制来检索/存储内容或操作数据片段。

其他功能包括基于 QR 的登录、条码读取器、OCR 读取/解析器、OTP 生成器、指纹/密码/图案/面部 Id 授权。

SmartCredentials-SDK-ios 项目的文件采用 Apache-2.0 许可协议。有关详细信息,请参阅仓库最顶层的“LICENSE”文件。

使用方法

核心模块的初始化。

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let core = SmartCredentialsCoreFactory.smartCredentialsCoreAPI(configuration: configuration)

userId 参数是您希望得到的目标 id,jailbreakCheckEnabled 布尔值用于决定是否启用越狱检查功能。核心是一个 Core 模块实例,可用于执行多个非特定于模块的操作。

Smart Credentials 模块的初始化和使用 每个模块应使用其自己的工厂类在它们被使用的组件中或在应用级别进行实例化。

身份验证模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let authentication = SmartCredentialsAuthenticationFactory.smartCredentialsAuthenticationAPI(configuration: configuration)
// Use the Authenticaion API

授权模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let authorization = SmartCredentialsAuthorizationFactory.smartCredentialsAuthorizationAPI(configuration: configuration)
// Use the Authorization API

摄像头扫描模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let cameraScanner = SmartCredentialsCameraScannerFactory.smartCredentialsCameraScannerAPI(configuration: configuration)
// Use the CameraScanner API

文档扫描模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let documentScanner = SmartCredentialsDocumentScannerFactory.smartCredentialsDocumentScannerAPI(configuration: configuration, license: license, licensee: licensee)
// Use the DocumentScanner API

加密模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let encryption = SmartCredentialsEncryptionFactory.smartCredentialsEncryptionAPI(configuration: configuration)
// Use the Encryption API

网络模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let networking = SmartCredentialsNetworkingFactory.smartCredentialsNetworkingAPI(for: configuration, connectionType: .overWiFi)
// Use the Networking API

OTP 模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let otp = SmartCredentialsOTPFactory.smartCredentialsOTPAPI(configuration: configuration, storage: storage, cameraScanner: cameraScanner)
// Use the OTP API

二维码登录模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let qrLogin = SmartCredentialsQRLoginFactory.smartCredentialsQRLoginAPI(configuration: configuration, authorization: authorization)
// Use the QRLogin API

存储模块

let configuration = SmartCredentialsConfiguration(userId: "user_id", logger: DemoLogger(), jailbreakCheckEnabled: true)
let storage = SmartCredentialsStorageFactory.smartCredentialsStorageAPI(configuration: configuration)
// Use the Storage Api (see the example below)

Smart Credentials Storage API 工作示例

// Create an Item Envelope
let itemEnvelope = ItemEnvelopeFactory.itemEnvelope(with: itemId,
                                                    type: itemType,
                                                    identifier: identifier,
                                                    privateData: privateData)

// Create an Item Context that specifies the place where it will be stored
let itemContext = ItemContextFactory.itemContext(with: .sensitive)

// Creates an Item Filter in regards to an item content type and item id (for single item operations). This filter specifies the place where the items are held.
let itemFilter = ItemFilterFactory.itemFilter(with: itemId, contentType: .sensitive)

// Insert an item in the database
_ = storage.put(itemEnvelope, with: itemContext)

// Updates an item from the database
_ = storage.update(itemEnvelope, with: itemContext)

// Deletes an item from the database
_ = storage.removeItem(for: itemFilter)

// Retrieve all items according to a filter
let getItemsResult = storage.getAllItems(for: ItemFilterFactory.itemFilter())
switch getItemsResult {
case .success(let items):
    // handle items list
case .failure(let error):
    // handle error
}

支持

关于SmartCredentials库的讨论在此Slack通道进行。任何人都可以加入这些讨论。

贡献

我们欢迎对凭证管理、身份验证和以用户为中心的身份主题的任何贡献。我们更希望找到有兴趣将他们的解决方案添加到现有模块列表中的合作伙伴。然而,如果您认为对另一个人解决方案的改编会有所帮助,那么您可能就是那个人。只需确保您有权利处理相关的代码或可执行文件。

欢迎提交针对小改进或错误修复的拉取请求。对于重大更改,请先打开一个 issue 进行讨论,您想更改什么。

在贡献时,请查阅贡献指南编码标准

扩展

Smart Credentials是一个开放且易于扩展的库。事实上,它如此开放和可扩展,以至于任何人都可以提供任何模块的并行实现(核心模块除外)。

使用Smart Credentials构建您的模块,您不仅可以通过利用现有功能节省实施的时间和精力,而且新创建的模块还可以与Smart Credentials的任何现有模块相结合使用。

目前,有9个可扩展模块

  1. 身份验证
  2. 授权
  3. 相机
  4. 文档扫描仪
  5. 加密
  6. 网络
  7. OTP
  8. 二维码登录
  9. 存储

为了实现您自己的模块,您必须遵循以下步骤

1. 将Smart Credentials核心模块作为依赖项添加

to be added

2. 从核心模块实现API接口

API接口公开了一个统一且标准的协议,针对您选择扩展的具体功能。

3. 使用公开类

在核心模块中,除了API之外,您还能找到每个模块各自的公开类。我们将它们留下以便您重用功能并节省大量时间,或者因为它们标准化了一些功能或数据声明/交付的方式。

建议在开始扩展模块之前查看这些类,并尽可能多地使用这些类。

4. 公开您的API实现

别忘了让您的API实现对最终用户公开,并为他们提供创建API实现实例的方法。

5. 恭喜

如果您遵循了所有上述步骤并提供了API的可用实现,那么您应该已经有了自己的Smart Credentials模块了!

作者和致谢

SmartCredentials的愿景、架构和代码的主要贡献者包括:Jochen Klaffer、Zhiyun Ren、Axel Nennker以及Jörg Heuer支持下的若干钱包项目成员。

许可证

The code in this repository is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.