diff --git a/src/app/modules/main/profile_section/keycard/io_interface.nim b/src/app/modules/main/profile_section/keycard/io_interface.nim index 4ef39871b3..a78af6d27a 100644 --- a/src/app/modules/main/profile_section/keycard/io_interface.nim +++ b/src/app/modules/main/profile_section/keycard/io_interface.nim @@ -28,6 +28,15 @@ method onSharedKeycarModuleFlowTerminated*(self: AccessInterface, lastStepInTheC method runSetupKeycardPopup*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") +method runGenerateSeedPhrasePopup*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method runImportOrRestoreViaSeedPhrasePopup*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method runImportFromKeycardToAppPopup*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + method runUnlockKeycardPopup*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/keycard/module.nim b/src/app/modules/main/profile_section/keycard/module.nim index ce2e039120..816c319b95 100644 --- a/src/app/modules/main/profile_section/keycard/module.nim +++ b/src/app/modules/main/profile_section/keycard/module.nim @@ -104,6 +104,15 @@ method runSetupKeycardPopup*(self: Module) = return self.keycardSharedModule.runFlow(keycard_shared_module.FlowType.SetupNewKeycard) +method runGenerateSeedPhrasePopup*(self: Module) = + info "TODO: Generate a seed phrase..." + +method runImportOrRestoreViaSeedPhrasePopup*(self: Module) = + info "TODO: Import or restore via a seed phrase..." + +method runImportFromKeycardToAppPopup*(self: Module) = + info "TODO: Import from Keycard to Status Desktop..." + method runUnlockKeycardPopup*(self: Module) = self.createSharedKeycardModule() if self.keycardSharedModule.isNil: @@ -111,7 +120,10 @@ method runUnlockKeycardPopup*(self: Module) = self.keycardSharedModule.runFlow(keycard_shared_module.FlowType.UnlockKeycard) method runDisplayKeycardContentPopup*(self: Module) = - info "TODO: Run display keycard content..." + self.createSharedKeycardModule() + if self.keycardSharedModule.isNil: + return + self.keycardSharedModule.runFlow(keycard_shared_module.FlowType.DisplayKeycardContent) method runFactoryResetPopup*(self: Module) = self.createSharedKeycardModule() diff --git a/src/app/modules/main/profile_section/keycard/view.nim b/src/app/modules/main/profile_section/keycard/view.nim index 1837dfa271..dc15cbb52e 100644 --- a/src/app/modules/main/profile_section/keycard/view.nim +++ b/src/app/modules/main/profile_section/keycard/view.nim @@ -34,6 +34,15 @@ QtObject: proc runSetupKeycardPopup*(self: View) {.slot.} = self.delegate.runSetupKeycardPopup() + proc runGenerateSeedPhrasePopup*(self: View) {.slot.} = + self.delegate.runGenerateSeedPhrasePopup() + + proc runImportOrRestoreViaSeedPhrasePopup*(self: View) {.slot.} = + self.delegate.runImportOrRestoreViaSeedPhrasePopup() + + proc runImportFromKeycardToAppPopup*(self: View) {.slot.} = + self.delegate.runImportFromKeycardToAppPopup() + proc runUnlockKeycardPopup*(self: View) {.slot.} = self.delegate.runUnlockKeycardPopup() diff --git a/src/app/modules/shared_modules/keycard_popup/internal/enter_pin_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/enter_pin_state.nim index 210c93a594..b8811a4300 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/enter_pin_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/enter_pin_state.nim @@ -15,10 +15,13 @@ method getNextPrimaryState*(self: EnterPinState, controller: Controller): State if self.flowType == FlowType.Authentication: if controller.getPin().len == PINLengthForStatusApp: controller.enterKeycardPin(controller.getPin()) + if self.flowType == FlowType.DisplayKeycardContent: + controller.runSharedModuleFlow(FlowType.FactoryReset) method executeSecondaryCommand*(self: EnterPinState, controller: Controller) = if self.flowType == FlowType.SetupNewKeycard or - self.flowType == FlowType.FactoryReset: + self.flowType == FlowType.FactoryReset or + self.flowType == FlowType.DisplayKeycardContent: if controller.getPin().len == PINLengthForStatusApp: controller.enterKeycardPin(controller.getPin()) if self.flowType == FlowType.Authentication: @@ -28,7 +31,8 @@ method executeSecondaryCommand*(self: EnterPinState, controller: Controller) = method executeTertiaryCommand*(self: EnterPinState, controller: Controller) = if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or - self.flowType == FlowType.Authentication: + self.flowType == FlowType.Authentication or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, keycardEvent: KeycardEvent, @@ -95,4 +99,22 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke if keycardFlowType == ResponseTypeValueKeycardFlowResult: if keycardEvent.error.len == 0: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) - return nil \ No newline at end of file + return nil + if self.flowType == FlowType.DisplayKeycardContent: + if keycardFlowType == ResponseTypeValueEnterPIN and + keycardEvent.error.len > 0 and + keycardEvent.error == ErrorPIN: + controller.setKeycardData($keycardEvent.pinRetries) + if keycardEvent.pinRetries > 0: + return createState(StateType.WrongPin, self.flowType, nil) + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueEnterPIN and + keycardEvent.error.len == 0: + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueEnterPUK and + keycardEvent.error.len == 0: + if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0: + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueKeycardFlowResult: + controller.setMetadataFromKeycard(keycardEvent.cardMetadata, updateKeyPair = true) + return createState(StateType.PinVerified, self.flowType, nil) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/insert_keycard_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/insert_keycard_state.nim index a55a43a027..ee12cb7235 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/insert_keycard_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/insert_keycard_state.nim @@ -17,7 +17,8 @@ method executeTertiaryCommand*(self: InsertKeycardState, controller: Controller) if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) method resolveKeycardNextState*(self: InsertKeycardState, keycardFlowType: string, keycardEvent: KeycardEvent, diff --git a/src/app/modules/shared_modules/keycard_popup/internal/keycard_empty_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/keycard_empty_state.nim index 2efc63ef11..9b04d32f6a 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/keycard_empty_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/keycard_empty_state.nim @@ -8,9 +8,16 @@ proc newKeycardEmptyState*(flowType: FlowType, backState: State): KeycardEmptySt proc delete*(self: KeycardEmptyState) = self.State.delete +method executePrimaryCommand*(self: KeycardEmptyState, controller: Controller) = + if self.flowType == FlowType.FactoryReset or + self.flowType == FlowType.Authentication or + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: + controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) + method executeTertiaryCommand*(self: KeycardEmptyState, controller: Controller) = if self.flowType == FlowType.FactoryReset or - self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/keycard_inserted_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/keycard_inserted_state.nim index e918bb7da2..df1bf46857 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/keycard_inserted_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/keycard_inserted_state.nim @@ -24,5 +24,6 @@ method executeTertiaryCommand*(self: KeycardInsertedState, controller: Controlle if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) diff --git a/src/app/modules/shared_modules/keycard_popup/internal/keycard_metadata_display_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/keycard_metadata_display_state.nim index ce88c38fed..4052b32546 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/keycard_metadata_display_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/keycard_metadata_display_state.nim @@ -12,9 +12,11 @@ method getNextPrimaryState*(self: KeycardMetadataDisplayState, controller: Contr if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard: return createState(StateType.FactoryResetConfirmationDisplayMetadata, self.flowType, self) - return nil + if self.flowType == FlowType.DisplayKeycardContent: + controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) method executeTertiaryCommand*(self: KeycardMetadataDisplayState, controller: Controller) = if self.flowType == FlowType.FactoryReset or - self.flowType == FlowType.SetupNewKeycard: + self.flowType == FlowType.SetupNewKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/max_pairing_slots_reached_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/max_pairing_slots_reached_state.nim index d292508999..5ebb3b34d9 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/max_pairing_slots_reached_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/max_pairing_slots_reached_state.nim @@ -12,13 +12,15 @@ method getNextPrimaryState*(self: MaxPairingSlotsReachedState, controller: Contr if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard: return createState(StateType.FactoryResetConfirmation, self.flowType, self) - if self.flowType == FlowType.Authentication: - controller.runSharedModuleFlow(FlowType.UnlockKeycard) + if self.flowType == FlowType.Authentication or + self.flowType == FlowType.DisplayKeycardContent: + controller.runSharedModuleFlow(FlowType.UnlockKeycard) return nil method executeTertiaryCommand*(self: MaxPairingSlotsReachedState, controller: Controller) = if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/max_pin_retries_reached_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/max_pin_retries_reached_state.nim index 783a59beb6..9dcc45b1a5 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/max_pin_retries_reached_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/max_pin_retries_reached_state.nim @@ -9,7 +9,8 @@ proc delete*(self: MaxPinRetriesReachedState) = self.State.delete method getNextPrimaryState*(self: MaxPinRetriesReachedState, controller: Controller): State = - if self.flowType == FlowType.FactoryReset: + if self.flowType == FlowType.FactoryReset or + self.flowType == FlowType.DisplayKeycardContent: controller.runSharedModuleFlow(FlowType.UnlockKeycard) if self.flowType == FlowType.SetupNewKeycard: let currValue = extractPredefinedKeycardDataToNumber(controller.getKeycardData()) @@ -23,7 +24,8 @@ method getNextPrimaryState*(self: MaxPinRetriesReachedState, controller: Control method executeTertiaryCommand*(self: MaxPinRetriesReachedState, controller: Controller) = if self.flowType == FlowType.FactoryReset or - self.flowType == FlowType.Authentication: + self.flowType == FlowType.Authentication or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) if self.flowType == FlowType.SetupNewKeycard: controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseUnlockLabelForLockedState, add = false)) diff --git a/src/app/modules/shared_modules/keycard_popup/internal/max_puk_retries_reached_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/max_puk_retries_reached_state.nim index 714f0965cb..f672a79095 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/max_puk_retries_reached_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/max_puk_retries_reached_state.nim @@ -12,8 +12,9 @@ method getNextPrimaryState*(self: MaxPukRetriesReachedState, controller: Control if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard: return createState(StateType.FactoryResetConfirmation, self.flowType, self) - if self.flowType == FlowType.Authentication: - controller.runSharedModuleFlow(FlowType.UnlockKeycard) + if self.flowType == FlowType.Authentication or + self.flowType == FlowType.DisplayKeycardContent: + controller.runSharedModuleFlow(FlowType.UnlockKeycard) if self.flowType == FlowType.UnlockKeycard: return createState(StateType.EnterSeedPhrase, self.flowType, self) @@ -21,5 +22,6 @@ method executeTertiaryCommand*(self: MaxPukRetriesReachedState, controller: Cont if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/not_keycard_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/not_keycard_state.nim index 4380b1a3a9..46814e4fc6 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/not_keycard_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/not_keycard_state.nim @@ -12,5 +12,6 @@ method executeTertiaryCommand*(self: NotKeycardState, controller: Controller) = if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/pin_verified_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/pin_verified_state.nim index d14985506d..de0b35cb86 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/pin_verified_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/pin_verified_state.nim @@ -10,11 +10,13 @@ proc delete*(self: PinVerifiedState) = method getNextPrimaryState*(self: PinVerifiedState, controller: Controller): State = if self.flowType == FlowType.FactoryReset or - self.flowType == FlowType.SetupNewKeycard: + self.flowType == FlowType.SetupNewKeycard or + self.flowType == FlowType.DisplayKeycardContent: return createState(StateType.KeycardMetadataDisplay, self.flowType, nil) return nil method executeTertiaryCommand*(self: PinVerifiedState, controller: Controller) = if self.flowType == FlowType.FactoryReset or - self.flowType == FlowType.SetupNewKeycard: + self.flowType == FlowType.SetupNewKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/plugin_reader_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/plugin_reader_state.nim index f1cb731923..7da70a686e 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/plugin_reader_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/plugin_reader_state.nim @@ -17,7 +17,8 @@ method executeTertiaryCommand*(self: PluginReaderState, controller: Controller) if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) method resolveKeycardNextState*(self: PluginReaderState, keycardFlowType: string, keycardEvent: KeycardEvent, diff --git a/src/app/modules/shared_modules/keycard_popup/internal/reading_keycard_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/reading_keycard_state.nim index ac5a5d7741..1ef64dd206 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/reading_keycard_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/reading_keycard_state.nim @@ -17,7 +17,8 @@ method executeTertiaryCommand*(self: ReadingKeycardState, controller: Controller if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or self.flowType == FlowType.Authentication or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) method getNextSecondaryState*(self: ReadingKeycardState, controller: Controller): State = diff --git a/src/app/modules/shared_modules/keycard_popup/internal/recognized_keycard_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/recognized_keycard_state.nim index 1ac8bdd4e6..052817553e 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/recognized_keycard_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/recognized_keycard_state.nim @@ -23,9 +23,12 @@ method getNextSecondaryState*(self: RecognizedKeycardState, controller: Controll return createState(StateType.CreatePin, self.flowType, self.getBackState) if self.flowType == FlowType.UnlockKeycard: return createState(StateType.UnlockKeycardOptions, self.flowType, nil) + if self.flowType == FlowType.DisplayKeycardContent: + return createState(StateType.EnterPin, self.flowType, nil) method executeTertiaryCommand*(self: RecognizedKeycardState, controller: Controller) = if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or - self.flowType == FlowType.UnlockKeycard: + self.flowType == FlowType.UnlockKeycard or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/internal/state_factory.nim b/src/app/modules/shared_modules/keycard_popup/internal/state_factory.nim index bb982626fc..ce2622cc1e 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/state_factory.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/state_factory.nim @@ -17,6 +17,7 @@ type PredefinedKeycardData* {.pure.} = enum WrongPassword = 8 OfferPukForUnlock = 16 UseUnlockLabelForLockedState = 32 + UseGeneralMessageForLockedState = 64 # Forward declaration proc createState*(stateToBeCreated: StateType, flowType: FlowType, backState: State): State @@ -194,7 +195,8 @@ proc ensureReaderAndCardPresence*(state: State, keycardFlowType: string, keycard ## Handling factory reset or authentication or unlock keycard flow if state.flowType == FlowType.FactoryReset or state.flowType == FlowType.Authentication or - state.flowType == FlowType.UnlockKeycard: + state.flowType == FlowType.UnlockKeycard or + state.flowType == FlowType.DisplayKeycardContent: if keycardFlowType == ResponseTypeValueKeycardFlowResult and keycardEvent.error.len > 0 and keycardEvent.error == ErrorConnection: @@ -277,8 +279,10 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy if keycardEvent.error == ErrorHasKeys: return createState(StateType.KeycardNotEmpty, state.flowType, nil) if keycardEvent.error == ErrorFreePairingSlots: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) return createState(StateType.MaxPairingSlotsReached, state.flowType, nil) if keycardEvent.error == ErrorPUKRetries: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) return createState(StateType.MaxPukRetriesReached, state.flowType, nil) if keycardFlowType == ResponseTypeValueEnterPIN: if controller.getCurrentKeycardServiceFlow() == KCSFlowType.GetMetadata: @@ -287,6 +291,7 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy if keycardFlowType == ResponseTypeValueEnterPUK and keycardEvent.error.len == 0: if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) return createState(StateType.MaxPinRetriesReached, state.flowType, nil) if keycardFlowType == ResponseTypeValueKeycardFlowResult and keycardEvent.error.len > 0: @@ -313,9 +318,11 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy if keycardEvent.error == ErrorNoKeys: return createState(StateType.KeycardEmpty, state.flowType, nil) if keycardEvent.error == ErrorFreePairingSlots: - return createState(StateType.MaxPairingSlotsReached, state.flowType, nil) + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) + return createState(StateType.MaxPairingSlotsReached, state.flowType, nil) if keycardEvent.error == ErrorPUKRetries: - return createState(StateType.MaxPukRetriesReached, state.flowType, nil) + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) + return createState(StateType.MaxPukRetriesReached, state.flowType, nil) if keycardFlowType == ResponseTypeValueEnterPIN: if keycardEvent.keyUid == controller.getKeyUidWhichIsBeingAuthenticating(): if controller.loggedInUserUsesBiometricLogin(): @@ -326,6 +333,7 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy if not controller.usePinFromBiometrics(): return createState(StateType.WrongKeychainPin, state.flowType, nil) return createState(StateType.WrongPin, state.flowType, nil) + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) return createState(StateType.MaxPinRetriesReached, state.flowType, nil) return createState(StateType.BiometricsReadyToSign, state.flowType, nil) return createState(StateType.EnterPin, state.flowType, nil) @@ -333,6 +341,7 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy if keycardFlowType == ResponseTypeValueEnterPUK and keycardEvent.error.len == 0: if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) return createState(StateType.MaxPinRetriesReached, state.flowType, nil) if keycardFlowType == ResponseTypeValueKeycardFlowResult: if keycardEvent.error.len == 0: @@ -363,4 +372,30 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy if keycardFlowType == ResponseTypeValueKeycardFlowResult or keycardEvent.error.len > 0: if keycardEvent.error == ErrorNoKeys: - return createState(StateType.KeycardEmpty, state.flowType, nil) \ No newline at end of file + return createState(StateType.KeycardEmpty, state.flowType, nil) + + if state.flowType == FlowType.DisplayKeycardContent: + if keycardFlowType == ResponseTypeValueEnterPIN and + keycardEvent.error.len == 0: + return createState(StateType.RecognizedKeycard, state.flowType, nil) + if keycardFlowType == ResponseTypeValueEnterPUK and + keycardEvent.error.len == 0: + if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) + return createState(StateType.MaxPinRetriesReached, state.flowType, nil) + if keycardFlowType == ResponseTypeValueSwapCard and + keycardEvent.error.len > 0: + if keycardEvent.error == ErrorNotAKeycard: + return createState(StateType.NotKeycard, state.flowType, nil) + if keycardEvent.error == ErrorNoKeys: + return createState(StateType.KeycardEmpty, state.flowType, nil) + if keycardEvent.error == ErrorFreePairingSlots: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) + return createState(StateType.MaxPairingSlotsReached, state.flowType, nil) + if keycardEvent.error == ErrorPUKRetries: + controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseGeneralMessageForLockedState, add = true)) + return createState(StateType.MaxPukRetriesReached, state.flowType, nil) + if keycardFlowType == ResponseTypeValueKeycardFlowResult or + keycardEvent.error.len > 0: + if keycardEvent.error == ErrorNoKeys: + return createState(StateType.KeycardEmpty, state.flowType, nil) diff --git a/src/app/modules/shared_modules/keycard_popup/internal/wrong_pin_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/wrong_pin_state.nim index 357cda6bd3..3ed4f67e61 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/wrong_pin_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/wrong_pin_state.nim @@ -15,11 +15,13 @@ method getNextPrimaryState*(self: WrongPinState, controller: Controller): State if self.flowType == FlowType.Authentication: if controller.getPin().len == PINLengthForStatusApp: controller.enterKeycardPin(controller.getPin()) - return nil + if self.flowType == FlowType.DisplayKeycardContent: + controller.runSharedModuleFlow(FlowType.FactoryReset) method executeSecondaryCommand*(self: WrongPinState, controller: Controller) = if self.flowType == FlowType.FactoryReset or - self.flowType == FlowType.SetupNewKeycard: + self.flowType == FlowType.SetupNewKeycard or + self.flowType == FlowType.DisplayKeycardContent: if controller.getPin().len == PINLengthForStatusApp: controller.enterKeycardPin(controller.getPin()) if self.flowType == FlowType.Authentication: @@ -29,7 +31,8 @@ method executeSecondaryCommand*(self: WrongPinState, controller: Controller) = method executeTertiaryCommand*(self: WrongPinState, controller: Controller) = if self.flowType == FlowType.FactoryReset or self.flowType == FlowType.SetupNewKeycard or - self.flowType == FlowType.Authentication: + self.flowType == FlowType.Authentication or + self.flowType == FlowType.DisplayKeycardContent: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, keycardEvent: KeycardEvent, @@ -84,4 +87,19 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke if keycardFlowType == ResponseTypeValueKeycardFlowResult: if keycardEvent.error.len == 0: controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) - return nil \ No newline at end of file + return nil + if self.flowType == FlowType.DisplayKeycardContent: + if keycardFlowType == ResponseTypeValueEnterPIN and + keycardEvent.error.len > 0 and + keycardEvent.error == ErrorPIN: + controller.setKeycardData($keycardEvent.pinRetries) + if keycardEvent.pinRetries > 0: + return self + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueEnterPUK and + keycardEvent.error.len == 0: + if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0: + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueKeycardFlowResult: + controller.setMetadataFromKeycard(keycardEvent.cardMetadata, updateKeyPair = true) + return createState(StateType.PinVerified, self.flowType, nil) \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/io_interface.nim b/src/app/modules/shared_modules/keycard_popup/io_interface.nim index f3a3aa335f..0d82e676bd 100644 --- a/src/app/modules/shared_modules/keycard_popup/io_interface.nim +++ b/src/app/modules/shared_modules/keycard_popup/io_interface.nim @@ -36,6 +36,7 @@ type FlowType* {.pure.} = enum SetupNewKeycard = "SetupNewKeycard" Authentication = "Authentication" UnlockKeycard = "UnlockKeycard" + DisplayKeycardContent = "DisplayKeycardContent" type AccessInterface* {.pure inheritable.} = ref object of RootObj diff --git a/src/app/modules/shared_modules/keycard_popup/module.nim b/src/app/modules/shared_modules/keycard_popup/module.nim index dd64ba9511..2d9dbae84e 100644 --- a/src/app/modules/shared_modules/keycard_popup/module.nim +++ b/src/app/modules/shared_modules/keycard_popup/module.nim @@ -317,13 +317,13 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path self.initialized = true self.controller.init() if flowToRun == FlowType.FactoryReset: - let items = self.buildKeyPairsList(excludeAlreadyMigratedPairs = false) - self.view.createKeyPairModel(items) + self.view.createKeyPairStoredOnKeycard() self.tmpLocalState = newReadingKeycardState(flowToRun, nil) self.controller.runGetMetadataFlow(resolveAddress = true) return if flowToRun == FlowType.SetupNewKeycard: let items = self.buildKeyPairsList(excludeAlreadyMigratedPairs = true) + self.view.createKeyPairStoredOnKeycard() self.view.createKeyPairModel(items) self.view.setCurrentState(newSelectExistingKeyPairState(flowToRun, nil)) self.controller.readyToDisplayPopup() @@ -346,6 +346,11 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path self.tmpLocalState = newReadingKeycardState(flowToRun, nil) self.controller.runGetMetadataFlow(resolveAddress = true) return + if flowToRun == FlowType.DisplayKeycardContent: + self.view.createKeyPairStoredOnKeycard() + self.tmpLocalState = newReadingKeycardState(flowToRun, nil) + self.controller.runGetMetadataFlow(resolveAddress = true) + return method setSelectedKeyPair*[T](self: Module[T], item: KeyPairItem) = var paths: seq[string] diff --git a/src/app/modules/shared_modules/keycard_popup/view.nim b/src/app/modules/shared_modules/keycard_popup/view.nim index f3ea2695ae..aa8351c821 100644 --- a/src/app/modules/shared_modules/keycard_popup/view.nim +++ b/src/app/modules/shared_modules/keycard_popup/view.nim @@ -100,6 +100,12 @@ QtObject: read = getKeyPairModel notify = keyPairModelChanged + proc createKeyPairStoredOnKeycard*(self: View) = + if self.keyPairStoredOnKeycard.isNil: + self.keyPairStoredOnKeycard = newKeyPairSelectedItem() + if self.keyPairStoredOnKeycardVariant.isNil: + self.keyPairStoredOnKeycardVariant = newQVariant(self.keyPairStoredOnKeycard) + proc createKeyPairModel*(self: View, items: seq[KeyPairItem]) = if self.keyPairModel.isNil: self.keyPairModel = newKeyPairModel() @@ -109,10 +115,6 @@ QtObject: self.selectedKeyPairItem = newKeyPairSelectedItem() if self.selectedKeyPairItemVariant.isNil: self.selectedKeyPairItemVariant = newQVariant(self.selectedKeyPairItem) - if self.keyPairStoredOnKeycard.isNil: - self.keyPairStoredOnKeycard = newKeyPairSelectedItem() - if self.keyPairStoredOnKeycardVariant.isNil: - self.keyPairStoredOnKeycardVariant = newQVariant(self.keyPairStoredOnKeycard) self.keyPairModel.setItems(items) self.keyPairModelChanged() diff --git a/ui/app/AppLayouts/Profile/stores/KeycardStore.qml b/ui/app/AppLayouts/Profile/stores/KeycardStore.qml index a9cf450b3a..8296118c39 100644 --- a/ui/app/AppLayouts/Profile/stores/KeycardStore.qml +++ b/ui/app/AppLayouts/Profile/stores/KeycardStore.qml @@ -10,6 +10,18 @@ QtObject { root.keycardModule.runSetupKeycardPopup() } + function runGenerateSeedPhrasePopup() { + root.keycardModule.runGenerateSeedPhrasePopup() + } + + function runImportOrRestoreViaSeedPhrasePopup() { + root.keycardModule.runImportOrRestoreViaSeedPhrasePopup() + } + + function runImportFromKeycardToAppPopup() { + root.keycardModule.runImportFromKeycardToAppPopup() + } + function runUnlockKeycardPopup() { root.keycardModule.runUnlockKeycardPopup() } diff --git a/ui/app/AppLayouts/Profile/views/KeycardView.qml b/ui/app/AppLayouts/Profile/views/KeycardView.qml index eee04f3b65..682c3d032e 100644 --- a/ui/app/AppLayouts/Profile/views/KeycardView.qml +++ b/ui/app/AppLayouts/Profile/views/KeycardView.qml @@ -115,7 +115,7 @@ SettingsContentBase { } ] onClicked: { - console.warn("TODO: Generate a seed phrase...") + root.keycardStore.runGenerateSeedPhrasePopup() } } @@ -130,7 +130,7 @@ SettingsContentBase { } ] onClicked: { - console.warn("TODO: Import or restore via a seed phrase...") + root.keycardStore.runImportOrRestoreViaSeedPhrasePopup() } } @@ -145,7 +145,7 @@ SettingsContentBase { } ] onClicked: { - console.warn("TODO: Import from Keycard to Status Desktop...") + root.keycardStore.runImportFromKeycardToAppPopup() } } diff --git a/ui/imports/shared/popups/keycard/KeycardPopup.qml b/ui/imports/shared/popups/keycard/KeycardPopup.qml index 5581e0dfe8..912b682e84 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopup.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopup.qml @@ -30,6 +30,11 @@ StatusModal { return Constants.keycard.general.popupBiggerHeight } } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + return Constants.keycard.general.popupBiggerHeight + } + } } return Constants.keycard.general.popupHeight } @@ -50,6 +55,9 @@ StatusModal { if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.unlockKeycard) { return qsTr("Unlock Keycard") } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + return qsTr("Check what’s on a Keycard") + } return "" } @@ -327,7 +335,6 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.notKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pinVerified || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPin || @@ -347,7 +354,6 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeychainPin || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || @@ -374,12 +380,26 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPuk || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPuk || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.notKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.unlockKeycardOptions || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterSeedPhrase) return qsTr("Cancel") } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPin || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.notKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pinVerified || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached) + return qsTr("Cancel") + } return "" } @@ -508,7 +528,6 @@ StatusModal { if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached) { - let a = root.sharedKeycardModule.keycardData & Constants.predefinedKeycardData.useUnlockLabelForLockedState if (root.sharedKeycardModule.keycardData & Constants.predefinedKeycardData.useUnlockLabelForLockedState) return qsTr("Unlock Keycard") return qsTr("Next") @@ -542,7 +561,8 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached) { return qsTr("Unlock Keycard") } - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetSuccess) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetSuccess) { return qsTr("Done") } } @@ -551,7 +571,6 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.notKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || @@ -561,6 +580,9 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPin) { return qsTr("Authenticate") } + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty) { + return qsTr("Done") + } if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterBiometricsPassword || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongBiometricsPassword) { return qsTr("Update password & authenticate") @@ -580,7 +602,8 @@ StatusModal { } } if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.unlockKeycard) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardAlreadyUnlocked || + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardAlreadyUnlocked || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.unlockKeycardSuccess) return qsTr("Done") if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.unlockKeycardOptions) @@ -599,6 +622,23 @@ StatusModal { return qsTr("Unlock Keycard") } } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + return qsTr("Done") + } + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin) { + return qsTr("I don’t know the PIN") + } + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pinVerified) { + return qsTr("Next") + } + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached) { + return qsTr("Unlock Keycard") + } + } return "" } visible: text !== "" @@ -638,7 +678,6 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeychainPin || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.notKeycard || @@ -684,8 +723,7 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.notKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty) + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) return "touch-id" } } diff --git a/ui/imports/shared/popups/keycard/states/KeycardInit.qml b/ui/imports/shared/popups/keycard/states/KeycardInit.qml index dcc7a6e34f..7af9163c05 100644 --- a/ui/imports/shared/popups/keycard/states/KeycardInit.qml +++ b/ui/imports/shared/popups/keycard/states/KeycardInit.qml @@ -182,6 +182,11 @@ Item { return true } } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + return true + } + } return false } @@ -226,6 +231,14 @@ Item { return keyPairForAuthenticationComponent } } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return knownKeyPairComponent + } + return unknownKeyPairCompontnt + } + } return undefined } @@ -513,10 +526,11 @@ Item { PropertyChanges { target: message text: { - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) - return qsTr("The Keycard you have inserted is locked,\nyou will need to factory reset it before proceeding") - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication) + if (root.sharedKeycardModule.keycardData & Constants.predefinedKeycardData.useGeneralMessageForLockedState) { + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) + return qsTr("The Keycard you have inserted is locked,\nyou will need to factory reset it before proceeding") return qsTr("You will need to unlock it before proceeding") + } if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached) return qsTr("Pin entered incorrectly too many times") if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached) diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 3b0da4084e..04c93ddde5 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -76,6 +76,7 @@ QtObject { readonly property int wrongPassword: 8 readonly property int offerPukForUnlock: 16 readonly property int useUnlockLabelForLockedState: 32 + readonly property int useGeneralMessageForLockedState: 64 } readonly property QtObject keycardSharedFlow: QtObject { @@ -84,6 +85,7 @@ QtObject { readonly property string setupNewKeycard: "SetupNewKeycard" readonly property string authentication: "Authentication" readonly property string unlockKeycard: "UnlockKeycard" + readonly property string displayKeycardContent: "DisplayKeycardContent" } readonly property QtObject keycardSharedState: QtObject {