chore(@desktop/keycard): shared keycard popup module extension
shared keycard popup module is extended with: - `uniqueIdentifier` - `settingsService` - `walletAccountService` - `keychainService`
This commit is contained in:
parent
6e9cb37766
commit
3042a0cffa
|
@ -1,4 +1,4 @@
|
|||
import ../shared_models/section_item, io_interface, chronicles
|
||||
import chronicles
|
||||
import ../../global/app_sections_config as conf
|
||||
import ../../global/global_singleton
|
||||
import ../../global/app_signals
|
||||
|
@ -18,9 +18,14 @@ import ../../../app_service/service/mailservers/service as mailservers_service
|
|||
import ../../../app_service/service/privacy/service as privacy_service
|
||||
import ../../../app_service/service/node/service as node_service
|
||||
|
||||
import ../shared_models/section_item, io_interface
|
||||
import ../shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
|
||||
logScope:
|
||||
topics = "main-module-controller"
|
||||
|
||||
const UNIQUE_MAIN_MODULE_IDENTIFIER* = "MainModule"
|
||||
|
||||
type
|
||||
Controller* = ref object of RootObj
|
||||
delegate: io_interface.AccessInterface
|
||||
|
@ -37,6 +42,7 @@ type
|
|||
mailserversService: mailservers_service.Service
|
||||
nodeService: node_service.Service
|
||||
activeSectionId: string
|
||||
authenticateUserFlowRequestedBy: string
|
||||
|
||||
# Forward declaration
|
||||
proc setActiveSection*(self: Controller, sectionId: string)
|
||||
|
@ -91,9 +97,7 @@ proc init*(self: Controller) =
|
|||
|
||||
self.events.on(SIGNAL_KEYCHAIN_SERVICE_ERROR) do(e:Args):
|
||||
let args = KeyChainServiceArg(e)
|
||||
# with the following condition we guard unintentional props deletion from the `.ini` file
|
||||
if self.accountsService.getLoggedInAccount().isValid():
|
||||
singletonInstance.localAccountSettings.removeKey(LS_KEY_STORE_TO_KEYCHAIN)
|
||||
self.delegate.emitStoringPasswordError(args.errDescription)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_JOINED) do(e:Args):
|
||||
|
@ -226,6 +230,33 @@ proc init*(self: Controller) =
|
|||
let args = chat_service.ChatArgs(e)
|
||||
self.delegate.onChatLeft(args.chatId)
|
||||
|
||||
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_FLOW_TERMINATED) do(e: Args):
|
||||
let args = SharedKeycarModuleFlowTerminatedArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_MAIN_MODULE_IDENTIFIER or
|
||||
self.authenticateUserFlowRequestedBy.len == 0:
|
||||
return
|
||||
self.delegate.onSharedKeycarModuleFlowTerminated(args.lastStepInTheCurrentFlow)
|
||||
let data = SharedKeycarModuleArgs(uniqueIdentifier: self.authenticateUserFlowRequestedBy,
|
||||
data: args.data,
|
||||
keyUid: args.keyUid,
|
||||
txR: args.txR,
|
||||
txS: args.txS,
|
||||
txV: args.txV)
|
||||
self.authenticateUserFlowRequestedBy = ""
|
||||
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED, data)
|
||||
|
||||
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_DISPLAY_POPUP) do(e: Args):
|
||||
let args = SharedKeycarModuleArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_MAIN_MODULE_IDENTIFIER or
|
||||
self.authenticateUserFlowRequestedBy.len == 0:
|
||||
return
|
||||
self.delegate.onDisplayKeycardSharedModuleFlow()
|
||||
|
||||
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER) do(e: Args):
|
||||
let args = SharedKeycarModuleAuthenticationArgs(e)
|
||||
self.authenticateUserFlowRequestedBy = args.uniqueIdentifier
|
||||
self.delegate.runAuthenticationPopup(args.keyUid, args.bip44Path, args.txHash)
|
||||
|
||||
proc isConnected*(self: Controller): bool =
|
||||
return self.nodeService.isConnected()
|
||||
|
||||
|
|
|
@ -205,6 +205,18 @@ method onStatusUrlRequested*(self: AccessInterface, action: StatusUrlAction, com
|
|||
method getVerificationRequestFrom*(self: AccessInterface, publicKey: string): VerificationRequest {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getKeycardSharedModule*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onDisplayKeycardSharedModuleFlow*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onSharedKeycarModuleFlowTerminated*(self: AccessInterface, lastStepInTheCurrentFlow: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method runAuthenticationPopup*(self: AccessInterface, keyUid: string, bip44Path: string, txHash: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# This way (using concepts) is used only for the modules managed by AppController
|
||||
type
|
||||
DelegateInterface* = concept c
|
||||
|
|
|
@ -4,6 +4,7 @@ import io_interface, view, controller, chat_search_item, chat_search_model
|
|||
import ephemeral_notification_item, ephemeral_notification_model
|
||||
import ./communities/models/[pending_request_item, pending_request_model]
|
||||
import ../shared_models/[user_item, member_item, member_model, section_item, section_model, active_section]
|
||||
import ../shared_modules/keycard_popup/module as keycard_shared_module
|
||||
import ../../global/app_sections_config as conf
|
||||
import ../../global/app_signals
|
||||
import ../../global/global_singleton
|
||||
|
@ -73,6 +74,13 @@ type
|
|||
viewVariant: QVariant
|
||||
controller: Controller
|
||||
channelGroupModules: OrderedTable[string, chat_section_module.AccessInterface]
|
||||
events: EventEmitter
|
||||
keycardService: keycard_service.Service
|
||||
settingsService: settings_service.Service
|
||||
privacyService: privacy_service.Service
|
||||
accountsService: accounts_service.Service
|
||||
walletAccountService: wallet_account_service.Service
|
||||
keychainService: keychain_service.Service
|
||||
walletSectionModule: wallet_section_module.AccessInterface
|
||||
browserSectionModule: browser_section_module.AccessInterface
|
||||
profileSectionModule: profile_section_module.AccessInterface
|
||||
|
@ -82,6 +90,7 @@ type
|
|||
appSearchModule: app_search_module.AccessInterface
|
||||
nodeSectionModule: node_section_module.AccessInterface
|
||||
networksModule: networks_module.AccessInterface
|
||||
keycardSharedModule: keycard_shared_module.AccessInterface
|
||||
moduleLoaded: bool
|
||||
statusUrlGroupName: string
|
||||
statusUrlGroupMembers: seq[string] # used only for creating group chat from the status url
|
||||
|
@ -145,6 +154,14 @@ proc newModule*[T](
|
|||
)
|
||||
result.moduleLoaded = false
|
||||
|
||||
result.events = events
|
||||
result.keycardService = keycardService
|
||||
result.settingsService = settingsService
|
||||
result.privacyService = privacyService
|
||||
result.accountsService = accountsService
|
||||
result.walletAccountService = walletAccountService
|
||||
result.keychainService = keychainService
|
||||
|
||||
# Submodules
|
||||
result.channelGroupModules = initOrderedTable[string, chat_section_module.AccessInterface]()
|
||||
result.walletSectionModule = wallet_section_module.newModule(
|
||||
|
@ -160,7 +177,7 @@ proc newModule*[T](
|
|||
result, events, accountsService, settingsService, stickersService,
|
||||
profileService, contactsService, aboutService, languageService, privacyService, nodeConfigurationService,
|
||||
devicesService, mailserversService, chatService, ensService, walletAccountService, generalService, communityService,
|
||||
networkService, keycardService
|
||||
networkService, keycardService, keychainService
|
||||
)
|
||||
result.stickersModule = stickers_module.newModule(result, events, stickersService, settingsService, walletAccountService, networkService)
|
||||
result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService,
|
||||
|
@ -184,6 +201,8 @@ method delete*[T](self: Module[T]) =
|
|||
self.appSearchModule.delete
|
||||
self.nodeSectionModule.delete
|
||||
self.networksModule.delete
|
||||
if not self.keycardSharedModule.isNil:
|
||||
self.keycardSharedModule.delete
|
||||
self.view.delete
|
||||
self.viewVariant.delete
|
||||
self.controller.delete
|
||||
|
@ -927,3 +946,29 @@ method onStatusUrlRequested*[T](self: Module[T], action: StatusUrlAction, commun
|
|||
|
||||
cModule.makeChatWithIdActive(chatId)
|
||||
break
|
||||
|
||||
method getKeycardSharedModule*[T](self: Module[T]): QVariant =
|
||||
return self.keycardSharedModule.getModuleAsVariant()
|
||||
|
||||
proc createSharedKeycardModule[T](self: Module[T]) =
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module[T]](self, UNIQUE_MAIN_MODULE_IDENTIFIER,
|
||||
self.events, self.keycardService, self.settingsService, self.privacyService, self.accountsService,
|
||||
self.walletAccountService, self.keychainService)
|
||||
|
||||
proc isSharedKeycardModuleFlowRunning[T](self: Module[T]): bool =
|
||||
return not self.keycardSharedModule.isNil
|
||||
|
||||
method onSharedKeycarModuleFlowTerminated*[T](self: Module[T], lastStepInTheCurrentFlow: bool) =
|
||||
if self.isSharedKeycardModuleFlowRunning():
|
||||
self.view.emitDestroyKeycardSharedModuleFlow()
|
||||
self.keycardSharedModule.delete
|
||||
self.keycardSharedModule = nil
|
||||
|
||||
method runAuthenticationPopup*[T](self: Module[T], keyUid: string, bip44Path: string, txHash: string) =
|
||||
self.createSharedKeycardModule()
|
||||
if self.keycardSharedModule.isNil:
|
||||
return
|
||||
self.keycardSharedModule.runFlow(keycard_shared_module.FlowType.Authentication, keyUid, bip44Path, txHash)
|
||||
|
||||
method onDisplayKeycardSharedModuleFlow*[T](self: Module[T]) =
|
||||
self.view.emitDisplayKeycardSharedModuleFlow()
|
|
@ -9,6 +9,8 @@ import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_modu
|
|||
logScope:
|
||||
topics = "profile-section-keycard-module-controller"
|
||||
|
||||
const UNIQUE_SETTING_KEYCARD_MODULE_IDENTIFIER* = "Settings-KeycardModule"
|
||||
|
||||
type
|
||||
Controller* = ref object of RootObj
|
||||
delegate: io_interface.AccessInterface
|
||||
|
@ -25,9 +27,14 @@ proc delete*(self: Controller) =
|
|||
discard
|
||||
|
||||
proc init*(self: Controller) =
|
||||
self.events.on(SignalSharedKeycarModuleFlowTerminated) do(e: Args):
|
||||
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_FLOW_TERMINATED) do(e: Args):
|
||||
let args = SharedKeycarModuleFlowTerminatedArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_SETTING_KEYCARD_MODULE_IDENTIFIER:
|
||||
return
|
||||
self.delegate.onSharedKeycarModuleFlowTerminated(args.lastStepInTheCurrentFlow)
|
||||
|
||||
self.events.on(SignalSharedKeycarModuleDisplayPopup) do(e: Args):
|
||||
self.delegate.onDisplayKeycardSharedModuleFlow()
|
||||
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_DISPLAY_POPUP) do(e: Args):
|
||||
let args = SharedKeycarModuleArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_SETTING_KEYCARD_MODULE_IDENTIFIER:
|
||||
return
|
||||
self.delegate.onDisplayKeycardSharedModuleFlow()
|
||||
|
|
|
@ -6,9 +6,11 @@ import ../io_interface as delegate_interface
|
|||
import ../../../../core/eventemitter
|
||||
|
||||
import ../../../../../app_service/service/keycard/service as keycard_service
|
||||
import ../../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../../app_service/service/privacy/service as privacy_service
|
||||
import ../../../../../app_service/service/accounts/service as accounts_service
|
||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../../app_service/service/keychain/service as keychain_service
|
||||
|
||||
import ../../../shared_modules/keycard_popup/module as keycard_shared_module
|
||||
|
||||
|
@ -26,24 +28,30 @@ type
|
|||
moduleLoaded: bool
|
||||
events: EventEmitter
|
||||
keycardService: keycard_service.Service
|
||||
settingsService: settings_service.Service
|
||||
privacyService: privacy_service.Service
|
||||
accountsService: accounts_service.Service
|
||||
walletAccountService: wallet_account_service.Service
|
||||
keychainService: keychain_service.Service
|
||||
keycardSharedModule: keycard_shared_module.AccessInterface
|
||||
|
||||
proc newModule*(delegate: delegate_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
keycardService: keycard_service.Service,
|
||||
settingsService: settings_service.Service,
|
||||
privacyService: privacy_service.Service,
|
||||
accountsService: accounts_service.Service,
|
||||
walletAccountService: wallet_account_service.Service): Module =
|
||||
walletAccountService: wallet_account_service.Service,
|
||||
keychainService: keychain_service.Service): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
result.events = events
|
||||
result.keycardService = keycardService
|
||||
result.settingsService = settingsService
|
||||
result.privacyService = privacyService
|
||||
result.accountsService = accountsService
|
||||
result.walletAccountService = walletAccountService
|
||||
result.keychainService = keychainService
|
||||
result.view = view.newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController(result, events)
|
||||
|
@ -74,8 +82,9 @@ method getKeycardSharedModule*(self: Module): QVariant =
|
|||
return self.keycardSharedModule.getModuleAsVariant()
|
||||
|
||||
proc createSharedKeycardModule(self: Module) =
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module](self, self.events, self.keycardService,
|
||||
self.privacyService, self.accountsService, self.walletAccountService)
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module](self, UNIQUE_SETTING_KEYCARD_MODULE_IDENTIFIER,
|
||||
self.events, self.keycardService, self.settingsService, self.privacyService, self.accountsService,
|
||||
self.walletAccountService, self.keychainService)
|
||||
|
||||
proc isSharedKeycardModuleFlowRunning(self: Module): bool =
|
||||
return not self.keycardSharedModule.isNil
|
||||
|
|
|
@ -21,6 +21,7 @@ import ../../../../app_service/service/wallet_account/service as wallet_account_
|
|||
import ../../../../app_service/service/general/service as general_service
|
||||
import ../../../../app_service/service/community/service as community_service
|
||||
import ../../../../app_service/service/keycard/service as keycard_service
|
||||
import ../../../../app_service/service/keychain/service as keychain_service
|
||||
|
||||
import ./profile/module as profile_module
|
||||
import ./contacts/module as contacts_module
|
||||
|
@ -77,7 +78,8 @@ proc newModule*(delegate: delegate_interface.AccessInterface,
|
|||
generalService: general_service.Service,
|
||||
communityService: community_service.Service,
|
||||
networkService: network_service.Service,
|
||||
keycardService: keycard_service.Service
|
||||
keycardService: keycard_service.Service,
|
||||
keychainService: keychain_service.Service
|
||||
): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
|
@ -99,8 +101,8 @@ proc newModule*(delegate: delegate_interface.AccessInterface,
|
|||
result, events, settingsService, ensService, walletAccountService, networkService
|
||||
)
|
||||
result.communitiesModule = communities_module.newModule(result, communityService)
|
||||
result.keycardModule = keycard_module.newModule(result, events, keycardService, privacyService, accountsService,
|
||||
walletAccountService)
|
||||
result.keycardModule = keycard_module.newModule(result, events, keycardService, settingsService, privacyService,
|
||||
accountsService, walletAccountService, keychainService)
|
||||
|
||||
singletonInstance.engine.setRootContextProperty("profileSectionModule", result.viewVariant)
|
||||
|
||||
|
|
|
@ -217,4 +217,17 @@ QtObject:
|
|||
|
||||
proc displayUserProfile*(self:View, publicKey: string) {.signal.}
|
||||
proc emitDisplayUserProfileSignal*(self: View, publicKey: string) =
|
||||
self.displayUserProfile(publicKey)
|
||||
self.displayUserProfile(publicKey)
|
||||
|
||||
proc getKeycardSharedModule(self: View): QVariant {.slot.} =
|
||||
return self.delegate.getKeycardSharedModule()
|
||||
QtProperty[QVariant] keycardSharedModule:
|
||||
read = getKeycardSharedModule
|
||||
|
||||
proc displayKeycardSharedModuleFlow*(self: View) {.signal.}
|
||||
proc emitDisplayKeycardSharedModuleFlow*(self: View) =
|
||||
self.displayKeycardSharedModuleFlow()
|
||||
|
||||
proc destroyKeycardSharedModuleFlow*(self: View) {.signal.}
|
||||
proc emitDestroyKeycardSharedModuleFlow*(self: View) =
|
||||
self.destroyKeycardSharedModuleFlow()
|
|
@ -6,9 +6,11 @@ import ../../../global/global_singleton
|
|||
import ../../../core/signals/types
|
||||
import ../../../core/eventemitter
|
||||
import ../../../../app_service/service/keycard/service as keycard_service
|
||||
import ../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../app_service/service/privacy/service as privacy_service
|
||||
import ../../../../app_service/service/accounts/service as accounts_service
|
||||
import ../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../app_service/service/keychain/service as keychain_service
|
||||
|
||||
logScope:
|
||||
topics = "keycard-popup-controller"
|
||||
|
@ -16,12 +18,17 @@ logScope:
|
|||
type
|
||||
Controller* = ref object of RootObj
|
||||
delegate: io_interface.AccessInterface
|
||||
uniqueIdentifier: string
|
||||
events: EventEmitter
|
||||
keycardService: keycard_service.Service
|
||||
settingsService: settings_service.Service
|
||||
privacyService: privacy_service.Service
|
||||
accountsService: accounts_service.Service
|
||||
walletAccountService: wallet_account_service.Service
|
||||
keychainService: keychain_service.Service
|
||||
connectionIds: seq[UUID]
|
||||
keychainConnectionIds: seq[UUID]
|
||||
connectionKeycardResponse: UUID
|
||||
tmpKeycardContainsMetadata: bool
|
||||
tmpPin: string
|
||||
tmpPinMatch: bool
|
||||
|
@ -34,19 +41,25 @@ type
|
|||
tmpSeedPhraseLength: int
|
||||
|
||||
proc newController*(delegate: io_interface.AccessInterface,
|
||||
uniqueIdentifier: string,
|
||||
events: EventEmitter,
|
||||
keycardService: keycard_service.Service,
|
||||
settingsService: settings_service.Service,
|
||||
privacyService: privacy_service.Service,
|
||||
accountsService: accounts_service.Service,
|
||||
walletAccountService: wallet_account_service.Service):
|
||||
walletAccountService: wallet_account_service.Service,
|
||||
keychainService: keychain_service.Service):
|
||||
Controller =
|
||||
result = Controller()
|
||||
result.delegate = delegate
|
||||
result.uniqueIdentifier = uniqueIdentifier
|
||||
result.events = events
|
||||
result.keycardService = keycardService
|
||||
result.settingsService = settingsService
|
||||
result.privacyService = privacyService
|
||||
result.accountsService = accountsService
|
||||
result.walletAccountService = walletAccountService
|
||||
result.keychainService = keychainService
|
||||
result.tmpKeycardContainsMetadata = false
|
||||
result.tmpPinMatch = false
|
||||
result.tmpSeedPhraseLength = 0
|
||||
|
@ -60,19 +73,51 @@ proc serviceApplicable[T](service: T): bool =
|
|||
serviceName = "WalletAccountService"
|
||||
when (service is privacy_service.Service):
|
||||
serviceName = "PrivacyService"
|
||||
when (service is settings_service.Service):
|
||||
serviceName = "SettingsService"
|
||||
debug "service doesn't meant to be used from the context it's used, check the context shared popup module is used", service=serviceName
|
||||
|
||||
proc disconnect*(self: Controller) =
|
||||
proc disconnectKeycardReponseSignal(self: Controller) =
|
||||
self.events.disconnect(self.connectionKeycardResponse)
|
||||
|
||||
proc connectKeycardReponseSignal(self: Controller) =
|
||||
self.connectionKeycardResponse = self.events.onWithUUID(SIGNAL_KEYCARD_RESPONSE) do(e: Args):
|
||||
let args = KeycardArgs(e)
|
||||
self.delegate.onKeycardResponse(args.flowType, args.flowEvent)
|
||||
|
||||
proc connectKeychainSignals*(self: Controller) =
|
||||
var handlerId = self.events.onWithUUID(SIGNAL_KEYCHAIN_SERVICE_SUCCESS) do(e:Args):
|
||||
let args = KeyChainServiceArg(e)
|
||||
self.delegate.keychainObtainedDataSuccess(args.data)
|
||||
self.keychainConnectionIds.add(handlerId)
|
||||
|
||||
handlerId = self.events.onWithUUID(SIGNAL_KEYCHAIN_SERVICE_ERROR) do(e:Args):
|
||||
let args = KeyChainServiceArg(e)
|
||||
self.delegate.keychainObtainedDataFailure(args.errDescription, args.errType)
|
||||
self.keychainConnectionIds.add(handlerId)
|
||||
|
||||
proc disconnectKeychainSignals(self: Controller) =
|
||||
for id in self.keychainConnectionIds:
|
||||
self.events.disconnect(id)
|
||||
|
||||
proc disconnectAll*(self: Controller) =
|
||||
self.disconnectKeycardReponseSignal()
|
||||
self.disconnectKeychainSignals()
|
||||
for id in self.connectionIds:
|
||||
self.events.disconnect(id)
|
||||
|
||||
proc delete*(self: Controller) =
|
||||
self.disconnect()
|
||||
self.disconnectAll()
|
||||
|
||||
proc init*(self: Controller) =
|
||||
let handlerId = self.events.onWithUUID(SignalKeycardResponse) do(e: Args):
|
||||
let args = KeycardArgs(e)
|
||||
self.delegate.onKeycardResponse(args.flowType, args.flowEvent)
|
||||
self.connectKeycardReponseSignal()
|
||||
|
||||
let handlerId = self.events.onWithUUID(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED) do(e: Args):
|
||||
let args = SharedKeycarModuleArgs(e)
|
||||
if args.uniqueIdentifier != self.uniqueIdentifier:
|
||||
return
|
||||
self.connectKeycardReponseSignal()
|
||||
self.delegate.onUserAuthenticated(args.data)
|
||||
self.connectionIds.add(handlerId)
|
||||
|
||||
proc getKeycardData*(self: Controller): string =
|
||||
|
|
|
@ -3,17 +3,38 @@ import ../../../../app/core/eventemitter
|
|||
from ../../../../app_service/service/keycard/service import KeycardEvent, CardMetadata, KeyDetails
|
||||
import models/key_pair_item
|
||||
|
||||
const SignalSharedKeycarModuleDisplayPopup* = "SignalSharedKeycarModuleDisplayPopup"
|
||||
const SignalSharedKeycarModuleFlowTerminated* = "sharedKeycarModuleFlowTerminated"
|
||||
const SIGNAL_SHARED_KEYCARD_MODULE_DISPLAY_POPUP* = "sharedKeycarModuleDisplayPopup"
|
||||
const SIGNAL_SHARED_KEYCARD_MODULE_FLOW_TERMINATED* = "sharedKeycarModuleFlowTerminated"
|
||||
const SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER* = "sharedKeycarModuleAuthenticateUser"
|
||||
const SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED* = "sharedKeycarModuleUserAuthenticated"
|
||||
|
||||
type
|
||||
SharedKeycarModuleFlowTerminatedArgs* = ref object of Args
|
||||
SharedKeycarModuleBaseArgs* = ref object of Args
|
||||
uniqueIdentifier*: string
|
||||
|
||||
type
|
||||
SharedKeycarModuleArgs* = ref object of SharedKeycarModuleBaseArgs
|
||||
data*: string
|
||||
keyUid*: string
|
||||
txR*: string
|
||||
txS*: string
|
||||
txV*: string
|
||||
|
||||
type
|
||||
SharedKeycarModuleFlowTerminatedArgs* = ref object of SharedKeycarModuleArgs
|
||||
lastStepInTheCurrentFlow*: bool
|
||||
|
||||
type
|
||||
SharedKeycarModuleAuthenticationArgs* = ref object of SharedKeycarModuleBaseArgs
|
||||
keyUid*: string
|
||||
bip44Path*: string
|
||||
txHash*: string
|
||||
|
||||
type FlowType* {.pure.} = enum
|
||||
General = "General"
|
||||
FactoryReset = "FactoryReset"
|
||||
SetupNewKeycard = "SetupNewKeycard"
|
||||
Authentication = "Authentication"
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
|
|
|
@ -8,9 +8,11 @@ import ../../../global/global_singleton
|
|||
import ../../../core/eventemitter
|
||||
|
||||
import ../../../../app_service/service/keycard/service as keycard_service
|
||||
import ../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../app_service/service/privacy/service as privacy_service
|
||||
import ../../../../app_service/service/accounts/service as accounts_service
|
||||
import ../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../app_service/service/keychain/service as keychain_service
|
||||
|
||||
export io_interface
|
||||
|
||||
|
@ -25,21 +27,26 @@ type
|
|||
controller: Controller
|
||||
initialized: bool
|
||||
tmpLocalState: State # used when flow is run, until response arrives to determine next state appropriatelly
|
||||
authenticationPopupIsAlreadyRunning: bool
|
||||
|
||||
proc newModule*[T](delegate: T,
|
||||
uniqueIdentifier: string,
|
||||
events: EventEmitter,
|
||||
keycardService: keycard_service.Service,
|
||||
settingsService: settings_service.Service,
|
||||
privacyService: privacy_service.Service,
|
||||
accountsService: accounts_service.Service,
|
||||
walletAccountService: wallet_account_service.Service):
|
||||
walletAccountService: wallet_account_service.Service,
|
||||
keychainService: keychain_service.Service):
|
||||
Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
result.view = view.newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController(result, events, keycardService, privacyService, accountsService,
|
||||
walletAccountService)
|
||||
result.controller = controller.newController(result, uniqueIdentifier, events, keycardService, settingsService,
|
||||
privacyService, accountsService, walletAccountService, keychainService)
|
||||
result.initialized = false
|
||||
result.authenticationPopupIsAlreadyRunning = false
|
||||
|
||||
method delete*[T](self: Module[T]) =
|
||||
self.view.delete
|
||||
|
|
|
@ -16,6 +16,8 @@ import ../shared_modules/keycard_popup/io_interface as keycard_shared_module
|
|||
logScope:
|
||||
topics = "startup-controller"
|
||||
|
||||
const UNIQUE_STARTUP_MODULE_IDENTIFIER* = "SartupModule"
|
||||
|
||||
type ProfileImageDetails = object
|
||||
url*: string
|
||||
croppedImage*: string
|
||||
|
@ -110,17 +112,22 @@ proc init*(self: Controller) =
|
|||
self.delegate.emitObtainingPasswordError(args.errDescription, args.errType)
|
||||
self.connectionIds.add(handlerId)
|
||||
|
||||
handlerId = self.events.onWithUUID(SignalKeycardResponse) do(e: Args):
|
||||
handlerId = self.events.onWithUUID(SIGNAL_KEYCARD_RESPONSE) do(e: Args):
|
||||
let args = KeycardArgs(e)
|
||||
self.delegate.onKeycardResponse(args.flowType, args.flowEvent)
|
||||
self.connectionIds.add(handlerId)
|
||||
|
||||
handlerId = self.events.onWithUUID(SignalSharedKeycarModuleFlowTerminated) do(e: Args):
|
||||
handlerId = self.events.onWithUUID(SIGNAL_SHARED_KEYCARD_MODULE_FLOW_TERMINATED) do(e: Args):
|
||||
let args = SharedKeycarModuleFlowTerminatedArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_STARTUP_MODULE_IDENTIFIER:
|
||||
return
|
||||
self.delegate.onSharedKeycarModuleFlowTerminated(args.lastStepInTheCurrentFlow)
|
||||
self.connectionIds.add(handlerId)
|
||||
|
||||
handlerId = self.events.onWithUUID(SignalSharedKeycarModuleDisplayPopup) do(e: Args):
|
||||
handlerId = self.events.onWithUUID(SIGNAL_SHARED_KEYCARD_MODULE_DISPLAY_POPUP) do(e: Args):
|
||||
let args = SharedKeycarModuleArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_STARTUP_MODULE_IDENTIFIER:
|
||||
return
|
||||
self.delegate.onDisplayKeycardSharedModuleFlow()
|
||||
self.connectionIds.add(handlerId)
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ type
|
|||
events: EventEmitter
|
||||
keycardService: keycard_service.Service
|
||||
accountsService: accounts_service.Service
|
||||
keychainService: keychain_service.Service
|
||||
keycardSharedModule: keycard_shared_module.AccessInterface
|
||||
|
||||
proc newModule*[T](delegate: T,
|
||||
|
@ -45,6 +46,7 @@ proc newModule*[T](delegate: T,
|
|||
result.events = events
|
||||
result.keycardService = keycardService
|
||||
result.accountsService = accountsService
|
||||
result.keychainService = keychainService
|
||||
result.view = view.newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController(result, events, generalService, accountsService, keychainService,
|
||||
|
@ -104,8 +106,9 @@ method getKeycardSharedModule*[T](self: Module[T]): QVariant =
|
|||
return self.keycardSharedModule.getModuleAsVariant()
|
||||
|
||||
proc createSharedKeycardModule[T](self: Module[T]) =
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module[T]](self, self.events, self.keycardService,
|
||||
privacyService = nil, self.accountsService, walletAccountService = nil)
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module[T]](self, UNIQUE_STARTUP_MODULE_IDENTIFIER,
|
||||
self.events, self.keycardService, settingsService = nil, privacyService = nil, self.accountsService,
|
||||
walletAccountService = nil, self.keychainService)
|
||||
|
||||
proc isSharedKeycardModuleFlowRunning[T](self: Module[T]): bool =
|
||||
return not self.keycardSharedModule.isNil
|
||||
|
|
Loading…
Reference in New Issue