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:
parent
78fda35807
commit
21eeefa42e
|
@ -8,7 +8,7 @@ proc newBiometricsPasswordFailedState*(flowType: FlowType, backState: State): Bi
|
|||
proc delete*(self: BiometricsPasswordFailedState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: BiometricsPasswordFailedState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: BiometricsPasswordFailedState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
|
@ -16,7 +16,7 @@ method getNextSecondaryState*(self: BiometricsPasswordFailedState, controller: C
|
|||
if self.flowType == FlowType.Authentication:
|
||||
return createState(StateType.EnterPassword, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: BiometricsPasswordFailedState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: BiometricsPasswordFailedState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,11 +8,11 @@ proc newBiometricsPinFailedState*(flowType: FlowType, backState: State): Biometr
|
|||
proc delete*(self: BiometricsPinFailedState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: BiometricsPinFailedState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: BiometricsPinFailedState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeSecondaryCommand*(self: BiometricsPinFailedState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: BiometricsPinFailedState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setUsePinFromBiometrics(true)
|
||||
|
||||
|
@ -20,7 +20,7 @@ method getNextSecondaryState*(self: BiometricsPinFailedState, controller: Contro
|
|||
if self.flowType == FlowType.Authentication:
|
||||
return createState(StateType.EnterPin, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: BiometricsPinFailedState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: BiometricsPinFailedState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.setPin("")
|
||||
|
|
|
@ -8,11 +8,11 @@ proc newBiometricsPinInvalidState*(flowType: FlowType, backState: State): Biomet
|
|||
proc delete*(self: BiometricsPinInvalidState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: BiometricsPinInvalidState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: BiometricsPinInvalidState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeSecondaryCommand*(self: BiometricsPinInvalidState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: BiometricsPinInvalidState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setUsePinFromBiometrics(true)
|
||||
controller.setOfferToStoreUpdatedPinToKeychain(true)
|
||||
|
@ -21,7 +21,7 @@ method getNextSecondaryState*(self: BiometricsPinInvalidState, controller: Contr
|
|||
if self.flowType == FlowType.Authentication:
|
||||
return createState(StateType.EnterPin, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: BiometricsPinInvalidState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: BiometricsPinInvalidState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.setPin("")
|
||||
|
|
|
@ -8,11 +8,11 @@ proc newBiometricsReadyToSignState*(flowType: FlowType, backState: State): Biome
|
|||
proc delete*(self: BiometricsReadyToSignState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: BiometricsReadyToSignState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: BiometricsReadyToSignState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeSecondaryCommand*(self: BiometricsReadyToSignState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: BiometricsReadyToSignState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setUsePinFromBiometrics(true)
|
||||
|
||||
|
@ -20,7 +20,7 @@ method getNextSecondaryState*(self: BiometricsReadyToSignState, controller: Cont
|
|||
if self.flowType == FlowType.Authentication:
|
||||
return createState(StateType.EnterPin, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: BiometricsReadyToSignState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: BiometricsReadyToSignState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.setPin("")
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newChangingKeycardPairingCodeState*(flowType: FlowType, backState: State):
|
|||
proc delete*(self: ChangingKeycardPairingCodeState) =
|
||||
self.State.delete
|
||||
|
||||
method executeSecondaryCommand*(self: ChangingKeycardPairingCodeState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: ChangingKeycardPairingCodeState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangePairingCode:
|
||||
controller.storePairingCodeToKeycard(controller.getPairingCode())
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newChangingKeycardPinState*(flowType: FlowType, backState: State): Changing
|
|||
proc delete*(self: ChangingKeycardPinState) =
|
||||
self.State.delete
|
||||
|
||||
method executeSecondaryCommand*(self: ChangingKeycardPinState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: ChangingKeycardPinState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPin:
|
||||
controller.storePinToKeycard(controller.getPin(), "")
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newChangingKeycardPukState*(flowType: FlowType, backState: State): Changing
|
|||
proc delete*(self: ChangingKeycardPukState) =
|
||||
self.State.delete
|
||||
|
||||
method executeSecondaryCommand*(self: ChangingKeycardPukState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: ChangingKeycardPukState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.storePukToKeycard(controller.getPuk())
|
||||
|
||||
|
|
|
@ -14,6 +14,6 @@ method getNextPrimaryState*(self: CreatePairingCodeState, controller: Controller
|
|||
return createState(StateType.ChangingKeycardPairingCode, 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:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,14 +8,14 @@ proc newCreatePinState*(flowType: FlowType, backState: State): CreatePinState =
|
|||
proc delete*(self: CreatePinState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: CreatePinState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: CreatePinState, controller: Controller) =
|
||||
controller.setPin("")
|
||||
controller.setPinMatch(false)
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executeTertiaryCommand*(self: CreatePinState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: CreatePinState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.UnlockKeycard or
|
||||
self.flowType == FlowType.ChangeKeycardPin:
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newCreatePukState*(flowType: FlowType, backState: State): CreatePukState =
|
|||
proc delete*(self: CreatePukState) =
|
||||
self.State.delete
|
||||
|
||||
method executeTertiaryCommand*(self: CreatePukState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: CreatePukState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ proc newEnterBiometricsPasswordState*(flowType: FlowType, backState: State): Ent
|
|||
proc delete*(self: EnterBiometricsPasswordState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: EnterBiometricsPasswordState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: EnterBiometricsPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
let password = controller.getPassword()
|
||||
self.success = controller.verifyPassword(password)
|
||||
|
@ -25,7 +25,7 @@ method getNextPrimaryState*(self: EnterBiometricsPasswordState, controller: Cont
|
|||
if not self.success:
|
||||
return createState(StateType.WrongBiometricsPassword, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: EnterBiometricsPasswordState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: EnterBiometricsPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -14,7 +14,7 @@ method getNextPrimaryState*(self: EnterKeycardNameState, controller: Controller)
|
|||
if self.flowType == FlowType.RenameKeycard:
|
||||
return createState(StateType.RenamingKeycard, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: EnterKeycardNameState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: EnterKeycardNameState, controller: Controller) =
|
||||
if self.flowType == FlowType.RenameKeycard:
|
||||
controller.setPassword("")
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
|
|
@ -10,7 +10,7 @@ proc newEnterPasswordState*(flowType: FlowType, backState: State): EnterPassword
|
|||
proc delete*(self: EnterPasswordState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: EnterPasswordState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: EnterPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
let password = controller.getPassword()
|
||||
self.success = controller.verifyPassword(password)
|
||||
|
@ -24,11 +24,11 @@ method getNextPrimaryState*(self: EnterPasswordState, controller: Controller): S
|
|||
if not self.success:
|
||||
return createState(StateType.WrongPassword, self.flowType, nil)
|
||||
|
||||
method executeSecondaryCommand*(self: EnterPasswordState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: EnterPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeTertiaryCommand*(self: EnterPasswordState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: EnterPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -16,7 +16,7 @@ method getNextPrimaryState*(self: EnterPinState, controller: Controller): State
|
|||
if controller.getPin().len == PINLengthForStatusApp:
|
||||
controller.enterKeycardPin(controller.getPin())
|
||||
|
||||
method executeSecondaryCommand*(self: EnterPinState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: EnterPinState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.DisplayKeycardContent or
|
||||
|
@ -30,7 +30,7 @@ method executeSecondaryCommand*(self: EnterPinState, controller: Controller) =
|
|||
controller.setUsePinFromBiometrics(false)
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeTertiaryCommand*(self: EnterPinState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: EnterPinState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -8,12 +8,12 @@ proc newEnterPukState*(flowType: FlowType, backState: State): EnterPukState =
|
|||
proc delete*(self: EnterPukState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: EnterPukState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: EnterPukState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
if controller.getPuk().len == PUKLengthForStatusApp:
|
||||
controller.enterKeycardPuk(controller.getPuk())
|
||||
|
||||
method executeTertiaryCommand*(self: EnterPukState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: EnterPukState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ proc newEnterSeedPhraseState*(flowType: FlowType, backState: State): EnterSeedPh
|
|||
proc delete*(self: EnterSeedPhraseState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: EnterSeedPhraseState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: EnterSeedPhraseState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
self.verifiedSeedPhrase = controller.validSeedPhrase(controller.getSeedPhrase()) and
|
||||
controller.seedPhraseRefersToSelectedKeyPair(controller.getSeedPhrase())
|
||||
|
@ -32,7 +32,7 @@ method getNextPrimaryState*(self: EnterSeedPhraseState, controller: Controller):
|
|||
if not self.verifiedSeedPhrase:
|
||||
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
|
||||
self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
|
|
@ -8,14 +8,14 @@ proc newFactoryResetConfirmationDisplayMetadataState*(flowType: FlowType, backSt
|
|||
proc delete*(self: FactoryResetConfirmationDisplayMetadataState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset:
|
||||
controller.runGetAppInfoFlow(factoryReset = true)
|
||||
elif self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
controller.runGetAppInfoFlow(factoryReset = true)
|
||||
|
||||
method executeTertiaryCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: FactoryResetConfirmationDisplayMetadataState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
|
|
@ -8,14 +8,14 @@ proc newFactoryResetConfirmationState*(flowType: FlowType, backState: State): Fa
|
|||
proc delete*(self: FactoryResetConfirmationState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: FactoryResetConfirmationState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: FactoryResetConfirmationState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset:
|
||||
controller.runGetAppInfoFlow(factoryReset = true)
|
||||
elif self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
controller.runGetAppInfoFlow(factoryReset = true)
|
||||
|
||||
method executeTertiaryCommand*(self: FactoryResetConfirmationState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: FactoryResetConfirmationState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
|
|
@ -8,13 +8,13 @@ proc newFactoryResetSuccessState*(flowType: FlowType, backState: State): Factory
|
|||
proc delete*(self: FactoryResetSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: FactoryResetSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: FactoryResetSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
elif self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.runLoadAccountFlow()
|
||||
|
||||
method executeTertiaryCommand*(self: FactoryResetSuccessState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: FactoryResetSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ proc newInsertKeycardState*(flowType: FlowType, backState: State): InsertKeycard
|
|||
proc delete*(self: InsertKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: InsertKeycardState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: InsertKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executeTertiaryCommand*(self: InsertKeycardState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: InsertKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -8,10 +8,10 @@ proc newKeyPairMigrateFailureState*(flowType: FlowType, backState: State): KeyPa
|
|||
proc delete*(self: KeyPairMigrateFailureState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeyPairMigrateFailureState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeyPairMigrateFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: KeyPairMigrateFailureState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeyPairMigrateFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,7 +8,7 @@ proc newKeyPairMigrateSuccessState*(flowType: FlowType, backState: State): KeyPa
|
|||
proc delete*(self: KeyPairMigrateSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeyPairMigrateSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeyPairMigrateSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
if controller.getSelectedKeyPairIsProfile():
|
||||
|
|
|
@ -8,10 +8,10 @@ proc newKeycardAlreadyUnlockedState*(flowType: FlowType, backState: State): Keyc
|
|||
proc delete*(self: KeycardAlreadyUnlockedState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardAlreadyUnlockedState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,10 +8,10 @@ proc newChangingKeycardPairingCodeFailureState*(flowType: FlowType, backState: S
|
|||
proc delete*(self: ChangingKeycardPairingCodeFailureState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangePairingCode:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ChangingKeycardPairingCodeFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangePairingCode:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,10 +8,10 @@ proc newChangingKeycardPairingCodeSuccessState*(flowType: FlowType, backState: S
|
|||
proc delete*(self: ChangingKeycardPairingCodeSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangePairingCode:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ChangingKeycardPairingCodeSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangePairingCode:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,10 +8,10 @@ proc newChangingKeycardPinFailureState*(flowType: FlowType, backState: State): C
|
|||
proc delete*(self: ChangingKeycardPinFailureState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: ChangingKeycardPinFailureState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: ChangingKeycardPinFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPin:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: ChangingKeycardPinFailureState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ChangingKeycardPinFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPin:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,10 +8,10 @@ proc newChangingKeycardPinSuccessState*(flowType: FlowType, backState: State): C
|
|||
proc delete*(self: ChangingKeycardPinSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPin:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ChangingKeycardPinSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPin:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,10 +8,10 @@ proc newChangingKeycardPukFailureState*(flowType: FlowType, backState: State): C
|
|||
proc delete*(self: ChangingKeycardPukFailureState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: ChangingKeycardPukFailureState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: ChangingKeycardPukFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: ChangingKeycardPukFailureState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ChangingKeycardPukFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,10 +8,10 @@ proc newChangingKeycardPukSuccessState*(flowType: FlowType, backState: State): C
|
|||
proc delete*(self: ChangingKeycardPukSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ChangingKeycardPukSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,14 +8,14 @@ proc newKeycardEmptyMetadataState*(flowType: FlowType, backState: State): Keycar
|
|||
proc delete*(self: KeycardEmptyMetadataState) =
|
||||
self.State.delete
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardEmptyMetadataState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardEmptyMetadataState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.DisplayKeycardContent or
|
||||
self.flowType == FlowType.RenameKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
method executePrimaryCommand*(self: KeycardEmptyMetadataState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeycardEmptyMetadataState, controller: Controller) =
|
||||
if self.flowType == FlowType.DisplayKeycardContent or
|
||||
self.flowType == FlowType.RenameKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newKeycardEmptyState*(flowType: FlowType, backState: State): KeycardEmptySt
|
|||
proc delete*(self: KeycardEmptyState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeycardEmptyState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeycardEmptyState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.Authentication or
|
||||
self.flowType == FlowType.UnlockKeycard or
|
||||
|
@ -19,7 +19,7 @@ method executePrimaryCommand*(self: KeycardEmptyState, controller: Controller) =
|
|||
self.flowType == FlowType.ChangePairingCode:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardEmptyState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardEmptyState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.Authentication or
|
||||
self.flowType == FlowType.UnlockKeycard or
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newKeycardInsertedState*(flowType: FlowType, backState: State): KeycardInse
|
|||
proc delete*(self: KeycardInsertedState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: KeycardInsertedState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: KeycardInsertedState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
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, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardInsertedState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardInsertedState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -17,7 +17,7 @@ method getNextPrimaryState*(self: KeycardMetadataDisplayState, controller: Contr
|
|||
if self.flowType == FlowType.RenameKeycard:
|
||||
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
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.DisplayKeycardContent or
|
||||
|
|
|
@ -8,12 +8,12 @@ proc newKeycardNotEmptyState*(flowType: FlowType, backState: State): KeycardNotE
|
|||
proc delete*(self: KeycardNotEmptyState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeycardNotEmptyState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeycardNotEmptyState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
controller.runGetMetadataFlow(resolveAddress = true)
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardNotEmptyState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardNotEmptyState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ proc newKeycardRenameFailureState*(flowType: FlowType, backState: State): Keycar
|
|||
proc delete*(self: KeycardRenameFailureState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeycardRenameFailureState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeycardRenameFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.RenameKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardRenameFailureState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardRenameFailureState, controller: Controller) =
|
||||
if self.flowType == FlowType.RenameKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -8,10 +8,10 @@ proc newKeycardRenameSuccessState*(flowType: FlowType, backState: State): Keycar
|
|||
proc delete*(self: KeycardRenameSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: KeycardRenameSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: KeycardRenameSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.RenameKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: KeycardRenameSuccessState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: KeycardRenameSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.RenameKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -21,7 +21,7 @@ method getNextPrimaryState*(self: MaxPairingSlotsReachedState, controller: Contr
|
|||
controller.runSharedModuleFlow(FlowType.UnlockKeycard)
|
||||
return nil
|
||||
|
||||
method executeTertiaryCommand*(self: MaxPairingSlotsReachedState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: MaxPairingSlotsReachedState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -26,7 +26,7 @@ method getNextPrimaryState*(self: MaxPinRetriesReachedState, controller: Control
|
|||
controller.runSharedModuleFlow(FlowType.UnlockKeycard)
|
||||
return nil
|
||||
|
||||
method executeTertiaryCommand*(self: MaxPinRetriesReachedState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: MaxPinRetriesReachedState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.Authentication or
|
||||
self.flowType == FlowType.DisplayKeycardContent or
|
||||
|
|
|
@ -22,7 +22,7 @@ method getNextPrimaryState*(self: MaxPukRetriesReachedState, controller: Control
|
|||
if self.flowType == FlowType.UnlockKeycard:
|
||||
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
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -29,14 +29,14 @@ proc doMigration(self: MigratingKeyPairState, controller: Controller) =
|
|||
controller.runStoreMetadataFlow(selectedKeyPairDto.keycardName, controller.getPin(),
|
||||
controller.getSelectedKeyPairWalletPaths())
|
||||
|
||||
method executePrimaryCommand*(self: MigratingKeyPairState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: MigratingKeyPairState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if controller.getSelectedKeyPairIsProfile():
|
||||
controller.authenticateUser()
|
||||
else:
|
||||
self.doMigration(controller)
|
||||
|
||||
method executeSecondaryCommand*(self: MigratingKeyPairState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: MigratingKeyPairState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
self.doMigration(controller)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newNotKeycardState*(flowType: FlowType, backState: State): NotKeycardState
|
|||
proc delete*(self: NotKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeTertiaryCommand*(self: NotKeycardState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: NotKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -22,6 +22,6 @@ method getNextPrimaryState*(self: PinSetState, controller: Controller): State =
|
|||
if controller.getCurrentKeycardServiceFlow() == KCSFlowType.StoreMetadata:
|
||||
return createState(StateType.UnlockKeycardSuccess, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: PinSetState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: PinSetState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -21,7 +21,7 @@ method getNextPrimaryState*(self: PinVerifiedState, controller: Controller): Sta
|
|||
if self.flowType == FlowType.ChangePairingCode:
|
||||
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
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.DisplayKeycardContent or
|
||||
|
|
|
@ -8,12 +8,12 @@ proc newPluginReaderState*(flowType: FlowType, backState: State): PluginReaderSt
|
|||
proc delete*(self: PluginReaderState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: PluginReaderState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: PluginReaderState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executeTertiaryCommand*(self: PluginReaderState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: PluginReaderState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -8,12 +8,12 @@ proc newReadingKeycardState*(flowType: FlowType, backState: State): ReadingKeyca
|
|||
proc delete*(self: ReadingKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: ReadingKeycardState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: ReadingKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method executeTertiaryCommand*(self: ReadingKeycardState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: ReadingKeycardState, controller: Controller) =
|
||||
error "reading state must not be canceled"
|
||||
|
||||
method getNextSecondaryState*(self: ReadingKeycardState, controller: Controller): State =
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newRecognizedKeycardState*(flowType: FlowType, backState: State): Recognize
|
|||
proc delete*(self: RecognizedKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: RecognizedKeycardState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: RecognizedKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
if not self.getBackState.isNil and self.getBackState.stateType == StateType.SelectExistingKeyPair:
|
||||
controller.cancelCurrentFlow()
|
||||
|
@ -30,5 +30,5 @@ method getNextSecondaryState*(self: RecognizedKeycardState, controller: Controll
|
|||
self.flowType == FlowType.ChangePairingCode:
|
||||
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"
|
|
@ -10,7 +10,7 @@ proc newRenamingKeycardState*(flowType: FlowType, backState: State): RenamingKey
|
|||
proc delete*(self: RenamingKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: RenamingKeycardState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: RenamingKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.RenameKeycard:
|
||||
let md = controller.getMetadataFromKeycard()
|
||||
let paths = md.walletAccounts.map(a => a.path)
|
||||
|
|
|
@ -8,11 +8,11 @@ proc newRepeatPinState*(flowType: FlowType, backState: State): RepeatPinState =
|
|||
proc delete*(self: RepeatPinState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: RepeatPinState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: RepeatPinState, controller: Controller) =
|
||||
controller.setPin("")
|
||||
controller.setPinMatch(false)
|
||||
|
||||
method executeSecondaryCommand*(self: RepeatPinState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: RepeatPinState, controller: Controller) =
|
||||
if not controller.getPinMatch():
|
||||
return
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
|
@ -26,7 +26,7 @@ method getNextSecondaryState*(self: RepeatPinState, controller: Controller): Sta
|
|||
if self.flowType == FlowType.ChangeKeycardPin:
|
||||
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
|
||||
self.flowType == FlowType.UnlockKeycard or
|
||||
self.flowType == FlowType.ChangeKeycardPin:
|
||||
|
|
|
@ -8,7 +8,7 @@ proc newRepeatPukState*(flowType: FlowType, backState: State): RepeatPukState =
|
|||
proc delete*(self: RepeatPukState) =
|
||||
self.State.delete
|
||||
|
||||
method executeBackCommand*(self: RepeatPukState, controller: Controller) =
|
||||
method executePreBackStateCommand*(self: RepeatPukState, controller: Controller) =
|
||||
controller.setPuk("")
|
||||
controller.setPukMatch(false)
|
||||
|
||||
|
@ -18,6 +18,6 @@ method getNextSecondaryState*(self: RepeatPukState, controller: Controller): Sta
|
|||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
return createState(StateType.ChangingKeycardPuk, self.flowType, nil)
|
||||
|
||||
method executeTertiaryCommand*(self: RepeatPukState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: RepeatPukState, controller: Controller) =
|
||||
if self.flowType == FlowType.ChangeKeycardPuk:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,7 +8,7 @@ proc newSeedPhraseDisplayState*(flowType: FlowType, backState: State): SeedPhras
|
|||
proc delete*(self: SeedPhraseDisplayState) =
|
||||
self.State.delete
|
||||
|
||||
method executeTertiaryCommand*(self: SeedPhraseDisplayState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: SeedPhraseDisplayState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ proc newSeedPhraseEnterWordsState*(flowType: FlowType, backState: State): SeedPh
|
|||
proc delete*(self: SeedPhraseEnterWordsState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
||||
let mnemonic = controller.getMnemonic()
|
||||
controller.setSeedPhrase(mnemonic)
|
||||
controller.storeSeedPhraseToKeycard(mnemonic.split(" ").len, mnemonic)
|
||||
|
||||
method executeTertiaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ proc newSelectExistingKeyPairState*(flowType: FlowType, backState: State): Selec
|
|||
proc delete*(self: SelectExistingKeyPairState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: SelectExistingKeyPairState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: SelectExistingKeyPairState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.runLoadAccountFlow()
|
||||
|
||||
method executeTertiaryCommand*(self: SelectExistingKeyPairState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: SelectExistingKeyPairState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -111,32 +111,48 @@ method getBackState*(self: State): State {.inline base.} =
|
|||
method displayBackButton*(self: State): bool {.inline base.} =
|
||||
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.} =
|
||||
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.} =
|
||||
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.} =
|
||||
return nil
|
||||
|
||||
## This method is executed in case "back" button is clicked
|
||||
method executeBackCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
## This method is executed before back state is set, if "back" action is triggered
|
||||
method executePreBackStateCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
discard
|
||||
|
||||
## This method is executed in case "primary" action is triggered
|
||||
method executePrimaryCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
## This method is executed after back state is set, if "back" action is triggered
|
||||
method executePostBackStateCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
discard
|
||||
|
||||
## This method is executed in case "secondary" action is triggered
|
||||
method executeSecondaryCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
## This method is executed before primary state is set, if "primary" action is triggered
|
||||
method executePrePrimaryStateCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
discard
|
||||
|
||||
## This method is executed in case "tertiary" action is triggered
|
||||
method executeTertiaryCommand*(self: State, controller: Controller) {.inline base.} =
|
||||
## This method is executed after primary state is set, if "primary" action is triggered
|
||||
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
|
||||
|
||||
## This method is used for handling aync responses for keycard related states
|
||||
|
|
|
@ -16,6 +16,6 @@ method getNextSecondaryState*(self: UnlockKeycardOptionsState, controller: Contr
|
|||
if self.flowType == FlowType.UnlockKeycard:
|
||||
return createState(StateType.EnterPuk, self.flowType, self)
|
||||
|
||||
method executeTertiaryCommand*(self: UnlockKeycardOptionsState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: UnlockKeycardOptionsState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,10 +8,10 @@ proc newUnlockKeycardSuccessState*(flowType: FlowType, backState: State): Unlock
|
|||
proc delete*(self: UnlockKeycardSuccessState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: UnlockKeycardSuccessState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: UnlockKeycardSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: UnlockKeycardSuccessState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: UnlockKeycardSuccessState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
|
@ -10,7 +10,7 @@ proc newWrongBiometricsPasswordState*(flowType: FlowType, backState: State): Wro
|
|||
proc delete*(self: WrongBiometricsPasswordState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: WrongBiometricsPasswordState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: WrongBiometricsPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = false))
|
||||
let password = controller.getPassword()
|
||||
|
@ -21,7 +21,7 @@ method executePrimaryCommand*(self: WrongBiometricsPasswordState, controller: Co
|
|||
else:
|
||||
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:
|
||||
controller.setPassword("")
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -8,7 +8,7 @@ proc newWrongKeycardState*(flowType: FlowType, backState: State): WrongKeycardSt
|
|||
proc delete*(self: WrongKeycardState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: WrongKeycardState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: WrongKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard or
|
||||
self.flowType == FlowType.RenameKeycard or
|
||||
self.flowType == FlowType.ChangeKeycardPin or
|
||||
|
@ -16,7 +16,7 @@ method executePrimaryCommand*(self: WrongKeycardState, controller: Controller) =
|
|||
self.flowType == FlowType.ChangePairingCode:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true)
|
||||
|
||||
method executeTertiaryCommand*(self: WrongKeycardState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: WrongKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication or
|
||||
self.flowType == FlowType.UnlockKeycard or
|
||||
self.flowType == FlowType.RenameKeycard or
|
||||
|
|
|
@ -14,7 +14,7 @@ method getNextPrimaryState*(self: WrongKeychainPinState, controller: Controller)
|
|||
controller.enterKeycardPin(controller.getPin())
|
||||
return nil
|
||||
|
||||
method executeTertiaryCommand*(self: WrongKeychainPinState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: WrongKeychainPinState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ proc newWrongPasswordState*(flowType: FlowType, backState: State): WrongPassword
|
|||
proc delete*(self: WrongPasswordState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: WrongPasswordState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: WrongPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongPassword, add = false))
|
||||
let password = controller.getPassword()
|
||||
|
@ -20,11 +20,11 @@ method executePrimaryCommand*(self: WrongPasswordState, controller: Controller)
|
|||
else:
|
||||
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:
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeTertiaryCommand*(self: WrongPasswordState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: WrongPasswordState, controller: Controller) =
|
||||
if self.flowType == FlowType.Authentication:
|
||||
controller.setPassword("")
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
|
@ -22,7 +22,7 @@ method getNextPrimaryState*(self: WrongPinState, controller: Controller): State
|
|||
self.flowType == FlowType.ChangePairingCode:
|
||||
controller.runSharedModuleFlow(FlowType.FactoryReset)
|
||||
|
||||
method executeSecondaryCommand*(self: WrongPinState, controller: Controller) =
|
||||
method executePreSecondaryStateCommand*(self: WrongPinState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.DisplayKeycardContent or
|
||||
|
@ -36,7 +36,7 @@ method executeSecondaryCommand*(self: WrongPinState, controller: Controller) =
|
|||
controller.setUsePinFromBiometrics(false)
|
||||
controller.tryToObtainDataFromKeychain()
|
||||
|
||||
method executeTertiaryCommand*(self: WrongPinState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: WrongPinState, controller: Controller) =
|
||||
if self.flowType == FlowType.FactoryReset or
|
||||
self.flowType == FlowType.SetupNewKeycard or
|
||||
self.flowType == FlowType.Authentication or
|
||||
|
|
|
@ -8,12 +8,12 @@ proc newWrongPukState*(flowType: FlowType, backState: State): WrongPukState =
|
|||
proc delete*(self: WrongPukState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: WrongPukState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: WrongPukState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
if controller.getPuk().len == PUKLengthForStatusApp:
|
||||
controller.enterKeycardPuk(controller.getPuk())
|
||||
|
||||
method executeTertiaryCommand*(self: WrongPukState, controller: Controller) =
|
||||
method executePreTertiaryStateCommand*(self: WrongPukState, controller: Controller) =
|
||||
if self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ proc newWrongSeedPhraseState*(flowType: FlowType, backState: State): WrongSeedPh
|
|||
proc delete*(self: WrongSeedPhraseState) =
|
||||
self.State.delete
|
||||
|
||||
method executePrimaryCommand*(self: WrongSeedPhraseState, controller: Controller) =
|
||||
method executePrePrimaryStateCommand*(self: WrongSeedPhraseState, controller: Controller) =
|
||||
if self.flowType == FlowType.SetupNewKeycard:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WrongSeedPhrase, add = false))
|
||||
sleep(500) # just to shortly remove text on the UI side
|
||||
|
@ -32,7 +32,7 @@ method executePrimaryCommand*(self: WrongSeedPhraseState, controller: Controller
|
|||
else:
|
||||
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
|
||||
self.flowType == FlowType.UnlockKeycard:
|
||||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
|
|
|
@ -166,10 +166,11 @@ method onBackActionClicked*[T](self: Module[T]) =
|
|||
error "sm_cannot resolve current state"
|
||||
return
|
||||
debug "sm_back_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
|
||||
currStateObj.executeBackCommand(self.controller)
|
||||
currStateObj.executePreBackStateCommand(self.controller)
|
||||
let backState = currStateObj.getBackState()
|
||||
self.preStateActivities(backState.flowType(), backState.stateType())
|
||||
self.view.setCurrentState(backState)
|
||||
currStateObj.executePostBackStateCommand(self.controller)
|
||||
debug "sm_back_action - set state", setCurrFlow=backState.flowType(), newCurrState=backState.stateType()
|
||||
currStateObj.delete()
|
||||
|
||||
|
@ -179,12 +180,13 @@ method onPrimaryActionClicked*[T](self: Module[T]) =
|
|||
error "sm_cannot resolve current state"
|
||||
return
|
||||
debug "sm_primary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
|
||||
currStateObj.executePrimaryCommand(self.controller)
|
||||
currStateObj.executePrePrimaryStateCommand(self.controller)
|
||||
let nextState = currStateObj.getNextPrimaryState(self.controller)
|
||||
if nextState.isNil:
|
||||
return
|
||||
self.preStateActivities(nextState.flowType(), nextState.stateType())
|
||||
self.view.setCurrentState(nextState)
|
||||
currStateObj.executePostPrimaryStateCommand(self.controller)
|
||||
debug "sm_primary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType()
|
||||
|
||||
method onSecondaryActionClicked*[T](self: Module[T]) =
|
||||
|
@ -193,12 +195,13 @@ method onSecondaryActionClicked*[T](self: Module[T]) =
|
|||
error "sm_cannot resolve current state"
|
||||
return
|
||||
debug "sm_secondary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
|
||||
currStateObj.executeSecondaryCommand(self.controller)
|
||||
currStateObj.executePreSecondaryStateCommand(self.controller)
|
||||
let nextState = currStateObj.getNextSecondaryState(self.controller)
|
||||
if nextState.isNil:
|
||||
return
|
||||
self.preStateActivities(nextState.flowType(), nextState.stateType())
|
||||
self.view.setCurrentState(nextState)
|
||||
currStateObj.executePostSecondaryStateCommand(self.controller)
|
||||
debug "sm_secondary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType()
|
||||
|
||||
method onTertiaryActionClicked*[T](self: Module[T]) =
|
||||
|
@ -207,12 +210,13 @@ method onTertiaryActionClicked*[T](self: Module[T]) =
|
|||
error "sm_cannot resolve current state"
|
||||
return
|
||||
debug "sm_tertiary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType()
|
||||
currStateObj.executeTertiaryCommand(self.controller)
|
||||
currStateObj.executePreTertiaryStateCommand(self.controller)
|
||||
let nextState = currStateObj.getNextTertiaryState(self.controller)
|
||||
if nextState.isNil:
|
||||
return
|
||||
self.preStateActivities(nextState.flowType(), nextState.stateType())
|
||||
self.view.setCurrentState(nextState)
|
||||
currStateObj.executePostTertiaryStateCommand(self.controller)
|
||||
debug "sm_tertiary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType()
|
||||
|
||||
method onKeycardResponse*[T](self: Module[T], keycardFlowType: string, keycardEvent: KeycardEvent) =
|
||||
|
|
Loading…
Reference in New Issue