Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
84a0044
WIP [CORE-3421] first steps of adding the external credentials supportˆ
alexandr-simprints Jul 29, 2025
9504059
[WIP] Adding external credentials to the Realm DBˆ
alexandr-simprints Aug 4, 2025
f279637
[CORE-3421] Adding external credential support on Domain, DB (Realm, …
alexandr-simprints Aug 10, 2025
d61fb62
[CORE-3421] Fixing testsˆ
alexandr-simprints Aug 10, 2025
0660608
[CORE-3421] Fixing testsˆ
alexandr-simprints Aug 10, 2025
5317e06
[CORE-3421] Fixing testsˆ
alexandr-simprints Aug 10, 2025
54f7ddf
[CORE-3421] Fixing testsˆ
alexandr-simprints Aug 10, 2025
d806959
[CORE-3421] Fixing testsˆˆ
alexandr-simprints Aug 10, 2025
6aedb12
[CORE-3421] Fixing tests
alexandr-simprints Aug 10, 2025
23a6c01
[CORE-3421] Adding 1->2 Room migrationˆ
alexandr-simprints Aug 12, 2025
7c2c5ff
[CORE-3421] Moving Room DB version to a static field so that it can b…
alexandr-simprints Aug 12, 2025
3036a3a
[CORE-3421] Updating tests
alexandr-simprints Aug 12, 2025
f0d359c
[CORE-3421] Removing unused classes
alexandr-simprints Aug 12, 2025
e445a48
[CORE-3421] External credentials are now stored as list on the Enrolm…
alexandr-simprints Aug 25, 2025
b372abe
[CORE-3421] Moving external credential Realm mapper to its separate file
alexandr-simprints Aug 25, 2025
b715b1b
[CORE-3421] EnrolmentRecordMoveEvent now contains external credentialˆ
alexandr-simprints Aug 25, 2025
16e166a
[CORE-3421] Reverting addition of the external credentials in Subject…
alexandr-simprints Aug 25, 2025
a3ed7f6
[CORE-3421] Addition of the external credentials back in SubjectBiome…
alexandr-simprints Aug 25, 2025
37d8cb4
[CORE-3421] Fixing tests
alexandr-simprints Aug 26, 2025
05d2a00
[CORE-3421] Adding test coverage for ExternalCredentialType
alexandr-simprints Aug 26, 2025
301e1f9
Merge pull request #1306 from Simprints/CORE-3421-search-verify-sync-…
alexandr-simprints Aug 26, 2025
6821840
Merge branch 'main' into CORE-3404-search-verify
alexandr-simprints Aug 26, 2025
dddaeb2
[CORE-3404] Merging with main
alexandr-simprints Sep 10, 2025
95de956
[CORE-3404] Adding 'id' field to the extˆernal credential but keeping…
alexandr-simprints Sep 10, 2025
846849c
[MS-1127] Changing type of API credential to follow the BFSID style
alexandr-simprints Sep 10, 2025
3ed2472
[MS-1127] Creating fundamental base for MF-ID navigation in Enrol or …
alexandr-simprints Sep 10, 2025
bc215dd
[MS-1127] Fixing room migrations, adding ID fieldˆ
alexandr-simprints Sep 11, 2025
724e6ac
[MS-1127] Adding version 2 for generated SubjectDatabase schema
alexandr-simprints Sep 11, 2025
e74f1c4
[MS-1127] Adding index for Foreign Key check speedup
alexandr-simprints Sep 11, 2025
f2498ce
[MS-1127] Fixing migrationsˆ
alexandr-simprints Sep 11, 2025
a1e03a7
[MS-1127] Fixing tests
alexandr-simprints Sep 11, 2025
88f4431
[MS-1127] Renaming subject migrations to explicit classˆ
alexandr-simprints Sep 11, 2025
c8106ee
[MS-1127] Adding test coverage for BuildStepsUseCaseTest.kt
alexandr-simprints Sep 11, 2025
4320188
Merge pull request #1358 from Simprints/MS-1127-mf-id-implementation-…
alexandr-simprints Sep 18, 2025
43c9f87
[MS-1163] Implementation of the External Credential selection screen
alexandr-simprints Sep 18, 2025
60414a2
[MS-1163] Adding ViewModel tests
alexandr-simprints Sep 19, 2025
c2a0669
[MS-1165] MFID: QR code implementation. Login and MFID QRCode reader …
alexandr-simprints Sep 19, 2025
b1d6b5a
[MS-1165] MFID: QR code reader further adjustments
alexandr-simprints Sep 20, 2025
2d530cd
[MS-1165] MFID: Adding instructions text to QR code reader
alexandr-simprints Sep 20, 2025
e8c53bb
[MS-1165] MFID: Adding test coverageˆ
alexandr-simprints Sep 20, 2025
c8dede8
[MS-1165] MFID: Adding test coverage
alexandr-simprints Sep 22, 2025
8a0a21d
MFID: Adding external credentials feature to PR checks
alexandr-simprints Sep 22, 2025
10fa2b0
MFID: Adding external credentials feature to PR checks
alexandr-simprints Sep 22, 2025
836f285
[MS-1165] Excluding PermissionRequestView from test coverage
alexandr-simprints Sep 22, 2025
c524a78
[MS-1165] Moving field into a constant
alexandr-simprints Sep 24, 2025
05a5ee8
[MS-1165] Refactoring dialog declaration
alexandr-simprints Sep 24, 2025
0324b6f
[MS-1165] Refactoring dialog declaration
alexandr-simprints Sep 24, 2025
4c430a5
[MS-1165] Refactoring string usage to be more language-specific
alexandr-simprints Sep 24, 2025
fe7ff4e
[MS-1165] Refactoring string usage to use plurals
alexandr-simprints Sep 24, 2025
5df8a11
Merge pull request #1369 from Simprints/MS-1165-mf-id-implementation-…
alexandr-simprints Sep 24, 2025
a2ffcf5
Merge pull request #1367 from Simprints/MS-1163-mf-id-implementation-…
alexandr-simprints Sep 24, 2025
2e0b95e
[MS-1164] Initial commit for OCR scanner implementation
alexandr-simprints Sep 26, 2025
88deb7c
[MS-1164] Optimization for OCR scanner. State of fragment-related ele…
alexandr-simprints Sep 28, 2025
1bbde6f
[MS-1164] Adding ExternalCredentialSelectViewModel test coverage
alexandr-simprints Sep 28, 2025
7a77077
[MS-1164] Removing accidental local commit
alexandr-simprints Sep 29, 2025
d9cd8d6
[MS-1164] Removing outdated comments
alexandr-simprints Sep 29, 2025
38cbf52
[MS-1167] Implementing zoom-in onto scanend external credential area
alexandr-simprints Sep 29, 2025
4d78193
[MS-1164] Moving BoundingBox extensions to the class definition
alexandr-simprints Sep 29, 2025
cfecd89
[MS-1164] Removing extra declarations
alexandr-simprints Sep 29, 2025
9fdfa74
[MS-1164] Adding sanity checks to CalculateLevenshteinDistanceUseCase…
alexandr-simprints Sep 29, 2025
a3ff925
[MS-1164] Moving separateˆ comments into a single one
alexandr-simprints Sep 29, 2025
9acc01a
[MS-1164] Refactoring return type to an assignment
alexandr-simprints Sep 29, 2025
d6310a0
[MS-1164] Removing unnecessary call to viewmodel's field
alexandr-simprints Sep 29, 2025
edce350
[MS-1164] Switching IO dispatcher to BG
alexandr-simprints Sep 29, 2025
867cc00
[MS-1164] Removing unnecessary use case
alexandr-simprints Sep 29, 2025
9e663be
[MS-1167] Rendering views based on state on External Credential searc…
alexandr-simprints Sep 29, 2025
18e0c2c
[MS-1190] Refactoring 'feature:match' module into 'infra:matching' an…
alexandr-simprints Sep 30, 2025
4b295c4
[MS-1164] Using a regular for-loop to not confusing the "return" stat…
alexandr-simprints Sep 30, 2025
2511e66
[MS-1164] Refactoring GetExternalCredentialBasedOnConfidenceUseCase. …
alexandr-simprints Sep 30, 2025
072d59e
[MS-1164] Adding sanity checks to CalculateLevenshteinDistanceUseCase…
luhmirin-s Sep 30, 2025
22f4ff4
[MS-1190] Fixing tests and formatting
alexandr-simprints Sep 30, 2025
d2019a3
[MS-1190] Updating pr-check.yml to include `infra:matching`
alexandr-simprints Sep 30, 2025
23118ee
Merge pull request #1380 from Simprints/MS-1190-refactor-feature-matc…
alexandr-simprints Sep 30, 2025
6dfd811
Merge branch 'CORE-3404-search-verify' into MS-1164-mf-id-implementat…
alexandr-simprints Sep 30, 2025
ffce454
Merge pull request #1379 from Simprints/MS-1164-mf-id-implementation-…
alexandr-simprints Sep 30, 2025
8d4524c
Merge branch 'CORE-3404-search-verify' into MS-1167-mf-id-implementat…
alexandr-simprints Sep 30, 2025
a463d2f
[MS-1190] Updating UI of OCR fragment - surrounding area goes white w…
alexandr-simprints Oct 2, 2025
f4e5272
[MS-1167] Updating UI of OCR fragment - adding animations for completion
alexandr-simprints Oct 2, 2025
998f0c4
[MS-1167] Intermediate implementation of the Credential Search screen…
alexandr-simprints Oct 3, 2025
082b473
[MS-1167] Adding unit tests
alexandr-simprints Oct 3, 2025
74e4b0e
[MS-1167] Zoomed-in image of credential is now created in the Externa…
alexandr-simprints Oct 4, 2025
3067804
[MS-1167] External Credential values are now using explicit Tokenizab…
alexandr-simprints Oct 6, 2025
80b987b
[MS-1167] UI updates: adding a separate landscape view for credential…
alexandr-simprints Oct 6, 2025
3d65653
[MS-1170] MF-ID: Initial implementation of the 'Confirm Identity' flo…
alexandr-simprints Oct 7, 2025
c710edc
[MS-1170] MF-ID: Secondary implementation of the 'Confirm Identity' f…
alexandr-simprints Oct 7, 2025
04c46d2
[MS-1167] Refactoring ViewExt.kt to use expression body
alexandr-simprints Oct 7, 2025
5ef369f
[MS-1167] Refactoring ViewExt.kt parameters order
alexandr-simprints Oct 7, 2025
aa117d0
[MS-1167] Renaming mappers according to conventions
alexandr-simprints Oct 7, 2025
9937398
[MS-1167] Refactoring to use scale factor instead of percentage. Simp…
alexandr-simprints Oct 7, 2025
4d334d9
[MS-1167] Using compat methods; removing magic constants
alexandr-simprints Oct 7, 2025
30a0308
[MS-1167] Refactoring to use expression body
alexandr-simprints Oct 7, 2025
7033f52
[MS-1167] Refactoring with KtLint
alexandr-simprints Oct 7, 2025
d86bc56
[MS-1167] Using common style instead of duplicating
alexandr-simprints Oct 7, 2025
420d0d0
[MS-1167] Making test in ZoomOntoCredentialUseCaseTest more comprehen…
alexandr-simprints Oct 7, 2025
9d0092d
[MS-1167] Refactoring to use expression bodyˆ
alexandr-simprints Oct 7, 2025
ec212c9
[MS-1167] Applying KtLint
alexandr-simprints Oct 7, 2025
11895f2
[MS-1167] Applying KtLint
alexandr-simprints Oct 7, 2025
a4aa5ef
[MS-1167] Making comments more consistent and avoiding usage of magic…
alexandr-simprints Oct 7, 2025
3020db5
Merge branch 'MS-1167-mf-id-implementation-search-screen' into MS-117…
alexandr-simprints Oct 7, 2025
3e9f4ef
[CORE-3404] Applytin KtLint formatting
alexandr-simprints Oct 8, 2025
e6f3d85
[MS-1167] Applying KtLint formatting
alexandr-simprints Oct 8, 2025
07098ca
Merge branch 'MS-1167-mf-id-implementation-search-screen' into MS-117…
alexandr-simprints Oct 8, 2025
24a34d1
Merge pull request #1390 from Simprints/MS-1167-mf-id-implementation-…
alexandr-simprints Oct 8, 2025
bd366cc
[MS-1170] Moving AddExternalCredentialToSubjectUseCase to external-cr…
alexandr-simprints Oct 8, 2025
0117ae3
[MS-1170] Excluding views and enums from test coverage
alexandr-simprints Oct 8, 2025
c47ba7a
[MS-1170] Excluding views from ˆtest coverage
alexandr-simprints Oct 8, 2025
20c32af
[CORE-3404] Applying KtLint
alexandr-simprints Oct 8, 2025
ecbbfa1
Merge branch 'CORE-3404-search-verify' into MS-1170-mf-id-implementat…
alexandr-simprints Oct 8, 2025
af0a0bc
[MS-1169] Initial implementation of the Enrol Last + Credential funct…
alexandr-simprints Oct 8, 2025
d16651b
[MS-1166] Initial implementation of the Skip Credential screen
alexandr-simprints Oct 8, 2025
8642b58
[MS-1166] Adding analytical reminder comment
alexandr-simprints Oct 9, 2025
7faae76
[MS-1170] Using correct scope to delete files
alexandr-simprints Oct 9, 2025
ea86e44
[MS-1170] Using ViewModel's scope for async operations, and only usin…
alexandr-simprints Oct 9, 2025
261bec8
[MS-1189] Adding MFID-specific consent text
alexandr-simprints Oct 9, 2025
35c6d2e
[MS-1170] Using correct scope in view model
alexandr-simprints Oct 9, 2025
ef1461a
[MS-1170] Fixing failing tests
alexandr-simprints Oct 9, 2025
056e044
Merge branch 'MS-1170-mf-id-implementation-confirm-identity-credentia…
alexandr-simprints Oct 9, 2025
1b2d76c
Merge branch 'MS-1169-mf-id-implementation-enrol-last-credential-save…
alexandr-simprints Oct 9, 2025
cadde42
Merge branch 'MS-1166-mf-id-implementation-skip-screen' into MS-1189-…
alexandr-simprints Oct 9, 2025
f063852
[MS-1198] Identification response now includes credential information…
alexandr-simprints Oct 9, 2025
ec44a71
Merge pull request #1396 from Simprints/MS-1170-mf-id-implementation-…
alexandr-simprints Oct 9, 2025
9779b42
Merge branch 'CORE-3404-search-verify' into MS-1169-mf-id-implementat…
alexandr-simprints Oct 9, 2025
5d37b57
Merge branch 'MS-1169-mf-id-implementation-enrol-last-credential-save…
alexandr-simprints Oct 9, 2025
97da10e
Merge branch 'MS-1166-mf-id-implementation-skip-screen' into MS-1189-…
alexandr-simprints Oct 9, 2025
514ee12
Merge branch 'MS-1189-md-id-consent-update' into MS-1198-mf-id-implem…
alexandr-simprints Oct 9, 2025
2814f55
Merge branch 'main' into CORE-3404-search-verify
alexandr-simprints Oct 10, 2025
eaa56ba
Merge branch 'CORE-3404-search-verify' into MS-1169-mf-id-implementat…
alexandr-simprints Oct 10, 2025
86233e3
Merge branch 'MS-1169-mf-id-implementation-enrol-last-credential-save…
alexandr-simprints Oct 10, 2025
1f8510a
Merge branch 'MS-1166-mf-id-implementation-skip-screen' into MS-1189-…
alexandr-simprints Oct 10, 2025
741d69d
Merge branch 'MS-1189-md-id-consent-update' into MS-1198-mf-id-implem…
alexandr-simprints Oct 10, 2025
6c97652
[MS-1199] Adding 'EnrolmentUpdate' event that captures addition of ex…
alexandr-simprints Oct 12, 2025
dd94835
[MFID PREVIEW] Removing tests from the build actions. Leaving only St…
alexandr-simprints Oct 12, 2025
9b5db4d
[MFID PREVIEW] Passing external credential value instead of tokenizat…
alexandr-simprints Oct 13, 2025
a78a48b
[MFID PREVIEW] Removing legacy response types for the MFID testing
alexandr-simprints Oct 13, 2025
447dcf3
[MFID PREVIEW] Verification threshold is now explicitly passed to the…
alexandr-simprints Oct 13, 2025
e58b44f
[MFID PREVIEW] External credential field is now an array in the ApiEn…
alexandr-simprints Oct 13, 2025
f9d267c
[MS-1169] Updating tests
alexandr-simprints Oct 14, 2025
ea63685
[MFID PREVIEW BUILD] Creating 'AppExternalCredential' class for app r…
alexandr-simprints Oct 14, 2025
20d8d0d
[MFID PREVIEW BUILD] Passing payload ID for credential, instead of cr…
alexandr-simprints Oct 14, 2025
b4af02e
[MFID PREVIEW BUILD] Enrolment Record update now uses list of credent…
alexandr-simprints Oct 14, 2025
a4958da
[MFID PREVIEW BUILD] Adding extra logging to be able to trace down th…
alexandr-simprints Oct 14, 2025
de9d99e
[MFID PREVIEW BUILD] Removing extra logging that traced the external …
alexandr-simprints Oct 15, 2025
655b5a1
[MS-1169] Updating test coverage
alexandr-simprints Oct 15, 2025
c5e0ed1
[MS-1169] Adding extra test coverage
alexandr-simprints Oct 15, 2025
7af652b
[MS-1169] Using external credential's value field to pass to SQL buil…
alexandr-simprints Oct 15, 2025
11a28c3
Merge branch 'MS-1169-mf-id-implementation-enrol-last-credential-save…
alexandr-simprints Oct 15, 2025
927f18d
[MS-1166] Removing old tests, updating existing tests of ExternalCred…
alexandr-simprints Oct 15, 2025
74d89d7
Merge branch 'MS-1166-mf-id-implementation-skip-screen' into MS-1189-…
alexandr-simprints Oct 15, 2025
5d1e59e
[MS-1189] Adding test coverage for updated MFID consent wording
alexandr-simprints Oct 15, 2025
52a2601
Merge branch 'MS-1189-md-id-consent-update' into MS-1198-mf-id-implem…
alexandr-simprints Oct 15, 2025
6cda049
Merge branch 'MS-1198-mf-id-implementation-update-identification-and-…
alexandr-simprints Oct 15, 2025
14c5ca5
Merge branch 'MS-1199-mf-id-implementation-fix-sync-issues' into mfid…
alexandr-simprints Oct 15, 2025
87f4b6e
[MFID PREVIEW] Fixing tests
alexandr-simprints Oct 16, 2025
23b7584
[MFID PREVIEW] Fixing tests
alexandr-simprints Oct 16, 2025
b562fb6
[MS-1189] Removing outdated comments
alexandr-simprints Oct 20, 2025
0241ddd
[MFID PREVIEW] Removing unnecessary plurals from strings.xml, and ren…
alexandr-simprints Oct 20, 2025
21193e0
Merge pull request #1409 from Simprints/MS-1189-md-id-consent-update
alexandr-simprints Oct 20, 2025
fab0972
Merge pull request #1408 from Simprints/MS-1166-mf-id-implementation-…
alexandr-simprints Oct 20, 2025
245c173
[MFID PREVIEW] Changing plural string to a singular
alexandr-simprints Oct 20, 2025
4e13b71
Merge pull request #1407 from Simprints/MS-1169-mf-id-implementation-…
alexandr-simprints Oct 20, 2025
99efd57
Merge branch 'main' into CORE-3404-search-verify
alexandr-simprints Oct 20, 2025
5e874b6
Merge branch 'CORE-3404-search-verify' into mfid-preview-build-2025-4-0
alexandr-simprints Oct 20, 2025
3129f96
[MFID PREVIEW] Adding test coverage for LibSimprintsResponseMapper
alexandr-simprints Oct 21, 2025
42f4b35
[MFID PREVIEW] Adding test coverage for ExternalCredentialViewModel
alexandr-simprints Oct 21, 2025
816a0ec
[MFID PREVIEW] Adding test coverage for ClientApiViewModel
alexandr-simprints Oct 21, 2025
86df903
[MFID PREVIEW] Excluding events from test coverage reports
alexandr-simprints Oct 21, 2025
d815b6a
Merge branch 'main' into CORE-3404-search-verify
alexandr-simprints Oct 21, 2025
8ee8efc
Merge branch 'CORE-3404-search-verify' into mfid-preview-build-2025-4-0
alexandr-simprints Oct 21, 2025
053e62b
[MFID PREVIEW] Reverting deployment workflows that were created speci…
alexandr-simprints Oct 21, 2025
577f433
MS-1205 Remove redundant endTime from credential capture event payload
luhmirin-s Oct 20, 2025
7b9333e
MS-1205 Add boilerplate and track ExternalCredentialSearch event
luhmirin-s Oct 20, 2025
8aac815
MS-1205 Add correct values to ExternalCredentialCaptureEvent
luhmirin-s Oct 21, 2025
f506e29
MS-1205 Add ExternalCredentialSelection tracking with boilerplate
luhmirin-s Oct 21, 2025
59c71d0
MS-1205 Add ExternalCredentialConfirmationEvent tracking and boilerplate
luhmirin-s Oct 21, 2025
989fb80
Merge pull request #1420 from Simprints/feature/MS-1205-mfid-events-1
luhmirin-s Oct 22, 2025
c33e082
Merge branch 'main' into CORE-3404-search-verify
alexandr-simprints Oct 22, 2025
e8b6f84
Translate strings.xml in am
transifex-integration[bot] Oct 21, 2025
42e9545
Translate strings.xml in fr
transifex-integration[bot] Oct 22, 2025
ab69457
Translate strings.xml in hi
transifex-integration[bot] Oct 22, 2025
c6bd0f6
Translate strings.xml in bn
transifex-integration[bot] Oct 22, 2025
44d9ee1
Remove am-ET translations
luhmirin-s Oct 22, 2025
bec2e5a
Merge branch 'CORE-3404-search-verify' into mfid-preview-build-2025-4-0
alexandr-simprints Oct 22, 2025
50d6085
Merge branch 'main' into CORE-3404-search-verify
alexandr-simprints Oct 22, 2025
06822c8
Merge branch 'CORE-3404-search-verify' into mfid-preview-build-2025-4-0
alexandr-simprints Oct 22, 2025
c66c62d
Merge pull request #1410 from Simprints/mfid-preview-build-2025-4-0
alexandr-simprints Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
infra:recent-user-activity
infra:config-store
infra:config-sync
infra:credential-store
infra:sync
reportsId: infra1

Expand All @@ -51,6 +52,7 @@ jobs:
infra:images
infra:auth-store
infra:auth-logic
infra:matching
reportsId: infra2

feature-unit-tests1:
Expand All @@ -65,6 +67,7 @@ jobs:
feature:alert
feature:exit-form
feature:select-subject-age-group
feature:external-credential
reportsId: feature1

feature-unit-tests2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.simprints.core.domain.externalcredential.ExternalCredential
import com.simprints.core.domain.tokenization.TokenizableString
import com.simprints.core.livedata.LiveDataEvent
import com.simprints.core.livedata.LiveDataEventWithContent
import com.simprints.core.livedata.send
Expand All @@ -21,6 +23,9 @@ import com.simprints.feature.clientapi.usecases.GetEnrolmentCreationEventForSubj
import com.simprints.feature.clientapi.usecases.IsFlowCompletedWithErrorUseCase
import com.simprints.feature.clientapi.usecases.SimpleEventReporter
import com.simprints.infra.authstore.AuthStore
import com.simprints.infra.config.store.models.Project
import com.simprints.infra.config.store.models.TokenKeyType
import com.simprints.infra.config.store.tokenization.TokenizationProcessor
import com.simprints.infra.config.sync.ConfigManager
import com.simprints.infra.logging.LoggingConstants.CrashReportTag.ORCHESTRATION
import com.simprints.infra.logging.Simber
Expand All @@ -30,6 +35,7 @@ import com.simprints.infra.orchestration.data.ActionResponse
import com.simprints.infra.orchestration.data.responses.AppConfirmationResponse
import com.simprints.infra.orchestration.data.responses.AppEnrolResponse
import com.simprints.infra.orchestration.data.responses.AppErrorResponse
import com.simprints.infra.orchestration.data.responses.AppExternalCredential
import com.simprints.infra.orchestration.data.responses.AppIdentifyResponse
import com.simprints.infra.orchestration.data.responses.AppRefusalResponse
import com.simprints.infra.orchestration.data.responses.AppVerifyResponse
Expand All @@ -53,6 +59,7 @@ class ClientApiViewModel @Inject internal constructor(
private val configManager: ConfigManager,
private val timeHelper: TimeHelper,
private val persistentLogger: PersistentLogger,
private val tokenizationProcessor: TokenizationProcessor,
) : ViewModel() {
val returnResponse: LiveData<LiveDataEventWithContent<Bundle>>
get() = _returnResponse
Expand Down Expand Up @@ -115,6 +122,7 @@ class ClientApiViewModel @Inject internal constructor(
sessionId = currentSessionId,
enrolledGuid = enrolResponse.guid,
subjectActions = coSyncEnrolmentRecords,
externalCredential = enrolResponse.externalCredential?.toAppExternalCredential(tokenizationProcessor, getProject()),
),
),
)
Expand All @@ -139,6 +147,7 @@ class ClientApiViewModel @Inject internal constructor(
actionIdentifier = action.actionIdentifier,
sessionId = currentSessionId,
identifications = identifyResponse.identifications,
isMultiFactorIdEnabled = identifyResponse.isMultiFactorIdEnabled,
),
),
)
Expand All @@ -161,6 +170,7 @@ class ClientApiViewModel @Inject internal constructor(
actionIdentifier = action.actionIdentifier,
sessionId = currentSessionId,
confirmed = confirmResponse.identificationOutcome,
externalCredential = confirmResponse.externalCredential?.toAppExternalCredential(tokenizationProcessor, getProject()),
),
),
)
Expand Down Expand Up @@ -262,4 +272,21 @@ class ClientApiViewModel @Inject internal constructor(
body = "${action.actionIdentifier}\n$response",
)
}

