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

[Onboarding] Create new Onboarding NIM backend #16832

Closed
caybro opened this issue Nov 28, 2024 · 6 comments · Fixed by #17003
Closed

[Onboarding] Create new Onboarding NIM backend #16832

caybro opened this issue Nov 28, 2024 · 6 comments · Fixed by #17003

Comments

@caybro
Copy link
Member

caybro commented Nov 28, 2024

Description

For the new onboarding redesign/rework (#16712), there is a need for a new matching backend.

Currently, the QML UI uses a mocked backend, modeled after existing StartupStore and PrivacyStore:

startupStore: StartupStore {
    readonly property var currentStartupState: QtObject {
        property string stateType: keycardMock.stateType  // Constants.startupState.keycardXXX
    }
    function getPasswordStrengthScore(password) {
        logs.logEvent("StartupStore.getPasswordStrengthScore", ["password"], arguments)
        return Math.min(password.length-1, 4)
    }
    function validMnemonic(mnemonic) {
        logs.logEvent("StartupStore.validMnemonic", ["mnemonic"], arguments)
        return mnemonic === keycardMock.mnemonic
    }
    function getPin() {
        logs.logEvent("StartupStore.getPin()")
        return ctrlPin.text
    }
    function getSeedPhrase() {
        logs.logEvent("StartupStore.getSeedPhrase()")
        // FIXME needed? cf getMnemonic()
    }
    function validateLocalPairingConnectionString(connectionString) {
        logs.logEvent("StartupStore.validateLocalPairingConnectionString", ["connectionString"], arguments)
        return !Number.isNaN(parseInt(connectionString))
    }
    function setConnectionString(connectionString) {
        logs.logEvent("StartupStore.setConnectionString", ["connectionString"], arguments)
    }
    readonly property var startupModuleInst: QtObject {
        property int remainingAttempts: 5
    }
}

privacyStore: PrivacyStore {
    readonly property var words: ["apple", "banana", "cat", "cow", "catalog", "catch", "category", "cattle", "dog", "elephant", "fish", "grape"]
    function getMnemonic() {
        logs.logEvent("PrivacyStore.getMnemonic()")
        return words.join(" ")
    }
    function mnemonicWasShown() {
        console.warn("!!! MNEMONIC SHOWN")
        logs.logEvent("PrivacyStore.mnemonicWasShown()")
    }
    function removeMnemonic() {
        console.warn("!!! REMOVE MNEMONIC")
        logs.logEvent("PrivacyStore.removeMnemonic()")
    }
}

QtObject {
    id: keycardMock
    property string stateType: ctrlKeycardState.currentValue
    readonly property var keycardStates: [
        // initial
        Constants.startupState.keycardNoPCSCService,
        Constants.startupState.keycardPluginReader,
        Constants.startupState.keycardInsertKeycard,
        Constants.startupState.keycardInsertedKeycard,
        Constants.startupState.keycardReadingKeycard,
        Constants.startupState.keycardRecognizedKeycard,
        // initial errors
        Constants.startupState.keycardWrongKeycard,
        Constants.startupState.keycardNotKeycard,
        Constants.startupState.keycardMaxPairingSlotsReached,
        Constants.startupState.keycardLocked,
        // exit states
        Constants.startupState.keycardNotEmpty,
        Constants.startupState.keycardEmpty
    ]
    readonly property string mnemonic: "dog dog dog dog dog dog dog dog dog dog dog dog"
}

This gives us an idea of the functions that need to be implemented. Ideally, these would live in a new store (e.g. OnboardingStore) which would encapsulate the new backend.

Acceptance Criteria

  • the new backend fullfills the needs of the UI
  • the backend is integrated into the app
  • the old backend is (partially?) removed from the app
@caybro
Copy link
Member Author

caybro commented Nov 28, 2024

@jrainville
Copy link
Member

@caybro would the new backend need to handle the navigation like the old one or it's all handled by the front-end now?

@caybro
Copy link
Member Author

caybro commented Nov 28, 2024

@caybro would the new backend need to handle the navigation like the old one or it's all handled by the front-end now?

Completely handled by the frontend stack now (navigation, sequence, transitions from page to page, etc).

My further thoughts: I could start sketching the proposed new OnboardingStore. This would continue to be the engine for Storybook now and at the same time this would give us the "contract" upon which we can actually implement the new backend

@jrainville
Copy link
Member

@igor-sirotin and I checked this issue real quick and realized that there are missing functions in the mock, like login, createAccount, etc.

Is this because the UI changes are still WIP? @caybro

@caybro
Copy link
Member Author

caybro commented Nov 28, 2024

@igor-sirotin and I checked this issue real quick and realized that there are missing functions in the mock, like login, createAccount, etc.

Is this because the UI changes are still WIP? @caybro

"Login" in the sense of logging in with an already created account is not handled here in the onboarding (cf "Login" in these onboarding flows rather refers to "restoring an account"). See the "Log in with an existing profile" section in the Figma here: https://www.figma.com/design/Lw4nPYQcZOPOwTgETiiIYo/Desktop-Onboarding-Redesign?node-id=788-34574&node-type=instance&m=dev That would be for another epic/issue I guess

For actually processing the data collected throughout the onboarding flows, I'm not calling any backend action. When any of the onboarding flows is finished, it merely emits this signal:

signal finished(int primaryPath, int secondaryPath, var data)

where data contains the info collected, e.g.:

data: {"password":"0123456789","keycardPin":"","enableBiometrics":true,"syncConnectionString":""}

for a "Create Profile" -> "Password" flow

@caybro
Copy link
Member Author

caybro commented Dec 10, 2024

Proposed OnboardingStore (WIP):

https://github.com/status-im/status-desktop/pull/16722/files#diff-331eefd37a07f8b6dde6173672c965dd7aa5e72fdefd54d17a2c46ffc677587b

QtObject {
    readonly property QtObject d: StatusQUtils.QObject {
        id: d
        readonly property var onboardingModuleInst: onboardingModule
    }

    // keycard
    readonly property int keycardState: d.onboardingModuleInst.keycardState // cf. enum Onboarding.KeycardState
    readonly property int keycardRemainingPinAttempts: d.onboardingModuleInst.keycardRemainingPinAttempts

    function setPin(pin: string) { // -> bool
        return d.onboardingModuleInst.setPin(pin)
    }

    readonly property int addKeyPairState: d.onboardingModuleInst.addKeyPairState // cf. enum Onboarding.AddKeyPairState
    function startKeypairTransfer() { // -> void
        d.onboardingModuleInst.startKeypairTransfer()
    }

    // password
    function getPasswordStrengthScore(password: string) { // -> int
        return d.onboardingModuleInst.getPasswordStrengthScore(password)
    }

    // seedphrase/mnemonic
    function validMnemonic(mnemonic: string) { // -> bool
        return d.onboardingModuleInst.validMnemonic(mnemonic)
    }
    function getMnemonic() { // -> string
        return d.onboardingModuleInst.mnemonic()
    }
    function mnemonicWasShown() { // -> void
        d.onboardingModuleInst.mnemonicWasShown()
    }
    function removeMnemonic() { // -> void
        d.onboardingModuleInst.removeMnemonic()
    }

    // sync
    readonly property int syncState: d.onboardingModuleInst.syncState // cf. enum Onboarding.SyncState
    function validateLocalPairingConnectionString(connectionString: string) { // -> bool
        return d.onboardingModuleInst.validateLocalPairingConnectionString(connectionString)
    }
    function inputConnectionStringForBootstrapping(connectionString: string) { // -> void
        d.onboardingModuleInst.inputConnectionStringForBootstrapping(connectionString)
    }
}

@igor-sirotin igor-sirotin moved this from Next to In Progress in Status Desktop/Mobile Board Dec 12, 2024
jrainville added a commit that referenced this issue Dec 18, 2024
Part of #16832

Adds the basic files needed for the new onboarding, aka onboarding V2.
It does not do anything yet, but it's ready to be implemented.

It is locked behind a feature flag.
To enable it,  run the app with `export FLAG_ONBOARDING_V2_ENABLED=1`
jrainville added a commit that referenced this issue Dec 18, 2024
Part of #16832

Adds the basic files needed for the new onboarding, aka onboarding V2.
It does not do anything yet, but it's ready to be implemented.

It is locked behind a feature flag.
To enable it,  run the app with `export FLAG_ONBOARDING_V2_ENABLED=1`
jrainville added a commit that referenced this issue Dec 19, 2024
Part of #16832

Adds the basic files needed for the new onboarding, aka onboarding V2.
It does not do anything yet, but it's ready to be implemented.

It is locked behind a feature flag.
To enable it,  run the app with `export FLAG_ONBOARDING_V2_ENABLED=1`
jrainville added a commit that referenced this issue Dec 19, 2024
Part of #16832

Adds the basic files needed for the new onboarding, aka onboarding V2.
It does not do anything yet, but it's ready to be implemented.

It is locked behind a feature flag.
To enable it,  run the app with `export FLAG_ONBOARDING_V2_ENABLED=1`
jrainville added a commit that referenced this issue Dec 19, 2024
Part of #16832

Adds the basic files needed for the new onboarding, aka onboarding V2.
It does not do anything yet, but it's ready to be implemented.

It is locked behind a feature flag.
To enable it,  run the app with `export FLAG_ONBOARDING_V2_ENABLED=1`
jrainville added a commit that referenced this issue Dec 20, 2024
Fixes #16832

Implements all the needed basic Nim functions for the new onboarding.

They do no do anything just yet. They shall be integrated in another commit.
@jrainville jrainville moved this from In Progress to Code Review in Status Desktop/Mobile Board Dec 20, 2024
@jrainville jrainville changed the title [Onboarding UI] Create new Onboarding NIM backend [Onboarding] Create new Onboarding NIM backend Dec 20, 2024
jrainville added a commit that referenced this issue Jan 6, 2025
Fixes #16832

Implements all the needed basic Nim functions for the new onboarding.

They do no do anything just yet. They shall be integrated in another commit.
@github-project-automation github-project-automation bot moved this from Code Review to Done in Status Desktop/Mobile Board Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment