feat(@desktop/keycard): recover an account fetching previously backed up data from waku
Closes: #8920
This commit is contained in:
parent
8a1e1947ae
commit
bf9b709cc8
|
@ -50,6 +50,7 @@ type SignalType* {.pure.} = enum
|
||||||
WakuFetchingBackupProgress = "waku.fetching.backup.progress"
|
WakuFetchingBackupProgress = "waku.fetching.backup.progress"
|
||||||
WakuBackedUpProfile = "waku.backedup.profile"
|
WakuBackedUpProfile = "waku.backedup.profile"
|
||||||
WakuBackedUpSettings = "waku.backedup.settings"
|
WakuBackedUpSettings = "waku.backedup.settings"
|
||||||
|
WakuBackedUpKeycards = "waku.backedup.keycards"
|
||||||
Unknown
|
Unknown
|
||||||
|
|
||||||
proc event*(self:SignalType):string =
|
proc event*(self:SignalType):string =
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import json
|
||||||
|
import base
|
||||||
|
|
||||||
|
import ../../../../app_service/service/wallet_account/[key_pair_dto]
|
||||||
|
|
||||||
|
type WakuBackedUpKeycardsSignal* = ref object of Signal
|
||||||
|
keycards*: seq[KeyPairDto]
|
||||||
|
|
||||||
|
proc fromEvent*(T: type WakuBackedUpKeycardsSignal, event: JsonNode): WakuBackedUpKeycardsSignal =
|
||||||
|
result = WakuBackedUpKeycardsSignal()
|
||||||
|
|
||||||
|
if event["event"]{"backedUpKeycards"} != nil:
|
||||||
|
for jsonKc in event["event"]["backedUpKeycards"]:
|
||||||
|
result.keycards.add(jsonKc.toKeyPairDto())
|
|
@ -105,6 +105,7 @@ QtObject:
|
||||||
of SignalType.WakuFetchingBackupProgress: WakuFetchingBackupProgressSignal.fromEvent(jsonSignal)
|
of SignalType.WakuFetchingBackupProgress: WakuFetchingBackupProgressSignal.fromEvent(jsonSignal)
|
||||||
of SignalType.WakuBackedUpProfile: WakuBackedUpProfileSignal.fromEvent(jsonSignal)
|
of SignalType.WakuBackedUpProfile: WakuBackedUpProfileSignal.fromEvent(jsonSignal)
|
||||||
of SignalType.WakuBackedUpSettings: WakuBackedUpSettingsSignal.fromEvent(jsonSignal)
|
of SignalType.WakuBackedUpSettings: WakuBackedUpSettingsSignal.fromEvent(jsonSignal)
|
||||||
|
of SignalType.WakuBackedUpKeycards: WakuBackedUpKeycardsSignal.fromEvent(jsonSignal)
|
||||||
else: Signal()
|
else: Signal()
|
||||||
|
|
||||||
result.signalType = signalType
|
result.signalType = signalType
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
import ./remote_signals/[base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages,
|
import ./remote_signals/[base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages,
|
||||||
peerstats, signal_type, stats, wallet, whisper_filter, keycard, update_available, status_updates, waku_backed_up_profile,
|
peerstats, signal_type, stats, wallet, whisper_filter, keycard, update_available, status_updates, waku_backed_up_profile,
|
||||||
waku_backed_up_settings, waku_fetching_backup_progress]
|
waku_backed_up_settings, waku_backed_up_keycards, waku_fetching_backup_progress]
|
||||||
|
|
||||||
export base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages, peerstats,
|
export base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages, peerstats,
|
||||||
signal_type, stats, wallet, whisper_filter, keycard, update_available, status_updates, waku_backed_up_profile,
|
signal_type, stats, wallet, whisper_filter, keycard, update_available, status_updates, waku_backed_up_profile,
|
||||||
waku_backed_up_settings, waku_fetching_backup_progress
|
waku_backed_up_settings, waku_backed_up_keycards, waku_fetching_backup_progress
|
||||||
|
|
|
@ -127,3 +127,6 @@ proc authenticateLoggedInUser*(self: Controller) =
|
||||||
if singletonInstance.userProfile.getIsKeycardUser():
|
if singletonInstance.userProfile.getIsKeycardUser():
|
||||||
data.keyUid = singletonInstance.userProfile.getKeyUid()
|
data.keyUid = singletonInstance.userProfile.getKeyUid()
|
||||||
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
|
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
|
||||||
|
|
||||||
|
proc backupData*(self: Controller): int64 =
|
||||||
|
return self.generalService.backupData()
|
|
@ -73,3 +73,6 @@ method tryRemoveFromKeyChain*(self: AccessInterface) {.base.} =
|
||||||
|
|
||||||
method onUserAuthenticated*(self: AccessInterface, pin: string, password: string, keyUid: string) {.base.} =
|
method onUserAuthenticated*(self: AccessInterface, pin: string, password: string, keyUid: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method backupData*(self: AccessInterface): int64 {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
|
@ -118,3 +118,6 @@ method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid:
|
||||||
self.controller.storeToKeychain(pin)
|
self.controller.storeToKeychain(pin)
|
||||||
else:
|
else:
|
||||||
self.controller.storeToKeychain(password)
|
self.controller.storeToKeychain(password)
|
||||||
|
|
||||||
|
method backupData*(self: Module): int64 =
|
||||||
|
return self.controller.backupData()
|
|
@ -78,3 +78,5 @@ QtObject:
|
||||||
proc tryRemoveFromKeyChain*(self: View) {.slot.} =
|
proc tryRemoveFromKeyChain*(self: View) {.slot.} =
|
||||||
self.delegate.tryRemoveFromKeyChain()
|
self.delegate.tryRemoveFromKeyChain()
|
||||||
|
|
||||||
|
proc backupData*(self: View): int {.slot.} =
|
||||||
|
return self.delegate.backupData().int
|
|
@ -32,6 +32,8 @@ const FetchingFromWakuCommunities = "communities"
|
||||||
const FetchingFromWakuCommunitiesIcon = "communities"
|
const FetchingFromWakuCommunitiesIcon = "communities"
|
||||||
const FetchingFromWakuSettings = "settings"
|
const FetchingFromWakuSettings = "settings"
|
||||||
const FetchingFromWakuSettingsIcon = "settings"
|
const FetchingFromWakuSettingsIcon = "settings"
|
||||||
|
const FetchingFromWakuKeycards = "keycards"
|
||||||
|
const FetchingFromWakuKeycardIcon = "keycard"
|
||||||
|
|
||||||
type
|
type
|
||||||
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
|
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
|
||||||
|
@ -338,7 +340,8 @@ proc prepareAndInitFetchingData[T](self: Module[T]) =
|
||||||
(FetchingFromWakuProfile, FetchingFromWakuProfileIcon),
|
(FetchingFromWakuProfile, FetchingFromWakuProfileIcon),
|
||||||
(FetchingFromWakuContacts, FetchingFromWakuContactsIcon),
|
(FetchingFromWakuContacts, FetchingFromWakuContactsIcon),
|
||||||
(FetchingFromWakuCommunities, FetchingFromWakuCommunitiesIcon),
|
(FetchingFromWakuCommunities, FetchingFromWakuCommunitiesIcon),
|
||||||
(FetchingFromWakuSettings, FetchingFromWakuSettingsIcon)
|
(FetchingFromWakuSettings, FetchingFromWakuSettingsIcon),
|
||||||
|
(FetchingFromWakuKeycards, FetchingFromWakuKeycardIcon)
|
||||||
]
|
]
|
||||||
self.view.createAndInitFetchingDataModel(listOfEntitiesWeExpectToBeSynced)
|
self.view.createAndInitFetchingDataModel(listOfEntitiesWeExpectToBeSynced)
|
||||||
|
|
||||||
|
|
|
@ -94,3 +94,10 @@ QtObject:
|
||||||
error "could not set display name"
|
error "could not set display name"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "error: ", procName="fetchWakuMessages", errName = e.name, errDesription = e.msg
|
error "error: ", procName="fetchWakuMessages", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
|
proc backupData*(self: Service): int64 =
|
||||||
|
try:
|
||||||
|
let response = status_general.backupData()
|
||||||
|
return response.result.getInt
|
||||||
|
except Exception as e:
|
||||||
|
error "error: ", procName="backupData", errName = e.name, errDesription = e.msg
|
|
@ -78,3 +78,7 @@ proc initKeystore*(keystoreDir: string): RpcResponse[JsonNode] {.raises: [Except
|
||||||
except RpcException as e:
|
except RpcException as e:
|
||||||
error "error", methodName = "initKeystore", exception=e.msg
|
error "error", methodName = "initKeystore", exception=e.msg
|
||||||
raise newException(RpcException, e.msg)
|
raise newException(RpcException, e.msg)
|
||||||
|
|
||||||
|
proc backupData*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
|
let payload = %* []
|
||||||
|
result = callPrivateRPC("backupData".prefix, payload)
|
|
@ -92,6 +92,8 @@ Item {
|
||||||
return qsTr("Community membership")
|
return qsTr("Community membership")
|
||||||
case Constants.onboarding.profileFetching.entity.settings:
|
case Constants.onboarding.profileFetching.entity.settings:
|
||||||
return qsTr("Settings")
|
return qsTr("Settings")
|
||||||
|
case Constants.onboarding.profileFetching.entity.keycards:
|
||||||
|
return qsTr("Keycards")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,7 @@ StatusSectionLayout {
|
||||||
implicitHeight: parent.height
|
implicitHeight: parent.height
|
||||||
|
|
||||||
devicesStore: root.store.devicesStore
|
devicesStore: root.store.devicesStore
|
||||||
|
privacyStore: root.store.privacyStore
|
||||||
sectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.devicesSettings)
|
sectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.devicesSettings)
|
||||||
contentWidth: d.contentWidth
|
contentWidth: d.contentWidth
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,8 @@ QtObject {
|
||||||
function tryRemoveFromKeyChain() {
|
function tryRemoveFromKeyChain() {
|
||||||
root.privacyModule.tryRemoveFromKeyChain()
|
root.privacyModule.tryRemoveFromKeyChain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function backupData() {
|
||||||
|
return root.privacyModule.backupData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ SettingsContentBase {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property DevicesStore devicesStore
|
property DevicesStore devicesStore
|
||||||
|
property PrivacyStore privacyStore
|
||||||
|
|
||||||
property bool isSyncing: false
|
property bool isSyncing: false
|
||||||
|
|
||||||
|
@ -229,6 +230,18 @@ SettingsContentBase {
|
||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusButton {
|
||||||
|
id: backupBtn
|
||||||
|
anchors.top: syncAllBtn.bottom
|
||||||
|
anchors.topMargin: Style.current.padding
|
||||||
|
anchors.horizontalCenter: listView.horizontalCenter
|
||||||
|
text: qsTr("Backup Data")
|
||||||
|
onClicked : {
|
||||||
|
let lastUpdate = root.privacyStore.backupData() * 1000
|
||||||
|
console.log("Backup done at: ", LocaleUtils.formatDateTime(lastUpdate))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
|
|
@ -364,6 +364,7 @@ QtObject {
|
||||||
readonly property string contacts: "contacts"
|
readonly property string contacts: "contacts"
|
||||||
readonly property string communities: "communities"
|
readonly property string communities: "communities"
|
||||||
readonly property string settings: "settings"
|
readonly property string settings: "settings"
|
||||||
|
readonly property string keycards: "keycards"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 60e1978bb5917078830aab13e1f2e1b3da17e865
|
Subproject commit 93de01e32e8e8bfa57e0c1f76b525b815cf0c08d
|
Loading…
Reference in New Issue