CLASS
Contents
- Properties
storage
standard
userAuthenticationRequired
trustedReaderCertificates
deviceAuthMethod
verifierApiUri
openID4VciIssuerUrl
openID4VciClientId
openID4VciRedirectUri
useSecureEnclave
- Methods
init(storageType:serviceName:accessGroup:trustedReaderCertificates:userAuthenticationRequired:verifierApiUri:openID4VciIssuerUrl:openID4VciClientId:openID4VciRedirectUri:)
issueDocument(docType:format:)
beginIssueDocument(id:privateKeyType:)
endIssueDocument(_:)
loadDocuments()
deleteDocuments()
loadSampleData(sampleDataFiles:)
prepareServiceDataParameters(docType:dataFormat:)
beginPresentation(flow:docType:dataFormat:)
beginPresentation(service:)
authorizedAction(action:disabled:dismiss:localizedReason:)
public final class EudiWallet: ObservableObject
User wallet implementation
public private(set) var storage: StorageManager
Storage manager instance
public static private(set) var standard: EudiWallet = EudiWallet()
Instance of the wallet initialized with default parameters
public var userAuthenticationRequired: Bool
Whether user authentication via biometrics or passcode is required before sending user data
public var trustedReaderCertificates: [Data]?
Trusted root certificates to validate the reader authentication certificate included in the proximity request
public var deviceAuthMethod: DeviceAuthMethod = .deviceMac
Method to perform mdoc authentication (MAC or signature). Defaults to device MAC
public var verifierApiUri: String?
OpenID4VP verifier api URL (used for preregistered clients)
public var openID4VciIssuerUrl: String?
OpenID4VCI issuer url
public var openID4VciClientId: String?
OpenID4VCI client id
public var openID4VciRedirectUri: String = "eudi-openid4ci://authorize/"
OpenID4VCI redirect URI. Defaults to "eudi-openid4ci://authorize/"
public var useSecureEnclave: Bool
Use iPhone Secure Enclave to protect keys and perform cryptographic operations. Defaults to true (if available)
init(storageType:serviceName:accessGroup:trustedReaderCertificates:userAuthenticationRequired:verifierApiUri:openID4VciIssuerUrl:openID4VciClientId:openID4VciRedirectUri:)
public init(storageType: StorageType = .keyChain, serviceName: String = "eudiw", accessGroup: String? = nil, trustedReaderCertificates: [Data]? = nil, userAuthenticationRequired: Bool = true, verifierApiUri: String? = nil, openID4VciIssuerUrl: String? = nil, openID4VciClientId: String? = nil, openID4VciRedirectUri: String? = nil)
Initialize a wallet instance. All parameters are optional.
@discardableResult public func issueDocument(docType: String, format: DataFormat = .cbor) async throws -> WalletStorage.Document
Issue a document with the given docType using OpenId4Vci protocol
If userAuthenticationRequired
is true, user authentication is required. The authentication prompt message has localisation key "issue_document"
- Parameters:
- docType: Document type
- format: Optional format type. Defaults to cbor
- Returns: The document issued. It is saved in storage.
public func beginIssueDocument(id: String, privateKeyType: PrivateKeyType = .secureEnclaveP256) async throws -> IssueRequest
Begin issuing a document by generating an issue request
- Parameters:
- id: Document identifier
- issuer: Issuer function
Name | Description |
---|---|
id | Document identifier |
issuer | Issuer function |
public func endIssueDocument(_ issued: WalletStorage.Document) throws
End issuing by saving the issuing document (and its private key) in storage
- Parameter issued: The issued document
Name | Description |
---|---|
issued | The issued document |
@discardableResult public func loadDocuments() async throws -> [WalletStorage.Document]?
Load documents from storage
Calls storage
loadDocuments
- Returns: An array of
WalletStorage.Document
objects
public func deleteDocuments() async throws
Delete all documents from storage
Calls storage
loadDocuments
- Returns: An array of
WalletStorage.Document
objects
public func loadSampleData(sampleDataFiles: [String]? = nil) async throws
Load sample data from json files
The mdoc data are stored in wallet storage as documents
- Parameter sampleDataFiles: Names of sample files provided in the app bundle
Name | Description |
---|---|
sampleDataFiles | Names of sample files provided in the app bundle |
public func prepareServiceDataParameters(docType: String? = nil, dataFormat: DataFormat = .cbor ) throws -> [String : Any]
Prepare Service Data Parameters
- Parameters:
- docType: docType of documents to present (optional)
- dataFormat: Exchanged data
Format
type
- Returns: A data dictionary that can be used to initialize a presentation service
Name | Description |
---|---|
docType | docType of documents to present (optional) |
dataFormat | Exchanged data Format type |
public func beginPresentation(flow: FlowType, docType: String? = nil, dataFormat: DataFormat = .cbor) -> PresentationSession
Begin attestation presentation to a verifier
- Parameters:
- flow: Presentation
FlowType
instance - docType: DocType of documents to present (optional)
- dataFormat: Exchanged data
Format
type
- flow: Presentation
- Returns: A presentation session instance,
Name | Description |
---|---|
flow | Presentation FlowType instance |
docType | DocType of documents to present (optional) |
dataFormat | Exchanged data Format type |
public func beginPresentation(service: any PresentationService) -> PresentationSession
Begin attestation presentation to a verifier
- Parameters:
- service: A
PresentationService
instance - docType: DocType of documents to present (optional)
- dataFormat: Exchanged data
Format
type
- service: A
- Returns: A presentation session instance,
Name | Description |
---|---|
service | A PresentationService instance |
docType | DocType of documents to present (optional) |
dataFormat | Exchanged data Format type |
public static func authorizedAction(action: () async throws -> Void, disabled: Bool, dismiss: () -> Void, localizedReason: String) async throws
Perform an action after user authorization via TouchID/FaceID/Passcode
- Parameters:
- dismiss: Action to perform if the user cancels authorization
- action: Action to perform after user authorization