private fun ExternalCredential.toAppExternalCredential(
tokenizationProcessor: TokenizationProcessor,
project: Project?,
): AppExternalCredential? {
if (project == null) return null
val decryptedValue = tokenizationProcessor.decrypt(
encrypted = value,
tokenKeyType = TokenKeyType.ExternalCredential,
project = project,
) as? TokenizableString.Raw ?: return null
return AppExternalCredential(
id = id,
value = decryptedValue,
type = type,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.core.os.bundleOf
import com.simprints.core.DeviceID
import com.simprints.core.PackageVersionName
import com.simprints.core.domain.response.AppErrorReason
import com.simprints.infra.events.event.domain.models.scope.Device
import com.simprints.infra.orchestration.data.ActionResponse
import com.simprints.infra.orchestration.data.responses.AppExternalCredential
import com.simprints.libsimprints.Constants
import com.simprints.libsimprints.contracts.VersionsList
import com.simprints.libsimprints.contracts.data.ConfidenceBand
Expand All @@ -15,6 +15,8 @@ import com.simprints.libsimprints.contracts.data.Identification
import com.simprints.libsimprints.contracts.data.Identification.Companion.toJson
import com.simprints.libsimprints.contracts.data.RefusalForm
import com.simprints.libsimprints.contracts.data.Verification
import org.json.JSONArray
import org.json.JSONObject
import javax.inject.Inject
import com.simprints.libsimprints.Identification as LegacyIdentification
import com.simprints.libsimprints.RefusalForm as LegacyRefusalForm
Expand All @@ -32,6 +34,7 @@ internal class LibSimprintsResponseMapper @Inject constructor(
Constants.SIMPRINTS_DEVICE_ID to deviceId,
Constants.SIMPRINTS_APP_VERSION_NAME to appVersionName,
Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK to true,
HAS_CREDENTIAL to (response.externalCredential != null),
).appendDataPerContractVersion(response) { version ->
when {
version < VersionsList.INITIAL_REWORK -> putParcelable(
Expand All @@ -42,6 +45,7 @@ internal class LibSimprintsResponseMapper @Inject constructor(
else -> putString(Constants.SIMPRINTS_ENROLMENT, Enrolment(response.enrolledGuid).toJson())
}
}.appendCoSyncData(response.subjectActions)
.appendExternalCredential(response.externalCredential)

is ActionResponse.IdentifyActionResponse -> bundleOf(
Constants.SIMPRINTS_SESSION_ID to response.sessionId,
Expand All @@ -50,6 +54,11 @@ internal class LibSimprintsResponseMapper @Inject constructor(
Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK to true,
).appendDataPerContractVersion(response) { version ->
when {
response.isMultiFactorIdEnabled -> putString(
Constants.SIMPRINTS_IDENTIFICATIONS,
response.mapIdentificationsWithCredentials(),
)

version < VersionsList.INITIAL_REWORK -> putParcelableArrayList(
Constants.SIMPRINTS_IDENTIFICATIONS,
response.identifications
Expand All @@ -66,12 +75,15 @@ internal class LibSimprintsResponseMapper @Inject constructor(
}
}

is ActionResponse.ConfirmActionResponse -> bundleOf(
Constants.SIMPRINTS_SESSION_ID to response.sessionId,
Constants.SIMPRINTS_DEVICE_ID to deviceId,
Constants.SIMPRINTS_APP_VERSION_NAME to appVersionName,
Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK to true,
)
is ActionResponse.ConfirmActionResponse -> {
bundleOf(
Constants.SIMPRINTS_SESSION_ID to response.sessionId,
Constants.SIMPRINTS_DEVICE_ID to deviceId,
Constants.SIMPRINTS_APP_VERSION_NAME to appVersionName,
Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK to true,
HAS_CREDENTIAL to (response.externalCredential != null),
).appendExternalCredential(response.externalCredential)
}

is ActionResponse.VerifyActionResponse -> bundleOf(
Constants.SIMPRINTS_SESSION_ID to response.sessionId,
Expand Down Expand Up @@ -146,6 +158,33 @@ internal class LibSimprintsResponseMapper @Inject constructor(
actions?.let { putString(Constants.SIMPRINTS_COSYNC_SUBJECT_ACTIONS, it) }
}

private fun Bundle.appendExternalCredential(credential: AppExternalCredential?) = apply {
if (credential != null) {
val credentialJson =
JSONObject()
.also {
it.put(SCANNED_CREDENTIAL_VALUE, credential.value)
it.put(SCANNED_CREDENTIAL_TYPE, credential.type)
}.toString()
putString(SCANNED_CREDENTIAL, credentialJson)
}
}

private fun ActionResponse.IdentifyActionResponse.mapIdentificationsWithCredentials(): String = identifications
.map { identification ->
JSONObject()
.also { json ->
json.put(KEY_GUID, identification.guid)
json.put(KEY_CONFIDENCE_BAND, identification.matchConfidence.name)
json.put(KEY_CONFIDENCE, identification.confidenceScore.toFloat())
json.put(KEY_IS_LINKED_TO_CREDENTIAL, identification.isLinkedToScannedCredential ?: false)
identification.isCredentialVerified?.let {
json.put(KEY_IS_CREDENTIAL_VERIFIED, it)
}
}
}.run(::JSONArray)
.toString()

private fun AppErrorReason.libSimprintsResultCode() = when (this) {
AppErrorReason.UNEXPECTED_ERROR -> Constants.SIMPRINTS_UNEXPECTED_ERROR
AppErrorReason.ROOTED_DEVICE -> Constants.SIMPRINTS_ROOTED_DEVICE
Expand Down Expand Up @@ -182,5 +221,16 @@ internal class LibSimprintsResponseMapper @Inject constructor(

companion object {
internal const val RESULT_CODE_OVERRIDE = "result_code_override"
internal const val HAS_CREDENTIAL = "hasCredential"
internal const val SCANNED_CREDENTIAL = "scannedCredential"
internal const val SCANNED_CREDENTIAL_VALUE = "value"
internal const val SCANNED_CREDENTIAL_TYPE = "type"

// TODO [MS-1190] Move implementation to LibSimprints. These constats are copies of com.simprints.libsimprints.contracts.data.Identification
private const val KEY_GUID = "guid"
private const val KEY_CONFIDENCE = "confidence"
private const val KEY_CONFIDENCE_BAND = "confidenceBand"
private const val KEY_IS_LINKED_TO_CREDENTIAL = "isLinkedToCredential"
private const val KEY_IS_CREDENTIAL_VERIFIED = "isVerified"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ internal class GetEnrolmentCreationEventForSubjectUseCase @Inject constructor(
?.fromSubjectToEnrolmentCreationEvent()

if (recordCreationEvent == null) {
Simber.e("Couldn't find enrolment for subjectActions", IllegalStateException("No enrolment record found for subjectId: $subjectId"))
Simber.e(
"Couldn't find enrolment for subjectActions",
IllegalStateException("No enrolment record found for subjectId: $subjectId"),
)
return null
}

return jsonHelper.toJson(CoSyncEnrolmentRecordEvents(listOf(recordCreationEvent)), coSyncSerializationModule)
}

private fun Subject.fromSubjectToEnrolmentCreationEvent() = EnrolmentRecordCreationEvent(
subjectId,
projectId,
moduleId,
attendantId,
EnrolmentRecordCreationEvent.buildBiometricReferences(fingerprintSamples, faceSamples, encoder),
subjectId = subjectId,
projectId = projectId,
moduleId = moduleId,
attendantId = attendantId,
biometricReferences = EnrolmentRecordCreationEvent.buildBiometricReferences(fingerprintSamples, faceSamples, encoder),
externalCredentials = externalCredentials,
)

companion object {
Expand Down
Loading