📄 DocumentStore
Before you can create or manage real-world identity documents, you need to set up repositories and storage for document types and documents. This should be done after initializing your secure storage components.
DocumentTypeRepository
A DocumentTypeRepository manages the metadata for different document types your app understands and uses.
- Standard Document Types: Multipaz provides a set of standard document types through the
multipaz-knowntypespackage, such as:DrivingLicenseEUCertificateOfResidencePhotoIDVaccinationDocumentVehicleRegistration
- Custom Document Types: You can define your own document types using the
DocumentType.Builderfactory method.
DocumentStore
A DocumentStore is responsible for securely holding and managing real-world identity documents, such as Mobile Driving Licenses (mDL), in accordance with the ISO/IEC 18013-5:2021 specification.
- Initialization: Create a
DocumentStoreinstance using either thebuildDocumentStorefunction or theDocumentStore.Builderclass. - Dependencies: Pass the previously-initialized
storageandsecureAreaRepositoryto theDocumentStore.
Implementation
In the modularized sample, this is handled inside AppContainerImpl in the core module:
// core/src/commonMain/kotlin/.../core/AppContainer.kt
interface AppContainer {
val documentTypeRepository: DocumentTypeRepository
val documentStore: DocumentStore
// ... rest of the implementations
}
Refer to this AppContainer code for the complete example.
// core/src/commonMain/kotlin/.../core/AppContainerImpl.kt
class AppContainerImpl : AppContainer {
// ...
override lateinit var documentTypeRepository: DocumentTypeRepository
override lateinit var documentStore: DocumentStore
override suspend fun init() {
if (isInitialized) return
// ... storage initialization
// DocumentStore
documentTypeRepository = DocumentTypeRepository().apply {
addDocumentType(DrivingLicense.getDocumentType())
}
documentStore = buildDocumentStore(
storage = storage,
secureAreaRepository = secureAreaRepository
) {}
// ...
isInitialized = true
}
}
By clearly structuring the setup of DocumentTypeRepository and DocumentStore, you ensure your app is ready to manage identity documents securely and efficiently. Always perform this setup early in your app lifecycle, after initializing storage and secure areas.
Refer to this DocumentStore code for the complete example.