Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
phisakel committed Nov 15, 2023
1 parent fb5d2b3 commit 802555a
Show file tree
Hide file tree
Showing 10 changed files with 576 additions and 5 deletions.
19 changes: 18 additions & 1 deletion Documentation/Reference/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Reference Documentation

## Protocols

- [PresentationService](protocols/PresentationService.md)

## Structs

- [DocElementsViewModel](structs/DocElementsViewModel.md)
Expand All @@ -9,10 +13,23 @@
## Classes

- [EudiWallet](classes/EudiWallet.md)
- [PresentationSession](classes/PresentationSession.md)
- [StorageManager](classes/StorageManager.md)

## Enums

- [DataFormat](enums/DataFormat.md)
- [FlowType](enums/FlowType.md)
- [StorageType](enums/StorageType.md)

## Extensions

- [Array](extensions/Array.md)
- [BlePresentationService](extensions/BlePresentationService.md)
- [String](extensions/String.md)

This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs) on 2023-11-15 22:54:53 +0000
## Typealiases

- [RequestItems](typealiases/RequestItems.md)

This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs) on 2023-11-15 22:59:16 +0000
146 changes: 146 additions & 0 deletions Documentation/Reference/classes/PresentationSession.md
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
189 changes: 189 additions & 0 deletions Documentation/Reference/classes/StorageManager.md
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 |
Loading

0 comments on commit 802555a

Please sign in to comment.