chore(@desktop/keycard): state commands improvement

Previously we had only a single command which may be triggered for any state and
it was triggered before the state was set as an active state. Now we are able to set
custom command which may be triggered either before or after the state is set.

Changes:
- old `executeBackCommand` is now `executePreBackStateCommand`
- old `executePrimaryCommand` is now `executePrePrimaryStateCommand`
- old `executeSecondaryCommand` is now `executePreSecondaryStateCommand`
- old `executeTertiaryCommand` is now `executePreTertiaryStateCommand`
- added `executePostBackStateCommand` command
- added `executePostPrimaryStateCommand` command
- added `executePostSecondaryStateCommand` command
- added `executePostTertiaryStateCommand` command
This commit is contained in:
Sale Djenic 2022-11-10 09:24:59 +01:00 committed by saledjenic
parent 78fda35807
commit 21eeefa42e
63 changed files with 145 additions and 125 deletions

View File

@ -8,7 +8,7 @@ proc newBiometricsPasswordFailedState*(flowType: FlowType, backState: State): Bi
proc delete*(self: BiometricsPasswordFailedState) = proc delete*(self: BiometricsPasswordFailedState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: BiometricsPasswordFailedState, controller: Controller) = method executePrePrimaryStateCommand*(self: BiometricsPasswordFailedState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
@ -16,7 +16,7 @@ method getNextSecondaryState*(self: BiometricsPasswordFailedState, controller: C
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
return createState(StateType.EnterPassword, self.flowType, nil) return createState(StateType.EnterPassword, self.flowType, nil)
method executeTertiaryCommand*(self: BiometricsPasswordFailedState, controller: Controller) = method executePreTertiaryStateCommand*(self: BiometricsPasswordFailedState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,11 +8,11 @@ proc newBiometricsPinFailedState*(flowType: FlowType, backState: State): Biometr
proc delete*(self: BiometricsPinFailedState) = proc delete*(self: BiometricsPinFailedState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: BiometricsPinFailedState, controller: Controller) = method executePrePrimaryStateCommand*(self: BiometricsPinFailedState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeSecondaryCommand*(self: BiometricsPinFailedState, controller: Controller) = method executePreSecondaryStateCommand*(self: BiometricsPinFailedState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setUsePinFromBiometrics(true) controller.setUsePinFromBiometrics(true)
@ -20,7 +20,7 @@ method getNextSecondaryState*(self: BiometricsPinFailedState, controller: Contro
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
return createState(StateType.EnterPin, self.flowType, nil) return createState(StateType.EnterPin, self.flowType, nil)
method executeTertiaryCommand*(self: BiometricsPinFailedState, controller: Controller) = method executePreTertiaryStateCommand*(self: BiometricsPinFailedState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.setPin("") controller.setPin("")

View File

@ -8,11 +8,11 @@ proc newBiometricsPinInvalidState*(flowType: FlowType, backState: State): Biomet
proc delete*(self: BiometricsPinInvalidState) = proc delete*(self: BiometricsPinInvalidState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: BiometricsPinInvalidState, controller: Controller) = method executePrePrimaryStateCommand*(self: BiometricsPinInvalidState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeSecondaryCommand*(self: BiometricsPinInvalidState, controller: Controller) = method executePreSecondaryStateCommand*(self: BiometricsPinInvalidState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setUsePinFromBiometrics(true) controller.setUsePinFromBiometrics(true)
controller.setOfferToStoreUpdatedPinToKeychain(true) controller.setOfferToStoreUpdatedPinToKeychain(true)
@ -21,7 +21,7 @@ method getNextSecondaryState*(self: BiometricsPinInvalidState, controller: Contr
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
return createState(StateType.EnterPin, self.flowType, nil) return createState(StateType.EnterPin, self.flowType, nil)
method executeTertiaryCommand*(self: BiometricsPinInvalidState, controller: Controller) = method executePreTertiaryStateCommand*(self: BiometricsPinInvalidState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.setPin("") controller.setPin("")

View File

@ -8,11 +8,11 @@ proc newBiometricsReadyToSignState*(flowType: FlowType, backState: State): Biome
proc delete*(self: BiometricsReadyToSignState) = proc delete*(self: BiometricsReadyToSignState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: BiometricsReadyToSignState, controller: Controller) = method executePrePrimaryStateCommand*(self: BiometricsReadyToSignState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeSecondaryCommand*(self: BiometricsReadyToSignState, controller: Controller) = method executePreSecondaryStateCommand*(self: BiometricsReadyToSignState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setUsePinFromBiometrics(true) controller.setUsePinFromBiometrics(true)
@ -20,7 +20,7 @@ method getNextSecondaryState*(self: BiometricsReadyToSignState, controller: Cont
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
return createState(StateType.EnterPin, self.flowType, nil) return createState(StateType.EnterPin, self.flowType, nil)
method executeTertiaryCommand*(self: BiometricsReadyToSignState, controller: Controller) = method executePreTertiaryStateCommand*(self: BiometricsReadyToSignState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.setPin("") controller.setPin("")

View File

@ -8,7 +8,7 @@ proc newChangingKeycardPairingCodeState*(flowType: FlowType, backState: State):
proc delete*(self: ChangingKeycardPairingCodeState) = proc delete*(self: ChangingKeycardPairingCodeState) =
self.State.delete self.State.delete
method executeSecondaryCommand*(self: ChangingKeycardPairingCodeState, controller: Controller) = method executePreSecondaryStateCommand*(self: ChangingKeycardPairingCodeState, controller: Controller) =
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
controller.storePairingCodeToKeycard(controller.getPairingCode()) controller.storePairingCodeToKeycard(controller.getPairingCode())

View File

@ -8,7 +8,7 @@ proc newChangingKeycardPinState*(flowType: FlowType, backState: State): Changing
proc delete*(self: ChangingKeycardPinState) = proc delete*(self: ChangingKeycardPinState) =
self.State.delete self.State.delete
method executeSecondaryCommand*(self: ChangingKeycardPinState, controller: Controller) = method executePreSecondaryStateCommand*(self: ChangingKeycardPinState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPin: if self.flowType == FlowType.ChangeKeycardPin:
controller.storePinToKeycard(controller.getPin(), "") controller.storePinToKeycard(controller.getPin(), "")

View File

@ -8,7 +8,7 @@ proc newChangingKeycardPukState*(flowType: FlowType, backState: State): Changing
proc delete*(self: ChangingKeycardPukState) = proc delete*(self: ChangingKeycardPukState) =
self.State.delete self.State.delete
method executeSecondaryCommand*(self: ChangingKeycardPukState, controller: Controller) = method executePreSecondaryStateCommand*(self: ChangingKeycardPukState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.storePukToKeycard(controller.getPuk()) controller.storePukToKeycard(controller.getPuk())

View File

@ -14,6 +14,6 @@ method getNextPrimaryState*(self: CreatePairingCodeState, controller: Controller
return createState(StateType.ChangingKeycardPairingCode, self.flowType, nil) return createState(StateType.ChangingKeycardPairingCode, self.flowType, nil)
return createState(StateType.ChangingKeycardPairingCodeFailure, self.flowType, nil) return createState(StateType.ChangingKeycardPairingCodeFailure, self.flowType, nil)
method executeTertiaryCommand*(self: CreatePairingCodeState, controller: Controller) = method executePreTertiaryStateCommand*(self: CreatePairingCodeState, controller: Controller) =
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,14 +8,14 @@ proc newCreatePinState*(flowType: FlowType, backState: State): CreatePinState =
proc delete*(self: CreatePinState) = proc delete*(self: CreatePinState) =
self.State.delete self.State.delete
method executeBackCommand*(self: CreatePinState, controller: Controller) = method executePreBackStateCommand*(self: CreatePinState, controller: Controller) =
controller.setPin("") controller.setPin("")
controller.setPinMatch(false) controller.setPinMatch(false)
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair: if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
controller.cancelCurrentFlow() controller.cancelCurrentFlow()
method executeTertiaryCommand*(self: CreatePinState, controller: Controller) = method executePreTertiaryStateCommand*(self: CreatePinState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard or if self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.UnlockKeycard or self.flowType == FlowType.UnlockKeycard or
self.flowType == FlowType.ChangeKeycardPin: self.flowType == FlowType.ChangeKeycardPin:

View File

@ -8,7 +8,7 @@ proc newCreatePukState*(flowType: FlowType, backState: State): CreatePukState =
proc delete*(self: CreatePukState) = proc delete*(self: CreatePukState) =
self.State.delete self.State.delete
method executeTertiaryCommand*(self: CreatePukState, controller: Controller) = method executePreTertiaryStateCommand*(self: CreatePukState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -10,7 +10,7 @@ proc newEnterBiometricsPasswordState*(flowType: FlowType, backState: State): Ent
proc delete*(self: EnterBiometricsPasswordState) = proc delete*(self: EnterBiometricsPasswordState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: EnterBiometricsPasswordState, controller: Controller) = method executePrePrimaryStateCommand*(self: EnterBiometricsPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
let password = controller.getPassword() let password = controller.getPassword()
self.success = controller.verifyPassword(password) self.success = controller.verifyPassword(password)
@ -25,7 +25,7 @@ method getNextPrimaryState*(self: EnterBiometricsPasswordState, controller: Cont
if not self.success: if not self.success:
return createState(StateType.WrongBiometricsPassword, self.flowType, nil) return createState(StateType.WrongBiometricsPassword, self.flowType, nil)
method executeTertiaryCommand*(self: EnterBiometricsPasswordState, controller: Controller) = method executePreTertiaryStateCommand*(self: EnterBiometricsPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -14,7 +14,7 @@ method getNextPrimaryState*(self: EnterKeycardNameState, controller: Controller)
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
return createState(StateType.RenamingKeycard, self.flowType, nil) return createState(StateType.RenamingKeycard, self.flowType, nil)
method executeTertiaryCommand*(self: EnterKeycardNameState, controller: Controller) = method executePreTertiaryStateCommand*(self: EnterKeycardNameState, controller: Controller) =
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
controller.setPassword("") controller.setPassword("")
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -10,7 +10,7 @@ proc newEnterPasswordState*(flowType: FlowType, backState: State): EnterPassword
proc delete*(self: EnterPasswordState) = proc delete*(self: EnterPasswordState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: EnterPasswordState, controller: Controller) = method executePrePrimaryStateCommand*(self: EnterPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
let password = controller.getPassword() let password = controller.getPassword()
self.success = controller.verifyPassword(password) self.success = controller.verifyPassword(password)
@ -24,11 +24,11 @@ method getNextPrimaryState*(self: EnterPasswordState, controller: Controller): S
if not self.success: if not self.success:
return createState(StateType.WrongPassword, self.flowType, nil) return createState(StateType.WrongPassword, self.flowType, nil)
method executeSecondaryCommand*(self: EnterPasswordState, controller: Controller) = method executePreSecondaryStateCommand*(self: EnterPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeTertiaryCommand*(self: EnterPasswordState, controller: Controller) = method executePreTertiaryStateCommand*(self: EnterPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -16,7 +16,7 @@ method getNextPrimaryState*(self: EnterPinState, controller: Controller): State
if controller.getPin().len == PINLengthForStatusApp: if controller.getPin().len == PINLengthForStatusApp:
controller.enterKeycardPin(controller.getPin()) controller.enterKeycardPin(controller.getPin())
method executeSecondaryCommand*(self: EnterPinState, controller: Controller) = method executePreSecondaryStateCommand*(self: EnterPinState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard or if self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.FactoryReset or self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.DisplayKeycardContent or self.flowType == FlowType.DisplayKeycardContent or
@ -30,7 +30,7 @@ method executeSecondaryCommand*(self: EnterPinState, controller: Controller) =
controller.setUsePinFromBiometrics(false) controller.setUsePinFromBiometrics(false)
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeTertiaryCommand*(self: EnterPinState, controller: Controller) = method executePreTertiaryStateCommand*(self: EnterPinState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -8,12 +8,12 @@ proc newEnterPukState*(flowType: FlowType, backState: State): EnterPukState =
proc delete*(self: EnterPukState) = proc delete*(self: EnterPukState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: EnterPukState, controller: Controller) = method executePrePrimaryStateCommand*(self: EnterPukState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
if controller.getPuk().len == PUKLengthForStatusApp: if controller.getPuk().len == PUKLengthForStatusApp:
controller.enterKeycardPuk(controller.getPuk()) controller.enterKeycardPuk(controller.getPuk())
method executeTertiaryCommand*(self: EnterPukState, controller: Controller) = method executePreTertiaryStateCommand*(self: EnterPukState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -10,7 +10,7 @@ proc newEnterSeedPhraseState*(flowType: FlowType, backState: State): EnterSeedPh
proc delete*(self: EnterSeedPhraseState) = proc delete*(self: EnterSeedPhraseState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: EnterSeedPhraseState, controller: Controller) = method executePrePrimaryStateCommand*(self: EnterSeedPhraseState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
self.verifiedSeedPhrase = controller.validSeedPhrase(controller.getSeedPhrase()) and self.verifiedSeedPhrase = controller.validSeedPhrase(controller.getSeedPhrase()) and
controller.seedPhraseRefersToSelectedKeyPair(controller.getSeedPhrase()) controller.seedPhraseRefersToSelectedKeyPair(controller.getSeedPhrase())
@ -32,7 +32,7 @@ method getNextPrimaryState*(self: EnterSeedPhraseState, controller: Controller):
if not self.verifiedSeedPhrase: if not self.verifiedSeedPhrase:
return createState(StateType.WrongSeedPhrase, self.flowType, nil) return createState(StateType.WrongSeedPhrase, self.flowType, nil)
method executeTertiaryCommand*(self: EnterSeedPhraseState, controller: Controller) = method executePreTertiaryStateCommand*(self: EnterSeedPhraseState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard or if self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.UnlockKeycard: self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,14 +8,14 @@ proc newFactoryResetConfirmationDisplayMetadataState*(flowType: FlowType, backSt
proc delete*(self: FactoryResetConfirmationDisplayMetadataState) = proc delete*(self: FactoryResetConfirmationDisplayMetadataState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) = method executePrePrimaryStateCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) =
if self.flowType == FlowType.FactoryReset: if self.flowType == FlowType.FactoryReset:
controller.runGetAppInfoFlow(factoryReset = true) controller.runGetAppInfoFlow(factoryReset = true)
elif self.flowType == FlowType.SetupNewKeycard: elif self.flowType == FlowType.SetupNewKeycard:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
controller.runGetAppInfoFlow(factoryReset = true) controller.runGetAppInfoFlow(factoryReset = true)
method executeTertiaryCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) = method executePreTertiaryStateCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard: self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,14 +8,14 @@ proc newFactoryResetConfirmationState*(flowType: FlowType, backState: State): Fa
proc delete*(self: FactoryResetConfirmationState) = proc delete*(self: FactoryResetConfirmationState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: FactoryResetConfirmationState, controller: Controller) = method executePrePrimaryStateCommand*(self: FactoryResetConfirmationState, controller: Controller) =
if self.flowType == FlowType.FactoryReset: if self.flowType == FlowType.FactoryReset:
controller.runGetAppInfoFlow(factoryReset = true) controller.runGetAppInfoFlow(factoryReset = true)
elif self.flowType == FlowType.SetupNewKeycard: elif self.flowType == FlowType.SetupNewKeycard:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
controller.runGetAppInfoFlow(factoryReset = true) controller.runGetAppInfoFlow(factoryReset = true)
method executeTertiaryCommand*(self: FactoryResetConfirmationState, controller: Controller) = method executePreTertiaryStateCommand*(self: FactoryResetConfirmationState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard: self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,13 +8,13 @@ proc newFactoryResetSuccessState*(flowType: FlowType, backState: State): Factory
proc delete*(self: FactoryResetSuccessState) = proc delete*(self: FactoryResetSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: FactoryResetSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: FactoryResetSuccessState, controller: Controller) =
if self.flowType == FlowType.FactoryReset: if self.flowType == FlowType.FactoryReset:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
elif self.flowType == FlowType.SetupNewKeycard: elif self.flowType == FlowType.SetupNewKeycard:
controller.runLoadAccountFlow() controller.runLoadAccountFlow()
method executeTertiaryCommand*(self: FactoryResetSuccessState, controller: Controller) = method executePreTertiaryStateCommand*(self: FactoryResetSuccessState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,12 +8,12 @@ proc newInsertKeycardState*(flowType: FlowType, backState: State): InsertKeycard
proc delete*(self: InsertKeycardState) = proc delete*(self: InsertKeycardState) =
self.State.delete self.State.delete
method executeBackCommand*(self: InsertKeycardState, controller: Controller) = method executePreBackStateCommand*(self: InsertKeycardState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair: if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
controller.cancelCurrentFlow() controller.cancelCurrentFlow()
method executeTertiaryCommand*(self: InsertKeycardState, controller: Controller) = method executePreTertiaryStateCommand*(self: InsertKeycardState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -8,10 +8,10 @@ proc newKeyPairMigrateFailureState*(flowType: FlowType, backState: State): KeyPa
proc delete*(self: KeyPairMigrateFailureState) = proc delete*(self: KeyPairMigrateFailureState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeyPairMigrateFailureState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeyPairMigrateFailureState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: KeyPairMigrateFailureState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeyPairMigrateFailureState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,7 +8,7 @@ proc newKeyPairMigrateSuccessState*(flowType: FlowType, backState: State): KeyPa
proc delete*(self: KeyPairMigrateSuccessState) = proc delete*(self: KeyPairMigrateSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeyPairMigrateSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeyPairMigrateSuccessState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
if controller.getSelectedKeyPairIsProfile(): if controller.getSelectedKeyPairIsProfile():

View File

@ -8,10 +8,10 @@ proc newKeycardAlreadyUnlockedState*(flowType: FlowType, backState: State): Keyc
proc delete*(self: KeycardAlreadyUnlockedState) = proc delete*(self: KeycardAlreadyUnlockedState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,10 +8,10 @@ proc newChangingKeycardPairingCodeFailureState*(flowType: FlowType, backState: S
proc delete*(self: ChangingKeycardPairingCodeFailureState) = proc delete*(self: ChangingKeycardPairingCodeFailureState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) = method executePrePrimaryStateCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) =
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) = method executePreTertiaryStateCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) =
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,10 +8,10 @@ proc newChangingKeycardPairingCodeSuccessState*(flowType: FlowType, backState: S
proc delete*(self: ChangingKeycardPairingCodeSuccessState) = proc delete*(self: ChangingKeycardPairingCodeSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) =
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) = method executePreTertiaryStateCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) =
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,10 +8,10 @@ proc newChangingKeycardPinFailureState*(flowType: FlowType, backState: State): C
proc delete*(self: ChangingKeycardPinFailureState) = proc delete*(self: ChangingKeycardPinFailureState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: ChangingKeycardPinFailureState, controller: Controller) = method executePrePrimaryStateCommand*(self: ChangingKeycardPinFailureState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPin: if self.flowType == FlowType.ChangeKeycardPin:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: ChangingKeycardPinFailureState, controller: Controller) = method executePreTertiaryStateCommand*(self: ChangingKeycardPinFailureState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPin: if self.flowType == FlowType.ChangeKeycardPin:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,10 +8,10 @@ proc newChangingKeycardPinSuccessState*(flowType: FlowType, backState: State): C
proc delete*(self: ChangingKeycardPinSuccessState) = proc delete*(self: ChangingKeycardPinSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPin: if self.flowType == FlowType.ChangeKeycardPin:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) = method executePreTertiaryStateCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPin: if self.flowType == FlowType.ChangeKeycardPin:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,10 +8,10 @@ proc newChangingKeycardPukFailureState*(flowType: FlowType, backState: State): C
proc delete*(self: ChangingKeycardPukFailureState) = proc delete*(self: ChangingKeycardPukFailureState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: ChangingKeycardPukFailureState, controller: Controller) = method executePrePrimaryStateCommand*(self: ChangingKeycardPukFailureState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: ChangingKeycardPukFailureState, controller: Controller) = method executePreTertiaryStateCommand*(self: ChangingKeycardPukFailureState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,10 +8,10 @@ proc newChangingKeycardPukSuccessState*(flowType: FlowType, backState: State): C
proc delete*(self: ChangingKeycardPukSuccessState) = proc delete*(self: ChangingKeycardPukSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) = method executePreTertiaryStateCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,14 +8,14 @@ proc newKeycardEmptyMetadataState*(flowType: FlowType, backState: State): Keycar
proc delete*(self: KeycardEmptyMetadataState) = proc delete*(self: KeycardEmptyMetadataState) =
self.State.delete self.State.delete
method executeTertiaryCommand*(self: KeycardEmptyMetadataState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardEmptyMetadataState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.DisplayKeycardContent or self.flowType == FlowType.DisplayKeycardContent or
self.flowType == FlowType.RenameKeycard: self.flowType == FlowType.RenameKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
method executePrimaryCommand*(self: KeycardEmptyMetadataState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeycardEmptyMetadataState, controller: Controller) =
if self.flowType == FlowType.DisplayKeycardContent or if self.flowType == FlowType.DisplayKeycardContent or
self.flowType == FlowType.RenameKeycard: self.flowType == FlowType.RenameKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,7 +8,7 @@ proc newKeycardEmptyState*(flowType: FlowType, backState: State): KeycardEmptySt
proc delete*(self: KeycardEmptyState) = proc delete*(self: KeycardEmptyState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeycardEmptyState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeycardEmptyState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or
self.flowType == FlowType.UnlockKeycard or self.flowType == FlowType.UnlockKeycard or
@ -19,7 +19,7 @@ method executePrimaryCommand*(self: KeycardEmptyState, controller: Controller) =
self.flowType == FlowType.ChangePairingCode: self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
method executeTertiaryCommand*(self: KeycardEmptyState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardEmptyState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or
self.flowType == FlowType.UnlockKeycard or self.flowType == FlowType.UnlockKeycard or

View File

@ -8,7 +8,7 @@ proc newKeycardInsertedState*(flowType: FlowType, backState: State): KeycardInse
proc delete*(self: KeycardInsertedState) = proc delete*(self: KeycardInsertedState) =
self.State.delete self.State.delete
method executeBackCommand*(self: KeycardInsertedState, controller: Controller) = method executePreBackStateCommand*(self: KeycardInsertedState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair: if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
controller.cancelCurrentFlow() controller.cancelCurrentFlow()
@ -20,7 +20,7 @@ method getNextSecondaryState*(self: KeycardInsertedState, controller: Controller
return createState(StateType.ReadingKeycard, self.flowType, self.getBackState) return createState(StateType.ReadingKeycard, self.flowType, self.getBackState)
return createState(StateType.ReadingKeycard, self.flowType, nil) return createState(StateType.ReadingKeycard, self.flowType, nil)
method executeTertiaryCommand*(self: KeycardInsertedState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardInsertedState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -17,7 +17,7 @@ method getNextPrimaryState*(self: KeycardMetadataDisplayState, controller: Contr
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
return createState(StateType.EnterKeycardName, self.flowType, nil) return createState(StateType.EnterKeycardName, self.flowType, nil)
method executeTertiaryCommand*(self: KeycardMetadataDisplayState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardMetadataDisplayState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.DisplayKeycardContent or self.flowType == FlowType.DisplayKeycardContent or

View File

@ -8,12 +8,12 @@ proc newKeycardNotEmptyState*(flowType: FlowType, backState: State): KeycardNotE
proc delete*(self: KeycardNotEmptyState) = proc delete*(self: KeycardNotEmptyState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeycardNotEmptyState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeycardNotEmptyState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
controller.runGetMetadataFlow(resolveAddress = true) controller.runGetMetadataFlow(resolveAddress = true)
method executeTertiaryCommand*(self: KeycardNotEmptyState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardNotEmptyState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,10 +8,10 @@ proc newKeycardRenameFailureState*(flowType: FlowType, backState: State): Keycar
proc delete*(self: KeycardRenameFailureState) = proc delete*(self: KeycardRenameFailureState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeycardRenameFailureState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeycardRenameFailureState, controller: Controller) =
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: KeycardRenameFailureState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardRenameFailureState, controller: Controller) =
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -8,10 +8,10 @@ proc newKeycardRenameSuccessState*(flowType: FlowType, backState: State): Keycar
proc delete*(self: KeycardRenameSuccessState) = proc delete*(self: KeycardRenameSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: KeycardRenameSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: KeycardRenameSuccessState, controller: Controller) =
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: KeycardRenameSuccessState, controller: Controller) = method executePreTertiaryStateCommand*(self: KeycardRenameSuccessState, controller: Controller) =
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -21,7 +21,7 @@ method getNextPrimaryState*(self: MaxPairingSlotsReachedState, controller: Contr
controller.runSharedModuleFlow(FlowType.UnlockKeycard) controller.runSharedModuleFlow(FlowType.UnlockKeycard)
return nil return nil
method executeTertiaryCommand*(self: MaxPairingSlotsReachedState, controller: Controller) = method executePreTertiaryStateCommand*(self: MaxPairingSlotsReachedState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -26,7 +26,7 @@ method getNextPrimaryState*(self: MaxPinRetriesReachedState, controller: Control
controller.runSharedModuleFlow(FlowType.UnlockKeycard) controller.runSharedModuleFlow(FlowType.UnlockKeycard)
return nil return nil
method executeTertiaryCommand*(self: MaxPinRetriesReachedState, controller: Controller) = method executePreTertiaryStateCommand*(self: MaxPinRetriesReachedState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or
self.flowType == FlowType.DisplayKeycardContent or self.flowType == FlowType.DisplayKeycardContent or

View File

@ -22,7 +22,7 @@ method getNextPrimaryState*(self: MaxPukRetriesReachedState, controller: Control
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
return createState(StateType.EnterSeedPhrase, self.flowType, self) return createState(StateType.EnterSeedPhrase, self.flowType, self)
method executeTertiaryCommand*(self: MaxPukRetriesReachedState, controller: Controller) = method executePreTertiaryStateCommand*(self: MaxPukRetriesReachedState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -29,14 +29,14 @@ proc doMigration(self: MigratingKeyPairState, controller: Controller) =
controller.runStoreMetadataFlow(selectedKeyPairDto.keycardName, controller.getPin(), controller.runStoreMetadataFlow(selectedKeyPairDto.keycardName, controller.getPin(),
controller.getSelectedKeyPairWalletPaths()) controller.getSelectedKeyPairWalletPaths())
method executePrimaryCommand*(self: MigratingKeyPairState, controller: Controller) = method executePrePrimaryStateCommand*(self: MigratingKeyPairState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if controller.getSelectedKeyPairIsProfile(): if controller.getSelectedKeyPairIsProfile():
controller.authenticateUser() controller.authenticateUser()
else: else:
self.doMigration(controller) self.doMigration(controller)
method executeSecondaryCommand*(self: MigratingKeyPairState, controller: Controller) = method executePreSecondaryStateCommand*(self: MigratingKeyPairState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
self.doMigration(controller) self.doMigration(controller)

View File

@ -8,7 +8,7 @@ proc newNotKeycardState*(flowType: FlowType, backState: State): NotKeycardState
proc delete*(self: NotKeycardState) = proc delete*(self: NotKeycardState) =
self.State.delete self.State.delete
method executeTertiaryCommand*(self: NotKeycardState, controller: Controller) = method executePreTertiaryStateCommand*(self: NotKeycardState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -22,6 +22,6 @@ method getNextPrimaryState*(self: PinSetState, controller: Controller): State =
if controller.getCurrentKeycardServiceFlow() == KCSFlowType.StoreMetadata: if controller.getCurrentKeycardServiceFlow() == KCSFlowType.StoreMetadata:
return createState(StateType.UnlockKeycardSuccess, self.flowType, nil) return createState(StateType.UnlockKeycardSuccess, self.flowType, nil)
method executeTertiaryCommand*(self: PinSetState, controller: Controller) = method executePreTertiaryStateCommand*(self: PinSetState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -21,7 +21,7 @@ method getNextPrimaryState*(self: PinVerifiedState, controller: Controller): Sta
if self.flowType == FlowType.ChangePairingCode: if self.flowType == FlowType.ChangePairingCode:
return createState(StateType.CreatePairingCode, self.flowType, nil) return createState(StateType.CreatePairingCode, self.flowType, nil)
method executeTertiaryCommand*(self: PinVerifiedState, controller: Controller) = method executePreTertiaryStateCommand*(self: PinVerifiedState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.DisplayKeycardContent or self.flowType == FlowType.DisplayKeycardContent or

View File

@ -8,12 +8,12 @@ proc newPluginReaderState*(flowType: FlowType, backState: State): PluginReaderSt
proc delete*(self: PluginReaderState) = proc delete*(self: PluginReaderState) =
self.State.delete self.State.delete
method executeBackCommand*(self: PluginReaderState, controller: Controller) = method executePreBackStateCommand*(self: PluginReaderState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair: if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
controller.cancelCurrentFlow() controller.cancelCurrentFlow()
method executeTertiaryCommand*(self: PluginReaderState, controller: Controller) = method executePreTertiaryStateCommand*(self: PluginReaderState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -8,12 +8,12 @@ proc newReadingKeycardState*(flowType: FlowType, backState: State): ReadingKeyca
proc delete*(self: ReadingKeycardState) = proc delete*(self: ReadingKeycardState) =
self.State.delete self.State.delete
method executeBackCommand*(self: ReadingKeycardState, controller: Controller) = method executePreBackStateCommand*(self: ReadingKeycardState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair: if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
controller.cancelCurrentFlow() controller.cancelCurrentFlow()
method executeTertiaryCommand*(self: ReadingKeycardState, controller: Controller) = method executePreTertiaryStateCommand*(self: ReadingKeycardState, controller: Controller) =
error "reading state must not be canceled" error "reading state must not be canceled"
method getNextSecondaryState*(self: ReadingKeycardState, controller: Controller): State = method getNextSecondaryState*(self: ReadingKeycardState, controller: Controller): State =

View File

@ -8,7 +8,7 @@ proc newRecognizedKeycardState*(flowType: FlowType, backState: State): Recognize
proc delete*(self: RecognizedKeycardState) = proc delete*(self: RecognizedKeycardState) =
self.State.delete self.State.delete
method executeBackCommand*(self: RecognizedKeycardState, controller: Controller) = method executePreBackStateCommand*(self: RecognizedKeycardState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair: if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
controller.cancelCurrentFlow() controller.cancelCurrentFlow()
@ -30,5 +30,5 @@ method getNextSecondaryState*(self: RecognizedKeycardState, controller: Controll
self.flowType == FlowType.ChangePairingCode: self.flowType == FlowType.ChangePairingCode:
return createState(StateType.EnterPin, self.flowType, nil) return createState(StateType.EnterPin, self.flowType, nil)
method executeTertiaryCommand*(self: RecognizedKeycardState, controller: Controller) = method executePreTertiaryStateCommand*(self: RecognizedKeycardState, controller: Controller) =
error "recognized state must not be canceled" error "recognized state must not be canceled"

View File

@ -10,7 +10,7 @@ proc newRenamingKeycardState*(flowType: FlowType, backState: State): RenamingKey
proc delete*(self: RenamingKeycardState) = proc delete*(self: RenamingKeycardState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: RenamingKeycardState, controller: Controller) = method executePrePrimaryStateCommand*(self: RenamingKeycardState, controller: Controller) =
if self.flowType == FlowType.RenameKeycard: if self.flowType == FlowType.RenameKeycard:
let md = controller.getMetadataFromKeycard() let md = controller.getMetadataFromKeycard()
let paths = md.walletAccounts.map(a => a.path) let paths = md.walletAccounts.map(a => a.path)

View File

@ -8,11 +8,11 @@ proc newRepeatPinState*(flowType: FlowType, backState: State): RepeatPinState =
proc delete*(self: RepeatPinState) = proc delete*(self: RepeatPinState) =
self.State.delete self.State.delete
method executeBackCommand*(self: RepeatPinState, controller: Controller) = method executePreBackStateCommand*(self: RepeatPinState, controller: Controller) =
controller.setPin("") controller.setPin("")
controller.setPinMatch(false) controller.setPinMatch(false)
method executeSecondaryCommand*(self: RepeatPinState, controller: Controller) = method executePreSecondaryStateCommand*(self: RepeatPinState, controller: Controller) =
if not controller.getPinMatch(): if not controller.getPinMatch():
return return
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
@ -26,7 +26,7 @@ method getNextSecondaryState*(self: RepeatPinState, controller: Controller): Sta
if self.flowType == FlowType.ChangeKeycardPin: if self.flowType == FlowType.ChangeKeycardPin:
return createState(StateType.ChangingKeycardPin, self.flowType, nil) return createState(StateType.ChangingKeycardPin, self.flowType, nil)
method executeTertiaryCommand*(self: RepeatPinState, controller: Controller) = method executePreTertiaryStateCommand*(self: RepeatPinState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard or if self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.UnlockKeycard or self.flowType == FlowType.UnlockKeycard or
self.flowType == FlowType.ChangeKeycardPin: self.flowType == FlowType.ChangeKeycardPin:

View File

@ -8,7 +8,7 @@ proc newRepeatPukState*(flowType: FlowType, backState: State): RepeatPukState =
proc delete*(self: RepeatPukState) = proc delete*(self: RepeatPukState) =
self.State.delete self.State.delete
method executeBackCommand*(self: RepeatPukState, controller: Controller) = method executePreBackStateCommand*(self: RepeatPukState, controller: Controller) =
controller.setPuk("") controller.setPuk("")
controller.setPukMatch(false) controller.setPukMatch(false)
@ -18,6 +18,6 @@ method getNextSecondaryState*(self: RepeatPukState, controller: Controller): Sta
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
return createState(StateType.ChangingKeycardPuk, self.flowType, nil) return createState(StateType.ChangingKeycardPuk, self.flowType, nil)
method executeTertiaryCommand*(self: RepeatPukState, controller: Controller) = method executePreTertiaryStateCommand*(self: RepeatPukState, controller: Controller) =
if self.flowType == FlowType.ChangeKeycardPuk: if self.flowType == FlowType.ChangeKeycardPuk:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,7 +8,7 @@ proc newSeedPhraseDisplayState*(flowType: FlowType, backState: State): SeedPhras
proc delete*(self: SeedPhraseDisplayState) = proc delete*(self: SeedPhraseDisplayState) =
self.State.delete self.State.delete
method executeTertiaryCommand*(self: SeedPhraseDisplayState, controller: Controller) = method executePreTertiaryStateCommand*(self: SeedPhraseDisplayState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -10,12 +10,12 @@ proc newSeedPhraseEnterWordsState*(flowType: FlowType, backState: State): SeedPh
proc delete*(self: SeedPhraseEnterWordsState) = proc delete*(self: SeedPhraseEnterWordsState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) = method executePrePrimaryStateCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
let mnemonic = controller.getMnemonic() let mnemonic = controller.getMnemonic()
controller.setSeedPhrase(mnemonic) controller.setSeedPhrase(mnemonic)
controller.storeSeedPhraseToKeycard(mnemonic.split(" ").len, mnemonic) controller.storeSeedPhraseToKeycard(mnemonic.split(" ").len, mnemonic)
method executeTertiaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) = method executePreTertiaryStateCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,11 +8,11 @@ proc newSelectExistingKeyPairState*(flowType: FlowType, backState: State): Selec
proc delete*(self: SelectExistingKeyPairState) = proc delete*(self: SelectExistingKeyPairState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: SelectExistingKeyPairState, controller: Controller) = method executePrePrimaryStateCommand*(self: SelectExistingKeyPairState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.runLoadAccountFlow() controller.runLoadAccountFlow()
method executeTertiaryCommand*(self: SelectExistingKeyPairState, controller: Controller) = method executePreTertiaryStateCommand*(self: SelectExistingKeyPairState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -111,32 +111,48 @@ method getBackState*(self: State): State {.inline base.} =
method displayBackButton*(self: State): bool {.inline base.} = method displayBackButton*(self: State): bool {.inline base.} =
return not self.backState.isNil return not self.backState.isNil
## Returns next state instance in case the "primary" action is triggered ## Returns next state instance if "primary" action is triggered
method getNextPrimaryState*(self: State, controller: Controller): State {.inline base.} = method getNextPrimaryState*(self: State, controller: Controller): State {.inline base.} =
return nil return nil
## Returns next state instance in case the "secondary" action is triggered ## Returns next state instance if "secondary" action is triggered
method getNextSecondaryState*(self: State, controller: Controller): State {.inline base.} = method getNextSecondaryState*(self: State, controller: Controller): State {.inline base.} =
return nil return nil
## Returns next state instance in case the "tertiary" action is triggered ## Returns next state instance if "tertiary" action is triggered
method getNextTertiaryState*(self: State, controller: Controller): State {.inline base.} = method getNextTertiaryState*(self: State, controller: Controller): State {.inline base.} =
return nil return nil
## This method is executed in case "back" button is clicked ## This method is executed before back state is set, if "back" action is triggered
method executeBackCommand*(self: State, controller: Controller) {.inline base.} = method executePreBackStateCommand*(self: State, controller: Controller) {.inline base.} =
discard discard
## This method is executed in case "primary" action is triggered ## This method is executed after back state is set, if "back" action is triggered
method executePrimaryCommand*(self: State, controller: Controller) {.inline base.} = method executePostBackStateCommand*(self: State, controller: Controller) {.inline base.} =
discard discard
## This method is executed in case "secondary" action is triggered ## This method is executed before primary state is set, if "primary" action is triggered
method executeSecondaryCommand*(self: State, controller: Controller) {.inline base.} = method executePrePrimaryStateCommand*(self: State, controller: Controller) {.inline base.} =
discard discard
## This method is executed in case "tertiary" action is triggered ## This method is executed after primary state is set, if "primary" action is triggered
method executeTertiaryCommand*(self: State, controller: Controller) {.inline base.} = method executePostPrimaryStateCommand*(self: State, controller: Controller) {.inline base.} =
discard
## This method is executed before secondary state is set, if "secondary" action is triggered
method executePreSecondaryStateCommand*(self: State, controller: Controller) {.inline base.} =
discard
## This method is executed after secondary state is set, if "secondary" action is triggered
method executePostSecondaryStateCommand*(self: State, controller: Controller) {.inline base.} =
discard
## This method is executed before tertiary state is set, if "tertiary" action is triggered
method executePreTertiaryStateCommand*(self: State, controller: Controller) {.inline base.} =
discard
## This method is executed after tertiary state is set, if "tertiary" action is triggered
method executePostTertiaryStateCommand*(self: State, controller: Controller) {.inline base.} =
discard discard
## This method is used for handling aync responses for keycard related states ## This method is used for handling aync responses for keycard related states

View File

@ -16,6 +16,6 @@ method getNextSecondaryState*(self: UnlockKeycardOptionsState, controller: Contr
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
return createState(StateType.EnterPuk, self.flowType, self) return createState(StateType.EnterPuk, self.flowType, self)
method executeTertiaryCommand*(self: UnlockKeycardOptionsState, controller: Controller) = method executePreTertiaryStateCommand*(self: UnlockKeycardOptionsState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,10 +8,10 @@ proc newUnlockKeycardSuccessState*(flowType: FlowType, backState: State): Unlock
proc delete*(self: UnlockKeycardSuccessState) = proc delete*(self: UnlockKeycardSuccessState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: UnlockKeycardSuccessState, controller: Controller) = method executePrePrimaryStateCommand*(self: UnlockKeycardSuccessState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: UnlockKeycardSuccessState, controller: Controller) = method executePreTertiaryStateCommand*(self: UnlockKeycardSuccessState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)

View File

@ -10,7 +10,7 @@ proc newWrongBiometricsPasswordState*(flowType: FlowType, backState: State): Wro
proc delete*(self: WrongBiometricsPasswordState) = proc delete*(self: WrongBiometricsPasswordState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: WrongBiometricsPasswordState, controller: Controller) = method executePrePrimaryStateCommand*(self: WrongBiometricsPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = false)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = false))
let password = controller.getPassword() let password = controller.getPassword()
@ -21,7 +21,7 @@ method executePrimaryCommand*(self: WrongBiometricsPasswordState, controller: Co
else: else:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = true)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = true))
method executeTertiaryCommand*(self: WrongBiometricsPasswordState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongBiometricsPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -8,7 +8,7 @@ proc newWrongKeycardState*(flowType: FlowType, backState: State): WrongKeycardSt
proc delete*(self: WrongKeycardState) = proc delete*(self: WrongKeycardState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: WrongKeycardState, controller: Controller) = method executePrePrimaryStateCommand*(self: WrongKeycardState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard or if self.flowType == FlowType.UnlockKeycard or
self.flowType == FlowType.RenameKeycard or self.flowType == FlowType.RenameKeycard or
self.flowType == FlowType.ChangeKeycardPin or self.flowType == FlowType.ChangeKeycardPin or
@ -16,7 +16,7 @@ method executePrimaryCommand*(self: WrongKeycardState, controller: Controller) =
self.flowType == FlowType.ChangePairingCode: self.flowType == FlowType.ChangePairingCode:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
method executeTertiaryCommand*(self: WrongKeycardState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongKeycardState, controller: Controller) =
if self.flowType == FlowType.Authentication or if self.flowType == FlowType.Authentication or
self.flowType == FlowType.UnlockKeycard or self.flowType == FlowType.UnlockKeycard or
self.flowType == FlowType.RenameKeycard or self.flowType == FlowType.RenameKeycard or

View File

@ -14,7 +14,7 @@ method getNextPrimaryState*(self: WrongKeychainPinState, controller: Controller)
controller.enterKeycardPin(controller.getPin()) controller.enterKeycardPin(controller.getPin())
return nil return nil
method executeTertiaryCommand*(self: WrongKeychainPinState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongKeychainPinState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -10,7 +10,7 @@ proc newWrongPasswordState*(flowType: FlowType, backState: State): WrongPassword
proc delete*(self: WrongPasswordState) = proc delete*(self: WrongPasswordState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: WrongPasswordState, controller: Controller) = method executePrePrimaryStateCommand*(self: WrongPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = false)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = false))
let password = controller.getPassword() let password = controller.getPassword()
@ -20,11 +20,11 @@ method executePrimaryCommand*(self: WrongPasswordState, controller: Controller)
else: else:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = true)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = true))
method executeSecondaryCommand*(self: WrongPasswordState, controller: Controller) = method executePreSecondaryStateCommand*(self: WrongPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeTertiaryCommand*(self: WrongPasswordState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongPasswordState, controller: Controller) =
if self.flowType == FlowType.Authentication: if self.flowType == FlowType.Authentication:
controller.setPassword("") controller.setPassword("")
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -22,7 +22,7 @@ method getNextPrimaryState*(self: WrongPinState, controller: Controller): State
self.flowType == FlowType.ChangePairingCode: self.flowType == FlowType.ChangePairingCode:
controller.runSharedModuleFlow(FlowType.FactoryReset) controller.runSharedModuleFlow(FlowType.FactoryReset)
method executeSecondaryCommand*(self: WrongPinState, controller: Controller) = method executePreSecondaryStateCommand*(self: WrongPinState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.DisplayKeycardContent or self.flowType == FlowType.DisplayKeycardContent or
@ -36,7 +36,7 @@ method executeSecondaryCommand*(self: WrongPinState, controller: Controller) =
controller.setUsePinFromBiometrics(false) controller.setUsePinFromBiometrics(false)
controller.tryToObtainDataFromKeychain() controller.tryToObtainDataFromKeychain()
method executeTertiaryCommand*(self: WrongPinState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongPinState, controller: Controller) =
if self.flowType == FlowType.FactoryReset or if self.flowType == FlowType.FactoryReset or
self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.Authentication or self.flowType == FlowType.Authentication or

View File

@ -8,12 +8,12 @@ proc newWrongPukState*(flowType: FlowType, backState: State): WrongPukState =
proc delete*(self: WrongPukState) = proc delete*(self: WrongPukState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: WrongPukState, controller: Controller) = method executePrePrimaryStateCommand*(self: WrongPukState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
if controller.getPuk().len == PUKLengthForStatusApp: if controller.getPuk().len == PUKLengthForStatusApp:
controller.enterKeycardPuk(controller.getPuk()) controller.enterKeycardPuk(controller.getPuk())
method executeTertiaryCommand*(self: WrongPukState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongPukState, controller: Controller) =
if self.flowType == FlowType.UnlockKeycard: if self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -12,7 +12,7 @@ proc newWrongSeedPhraseState*(flowType: FlowType, backState: State): WrongSeedPh
proc delete*(self: WrongSeedPhraseState) = proc delete*(self: WrongSeedPhraseState) =
self.State.delete self.State.delete
method executePrimaryCommand*(self: WrongSeedPhraseState, controller: Controller) = method executePrePrimaryStateCommand*(self: WrongSeedPhraseState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard: if self.flowType == FlowType.SetupNewKeycard:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongSeedPhrase, add = false)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongSeedPhrase, add = false))
sleep(500) # just to shortly remove text on the UI side sleep(500) # just to shortly remove text on the UI side
@ -32,7 +32,7 @@ method executePrimaryCommand*(self: WrongSeedPhraseState, controller: Controller
else: else:
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongSeedPhrase, add = true)) controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongSeedPhrase, add = true))
method executeTertiaryCommand*(self: WrongSeedPhraseState, controller: Controller) = method executePreTertiaryStateCommand*(self: WrongSeedPhraseState, controller: Controller) =
if self.flowType == FlowType.SetupNewKeycard or if self.flowType == FlowType.SetupNewKeycard or
self.flowType == FlowType.UnlockKeycard: self.flowType == FlowType.UnlockKeycard:
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)

View File

@ -166,10 +166,11 @@ method onBackActionClicked*[T](self: Module[T]) =
error "sm_cannot resolve current state" error "sm_cannot resolve current state"
return return
debug "sm_back_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType() debug "sm_back_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
currStateObj.executeBackCommand(self.controller) currStateObj.executePreBackStateCommand(self.controller)
let backState = currStateObj.getBackState() let backState = currStateObj.getBackState()
self.preStateActivities(backState.flowType(), backState.stateType()) self.preStateActivities(backState.flowType(), backState.stateType())
self.view.setCurrentState(backState) self.view.setCurrentState(backState)
currStateObj.executePostBackStateCommand(self.controller)
debug "sm_back_action - set state", setCurrFlow=backState.flowType(), newCurrState=backState.stateType() debug "sm_back_action - set state", setCurrFlow=backState.flowType(), newCurrState=backState.stateType()
currStateObj.delete() currStateObj.delete()
@ -179,12 +180,13 @@ method onPrimaryActionClicked*[T](self: Module[T]) =
error "sm_cannot resolve current state" error "sm_cannot resolve current state"
return return
debug "sm_primary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType() debug "sm_primary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
currStateObj.executePrimaryCommand(self.controller) currStateObj.executePrePrimaryStateCommand(self.controller)
let nextState = currStateObj.getNextPrimaryState(self.controller) let nextState = currStateObj.getNextPrimaryState(self.controller)
if nextState.isNil: if nextState.isNil:
return return
self.preStateActivities(nextState.flowType(), nextState.stateType()) self.preStateActivities(nextState.flowType(), nextState.stateType())
self.view.setCurrentState(nextState) self.view.setCurrentState(nextState)
currStateObj.executePostPrimaryStateCommand(self.controller)
debug "sm_primary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType() debug "sm_primary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType()
method onSecondaryActionClicked*[T](self: Module[T]) = method onSecondaryActionClicked*[T](self: Module[T]) =
@ -193,12 +195,13 @@ method onSecondaryActionClicked*[T](self: Module[T]) =
error "sm_cannot resolve current state" error "sm_cannot resolve current state"
return return
debug "sm_secondary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType() debug "sm_secondary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
currStateObj.executeSecondaryCommand(self.controller) currStateObj.executePreSecondaryStateCommand(self.controller)
let nextState = currStateObj.getNextSecondaryState(self.controller) let nextState = currStateObj.getNextSecondaryState(self.controller)
if nextState.isNil: if nextState.isNil:
return return
self.preStateActivities(nextState.flowType(), nextState.stateType()) self.preStateActivities(nextState.flowType(), nextState.stateType())
self.view.setCurrentState(nextState) self.view.setCurrentState(nextState)
currStateObj.executePostSecondaryStateCommand(self.controller)
debug "sm_secondary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType() debug "sm_secondary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType()
method onTertiaryActionClicked*[T](self: Module[T]) = method onTertiaryActionClicked*[T](self: Module[T]) =
@ -207,12 +210,13 @@ method onTertiaryActionClicked*[T](self: Module[T]) =
error "sm_cannot resolve current state" error "sm_cannot resolve current state"
return return
debug "sm_tertiary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType() debug "sm_tertiary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
currStateObj.executeTertiaryCommand(self.controller) currStateObj.executePreTertiaryStateCommand(self.controller)
let nextState = currStateObj.getNextTertiaryState(self.controller) let nextState = currStateObj.getNextTertiaryState(self.controller)
if nextState.isNil: if nextState.isNil:
return return
self.preStateActivities(nextState.flowType(), nextState.stateType()) self.preStateActivities(nextState.flowType(), nextState.stateType())
self.view.setCurrentState(nextState) self.view.setCurrentState(nextState)
currStateObj.executePostTertiaryStateCommand(self.controller)
debug "sm_tertiary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType() debug "sm_tertiary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType()
method onKeycardResponse*[T](self: Module[T], keycardFlowType: string, keycardEvent: KeycardEvent) = method onKeycardResponse*[T](self: Module[T], keycardFlowType: string, keycardEvent: KeycardEvent) =