-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
576 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
**CLASS** | ||
|
||
# `PresentationSession` | ||
|
||
**Contents** | ||
|
||
- [Properties](#properties) | ||
- `presentationService` | ||
- `readerCertIssuer` | ||
- `readerCertValidationMessage` | ||
- `uiError` | ||
- `disclosedDocuments` | ||
- `status` | ||
- `flow` | ||
- `deviceEngagement` | ||
- [Methods](#methods) | ||
- `init(presentationService:)` | ||
- `decodeRequest(_:)` | ||
- `startQrEngagement()` | ||
- `receiveRequest()` | ||
- `sendResponse(userAccepted:itemsToSend:onCancel:)` | ||
|
||
```swift | ||
public class PresentationSession: ObservableObject | ||
``` | ||
|
||
Presentation session | ||
|
||
This class wraps the ``PresentationService`` instance, providing bindable fields to a SwifUI view | ||
|
||
## Properties | ||
### `presentationService` | ||
|
||
```swift | ||
public var presentationService: any PresentationService | ||
``` | ||
|
||
### `readerCertIssuer` | ||
|
||
```swift | ||
@Published public var readerCertIssuer: String? | ||
``` | ||
|
||
Reader certificate issuer (only for BLE flow wih verifier using reader authentication) | ||
|
||
### `readerCertValidationMessage` | ||
|
||
```swift | ||
@Published public var readerCertValidationMessage: String? | ||
``` | ||
|
||
Reader certificate validation message (only for BLE transfer wih verifier using reader authentication) | ||
|
||
### `uiError` | ||
|
||
```swift | ||
@Published public var uiError: WalletError? | ||
``` | ||
|
||
Error message when the ``status`` is in the error state. | ||
|
||
### `disclosedDocuments` | ||
|
||
```swift | ||
@Published public var disclosedDocuments: [DocElementsViewModel] = [] | ||
``` | ||
|
||
Request items selected by the user to be sent to verifier. | ||
|
||
### `status` | ||
|
||
```swift | ||
@Published public var status: TransferStatus = .initializing | ||
``` | ||
|
||
Status of the data transfer. | ||
|
||
### `flow` | ||
|
||
```swift | ||
public var flow: FlowType | ||
``` | ||
|
||
The ``FlowType`` instance | ||
|
||
### `deviceEngagement` | ||
|
||
```swift | ||
@Published public var deviceEngagement: Data? | ||
``` | ||
|
||
Device engagement data (QR image data for the BLE flow) | ||
|
||
## Methods | ||
### `init(presentationService:)` | ||
|
||
```swift | ||
public init(presentationService: any PresentationService) | ||
``` | ||
|
||
### `decodeRequest(_:)` | ||
|
||
```swift | ||
public func decodeRequest(_ request: [String: Any]) | ||
``` | ||
|
||
Decodes a presentation request | ||
|
||
The ``disclosedDocuments`` property will be set. Additionally ``readerCertIssuer`` and ``readerCertValidationMessage`` may be set for the BLE proximity flow | ||
- Parameter request: Keys are defined in the ``UserRequestKeys`` | ||
|
||
### `startQrEngagement()` | ||
|
||
```swift | ||
public func startQrEngagement() async | ||
``` | ||
|
||
Start QR engagement to be presented to verifier | ||
|
||
On success ``deviceEngagement`` published variable will be set with the result and ``status`` will be ``.qrEngagementReady`` | ||
On error ``uiError`` will be filled and ``status`` will be ``.error`` | ||
|
||
### `receiveRequest()` | ||
|
||
```swift | ||
public func receiveRequest() async -> [String: Any]? | ||
``` | ||
|
||
Receive request from verifer | ||
|
||
The request is futher decoded internally. See also ``decodeRequest(_:)`` | ||
On success ``disclosedDocuments`` published variable will be set and ``status`` will be ``.requestReceived`` | ||
On error ``uiError`` will be filled and ``status`` will be ``.error`` | ||
- Returns: A request dictionary keyed by ``MdocDataTransfer.UserRequestKeys`` | ||
|
||
### `sendResponse(userAccepted:itemsToSend:onCancel:)` | ||
|
||
```swift | ||
public func sendResponse(userAccepted: Bool, itemsToSend: RequestItems, onCancel: (() -> Void)?) async | ||
``` | ||
|
||
Send response to verifier | ||
- Parameters: | ||
- userAccepted: Whether user confirmed to send the response | ||
- itemsToSend: Data to send organized into a hierarcy of doc.types and namespaces | ||
- onCancel: Action to perform if the user cancels the biometric authentication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
**CLASS** | ||
|
||
# `StorageManager` | ||
|
||
**Contents** | ||
|
||
- [Properties](#properties) | ||
- `knownDocTypes` | ||
- `docTypes` | ||
- `mdocModels` | ||
- `documentIds` | ||
- `hasData` | ||
- `hasWellKnownData` | ||
- `docCount` | ||
- `mdlModel` | ||
- `pidModel` | ||
- `otherModels` | ||
- [Methods](#methods) | ||
- `init(storageService:)` | ||
- `loadDocuments()` | ||
- `getDocumentModel(index:)` | ||
- `getDocumentModel(docType:)` | ||
- `deleteDocument(docType:)` | ||
- `deleteDocument(index:)` | ||
|
||
```swift | ||
public class StorageManager: ObservableObject | ||
``` | ||
|
||
Storage manager. Provides services and view models | ||
|
||
## Properties | ||
### `knownDocTypes` | ||
|
||
```swift | ||
public static let knownDocTypes = [EuPidModel.EuPidDocType, IsoMdlModel.isoDocType] | ||
``` | ||
|
||
### `docTypes` | ||
|
||
```swift | ||
public var docTypes: [String?] = [] | ||
``` | ||
|
||
Array of doc.types of documents loaded in the wallet | ||
|
||
### `mdocModels` | ||
|
||
```swift | ||
@Published public var mdocModels: [MdocDecodable?] = [] | ||
``` | ||
|
||
Array of document models loaded in the wallet | ||
|
||
### `documentIds` | ||
|
||
```swift | ||
public var documentIds: [String?] = [] | ||
``` | ||
|
||
Array of document identifiers loaded in the wallet | ||
|
||
### `hasData` | ||
|
||
```swift | ||
@Published public var hasData: Bool = false | ||
``` | ||
|
||
Whether wallet currently has loaded data | ||
|
||
### `hasWellKnownData` | ||
|
||
```swift | ||
@Published public var hasWellKnownData: Bool = false | ||
``` | ||
|
||
Whether wallet currently has loaded a document with doc.type included in the ``knownDocTypes`` array | ||
|
||
### `docCount` | ||
|
||
```swift | ||
@Published public var docCount: Int = 0 | ||
``` | ||
|
||
Count of documents loaded in the wallet | ||
|
||
### `mdlModel` | ||
|
||
```swift | ||
@Published public var mdlModel: IsoMdlModel? | ||
``` | ||
|
||
The driver license model loaded in the wallet | ||
|
||
### `pidModel` | ||
|
||
```swift | ||
@Published public var pidModel: EuPidModel? | ||
``` | ||
|
||
The PID model loaded in the wallet | ||
|
||
### `otherModels` | ||
|
||
```swift | ||
@Published public var otherModels: [GenericMdocModel] = [] | ||
``` | ||
|
||
Other document models loaded in the wallet | ||
|
||
## Methods | ||
### `init(storageService:)` | ||
|
||
```swift | ||
public init(storageService: any DataStorageService) | ||
``` | ||
|
||
### `loadDocuments()` | ||
|
||
```swift | ||
@discardableResult public func loadDocuments() -> [WalletStorage.Document]? | ||
``` | ||
|
||
Load documents from storage | ||
|
||
Internally sets the ``docTypes``, ``mdocModels``, ``documentIds``, ``mdocModels``, ``mdlModel``, ``pidModel`` variables | ||
- Returns: An array of ``WalletStorage.Document`` objects | ||
|
||
### `getDocumentModel(index:)` | ||
|
||
```swift | ||
public func getDocumentModel(index: Int) -> MdocDecodable? | ||
``` | ||
|
||
Get document model by index | ||
- Parameter index: Index in array of loaded models | ||
- Returns: The ``MdocDecodable`` model | ||
|
||
#### Parameters | ||
|
||
| Name | Description | | ||
| ---- | ----------- | | ||
| index | Index in array of loaded models | | ||
|
||
### `getDocumentModel(docType:)` | ||
|
||
```swift | ||
public func getDocumentModel(docType: String) -> MdocDecodable? | ||
``` | ||
|
||
Get document model by docType | ||
- Parameter docType: The docType of the document model to return | ||
- Returns: The ``MdocDecodable`` model | ||
|
||
#### Parameters | ||
|
||
| Name | Description | | ||
| ---- | ----------- | | ||
| docType | The docType of the document model to return | | ||
|
||
### `deleteDocument(docType:)` | ||
|
||
```swift | ||
public func deleteDocument(docType: String) | ||
``` | ||
|
||
Delete document by docType | ||
- Parameter docType: Document type | ||
|
||
#### Parameters | ||
|
||
| Name | Description | | ||
| ---- | ----------- | | ||
| docType | Document type | | ||
|
||
### `deleteDocument(index:)` | ||
|
||
```swift | ||
public func deleteDocument(index: Int) | ||
``` | ||
|
||
Delete document by Index | ||
- Parameter index: Index in array of loaded models | ||
|
||
#### Parameters | ||
|
||
| Name | Description | | ||
| ---- | ----------- | | ||
| index | Index in array of loaded models | |
Oops, something went wrong.