# QES (Qualified Electronic Signature)

The QES (Qualified Electronic Signature) module shows the user documents to sign, collects their consent, and captures a Qualified Electronic Signature (QES), the highest-assurance electronic signature under the [EU eIDAS Regulation](https://eur-lex.europa.eu/eli/reg/2014/910/oj/eng). A qualified certificate from a Qualified Trust Service Provider (QTSP) backs the signature, making it legally equivalent to a handwritten signature across EU member states.

For an overview of this module and how it works, see [Qualified Electronic Signature](https://developer.incode.com/docs/qualified-electronic-signature).

How you use this module depends on your integration pattern. When the app defines the steps in code, you add the module to an `IncdOnboardingFlowConfiguration` as shown below; when the flow is defined in Dashboard, you reference it by ID. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** All variants.

## Add QES

1. Add identity check modules before QES. [ID Capture](https://developer.incode.com/docs/module-id-scan), [Phone](https://developer.incode.com/docs/module-phone), and [Selfie](https://developer.incode.com/docs/module-selfie) must come before QES when included in the flow.
2. Add the module with `addQes()`.
   ```swift
   flowConfig.addQes(configuration: QESConfiguration(downloadDocument: true))
   ```

QES ships both a v1 and v2 UI.

## Configuration Options

Configure the module by passing a `QESConfiguration` to `addQes(configuration:)`.

| Option             | Type      | Description                                                                |
| ------------------ | --------- | -------------------------------------------------------------------------- |
| `downloadDocument` | `Bool?`   | When `true`, downloads the signed document. Defaults to `false`.           |
| `providerCode`     | `String?` | The QTSP provider code used for the signature. Optional.                   |
| `uploadDocument`   | `Bool?`   | Present on `QESConfiguration` but not currently applied by the QES module. |

## Result

`onQESCompleted` is called regardless of the outcome, and the user continues with any modules configured after QES.

```swift
func onQESCompleted(result: QESResult)
```

`QESResult` fields:

- `success: Bool`: `true` if the documents were signed successfully.
- `error: QESError?`: The signing error, or `nil` if there was no error.

`QESError` cases:

- `noDocuments`: No documents were available for the session.
- `failedToSign`: Signing failed.

<br />
