Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last session recovery #2421

Merged
merged 25 commits into from
Feb 22, 2024
Merged

Last session recovery #2421

merged 25 commits into from
Feb 22, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Feb 20, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Add a way to let the user enter a recovery key when there is no other sessions available.

Also update the UI flow, when clicking on the verification banner : either directly open the verification screens (instead of opening the settings), or directly open the "enter recovery key" screen (instead of opening the verification screens, which is non-sense since there are no other sessions).

  • This PR also fixes an issue were the various states regarding crypto was not updated (b09294c)
  • and the isLastDevice is now a StateFlow, to help having more dynamic UI.
  • Finally the flag FeatureFlags.SecureStorage is removed.

Motivation and context

Closes #2400

Screenshots / GIFs

RecoveryKey_OneSession

Tests

  • Log an account in, with no other session available.
  • The banner display the special case to enter a recovery key.
  • If there are other sessions, the banner will be the classical verify session banner

When verifying a session, it's also possible to choose to enter a recovery key instead.

See the recorded screenshot for more details.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

Copy link
Contributor

github-actions bot commented Feb 20, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/XHDzt7

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (develop@69776f9). Click here to learn what that means.
Report is 2 commits behind head on develop.

Files Patch % Lines
...securebackup/impl/DefaultSecureBackupEntryPoint.kt 0.00% 5 Missing ⚠️
...rifysession/impl/DefaultVerifySessionEntryPoint.kt 0.00% 5 Missing ⚠️
...atures/verifysession/impl/VerifySelfSessionView.kt 80.95% 0 Missing and 4 partials ⚠️
...eatures/securebackup/api/SecureBackupEntryPoint.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #2421   +/-   ##
==========================================
  Coverage           ?   72.44%           
==========================================
  Files              ?     1357           
  Lines              ?    32261           
  Branches           ?     6259           
==========================================
  Hits               ?    23373           
  Misses             ?     5658           
  Partials           ?     3230           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a new issue but the word Enter... on this screenshot looks off

@bmarty bmarty changed the title Feature/bma/last session recovery Last session recovery Feb 21, 2024
@bmarty bmarty force-pushed the feature/bma/lastSessionRecovery branch from 2cfa5a5 to 0642820 Compare February 21, 2024 13:40
bmarty and others added 24 commits February 21, 2024 18:25
Also get the sessionVerificationService from the matrixClient, instead of injecting it separately.
…lue change.

The session can become verified when the user enters their recovery key, and in this case the callback `didFinish` is not invoked.
@bmarty bmarty force-pushed the feature/bma/lastSessionRecovery branch from db09349 to d3d76dd Compare February 21, 2024 17:34
@bmarty bmarty marked this pull request as ready for review February 21, 2024 17:37
@bmarty bmarty requested a review from a team as a code owner February 21, 2024 17:37
@bmarty bmarty requested review from ganfra and removed request for a team February 21, 2024 17:37
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 remarks, otherwise LGTM

@Composable
override fun View(modifier: Modifier) {
val state = presenter.present()
VerifySelfSessionView(
state = state,
modifier = modifier,
onEnterRecoveryKey = { onEnterRecoveryKey() },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use method reference here?

fun start() {
service.backupStateListener(object : BackupStateListener {
backupStateListenerTaskHandle = service.backupStateListener(object : BackupStateListener {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use mxCallbackFlow instead, so we can remove this start function. Maybe create extension methods on Encryption so you can reuse them.

private val backupStateFlow = mxCallbackFlow {
        val listener = object : BackupStateListener {
            override fun onUpdate(status: RustBackupState) {
                trySend(backupStateMapper.map(status))
            }
        }
        service.backupStateListener(listener)
    }.stateIn(sessionCoroutineScope, SharingStarted.Eagerly, service.backupState().let(backupStateMapper::map))
 private val recoveryStateFlow = mxCallbackFlow {
        val listener = object : RecoveryStateListener {
            override fun onUpdate(status: org.matrix.rustcomponents.sdk.RecoveryState) {
                trySend(recoveryStateMapper.map(status))
            }
        }
        service.recoveryStateListener(listener)
    }.stateIn(sessionCoroutineScope, SharingStarted.Eagerly, service.recoveryState().let(recoveryStateMapper::map))

@bmarty
Copy link
Member Author

bmarty commented Feb 22, 2024

@ganfra thanks for your review. I'll handle your remarks in a dedicated PR. I also want to add some Maestro test which will enter recovery key.

@bmarty bmarty merged commit f68087b into develop Feb 22, 2024
15 checks passed
@bmarty bmarty deleted the feature/bma/lastSessionRecovery branch February 22, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Verify with recovery key
3 participants