diff --git a/lib/types/backup-types.js b/lib/types/backup-types.js index fb71dcac5..493ff72ab 100644 --- a/lib/types/backup-types.js +++ b/lib/types/backup-types.js @@ -1,51 +1,60 @@ // @flow import type { TInterface } from 'tcomb'; import t from 'tcomb'; import { tShape } from '../utils/validation-utils.js'; // This type should match `SIWEBackupData` in // `native/native_rust_library/src/backup.rs` export type SIWEBackupData = { +siweBackupMsgNonce: string, +siweBackupMsgStatement: string, +siweBackupMsgIssuedAt: string, }; export const siweBackupDataValidator: TInterface = tShape({ siweBackupMsgNonce: t.String, siweBackupMsgStatement: t.String, siweBackupMsgIssuedAt: t.String, }); // This type should match `LatestBackupInfo` in // `native/native_rust_library/src/backup.rs` export type LatestBackupInfo = { +backupID: string, +userID: string, +siweBackupData?: ?SIWEBackupData, }; export const latestBackupInfoResponseValidator: TInterface = tShape({ backupID: t.String, userID: t.String, siweBackupData: t.maybe(siweBackupDataValidator), }); // This type should match `UserKeys` in // `native/native_rust_library/src/backup.rs` export type UserKeys = { +backupDataKey: string, +backupLogDataKey: string, +pickleKey: string, +pickledAccount: string, }; export const userKeysResponseValidator: TInterface = tShape( { backupDataKey: t.String, backupLogDataKey: t.String, pickleKey: t.String, pickledAccount: t.String, }, ); + +type LocalLatestBackupInfo = { + +backupID: string, + +timestamp: number, +}; + +export type BackupStore = { + +latestBackupInfo: ?LocalLatestBackupInfo, +}; diff --git a/native/redux/default-state.js b/native/redux/default-state.js index 3a91b6491..b4011570b 100644 --- a/native/redux/default-state.js +++ b/native/redux/default-state.js @@ -1,112 +1,115 @@ // @flow import { Platform } from 'react-native'; import Orientation from 'react-native-orientation-locker'; import { defaultAlertInfos } from 'lib/types/alert-types.js'; import { defaultEnabledApps } from 'lib/types/enabled-apps.js'; import { defaultCalendarFilters } from 'lib/types/filter-types.js'; import { defaultKeyserverInfo } from 'lib/types/keyserver-types.js'; import { defaultGlobalThemeInfo } from 'lib/types/theme-types.js'; import { defaultDimensionsInfo } from './dimensions-updater.react.js'; import type { AppState } from './state-types.js'; import { authoritativeKeyserverID } from '../authoritative-keyserver.js'; import { defaultNavInfo } from '../navigation/default-state.js'; import { defaultDeviceCameraInfo } from '../types/camera.js'; import { defaultConnectivityInfo } from '../types/connectivity.js'; import { defaultURLPrefix, natNodeServer } from '../utils/url-utils.js'; const defaultState = ({ navInfo: defaultNavInfo, currentUserInfo: null, draftStore: { drafts: {} }, entryStore: { entryInfos: {}, daysToEntries: {}, lastUserInteractionCalendar: 0, }, threadStore: { threadInfos: {}, }, userStore: { userInfos: {}, }, messageStore: { messages: {}, threads: {}, local: {}, currentAsOf: { [authoritativeKeyserverID]: 0 }, }, initialStateLoaded: false, loadingStatuses: {}, calendarFilters: defaultCalendarFilters, dataLoaded: false, customServer: natNodeServer, alertStore: { alertInfos: defaultAlertInfos, }, watchedThreadIDs: [], lifecycleState: 'active', enabledApps: defaultEnabledApps, reportStore: { enabledReports: { crashReports: __DEV__, inconsistencyReports: __DEV__, mediaReports: __DEV__, }, queuedReports: [], }, _persist: null, dimensions: defaultDimensionsInfo, connectivity: defaultConnectivityInfo, globalThemeInfo: defaultGlobalThemeInfo, deviceCameraInfo: defaultDeviceCameraInfo, deviceOrientation: Orientation.getInitialOrientation(), frozen: false, userPolicies: {}, commServicesAccessToken: null, inviteLinksStore: { links: {}, }, keyserverStore: { keyserverInfos: { [authoritativeKeyserverID]: defaultKeyserverInfo( defaultURLPrefix, Platform.OS, ), }, }, localSettings: { isBackupEnabled: false, }, threadActivityStore: {}, integrityStore: { threadHashes: {}, threadHashingStatus: 'starting' }, communityStore: { communityInfos: {}, }, auxUserStore: { auxUserInfos: {}, }, dbOpsStore: { queuedOps: [], }, syncedMetadataStore: { syncedMetadata: {}, }, tunnelbrokerDeviceToken: { localToken: null, tunnelbrokerToken: null, }, queuedDMOperations: { threadQueue: {}, messageQueue: {}, entryQueue: {}, membershipQueue: {}, }, holderStore: { storedHolders: {}, }, + backupStore: { + latestBackupInfo: null, + }, }: AppState); export { defaultState }; diff --git a/native/redux/state-types.js b/native/redux/state-types.js index 9650cfe2e..fab9e8cd8 100644 --- a/native/redux/state-types.js +++ b/native/redux/state-types.js @@ -1,93 +1,95 @@ // @flow import type { Orientations } from 'react-native-orientation-locker'; import type { PersistState } from 'redux-persist/es/types.js'; import type { AlertStore } from 'lib/types/alert-types.js'; import type { AuxUserStore } from 'lib/types/aux-user-types.js'; +import type { BackupStore } from 'lib/types/backup-types.js'; import type { CommunityStore } from 'lib/types/community-types.js'; import type { DBOpsStore } from 'lib/types/db-ops-types'; import type { QueuedDMOperations } from 'lib/types/dm-ops'; import type { DraftStore } from 'lib/types/draft-types.js'; import type { EnabledApps } from 'lib/types/enabled-apps.js'; import type { EntryStore } from 'lib/types/entry-types.js'; import type { CalendarFilter } from 'lib/types/filter-types.js'; import type { HolderStore } from 'lib/types/holder-types.js'; import type { IntegrityStore } from 'lib/types/integrity-types.js'; import type { KeyserverStore } from 'lib/types/keyserver-types.js'; import type { LifecycleState } from 'lib/types/lifecycle-state-types.js'; import type { InviteLinksStore } from 'lib/types/link-types.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; import type { MessageStore } from 'lib/types/message-types.js'; import type { UserPolicies } from 'lib/types/policy-types.js'; import type { ReportStore } from 'lib/types/report-types.js'; import type { SyncedMetadataStore } from 'lib/types/synced-metadata-types.js'; import type { GlobalThemeInfo } from 'lib/types/theme-types.js'; import type { ThreadActivityStore } from 'lib/types/thread-activity-types'; import type { ThreadStore } from 'lib/types/thread-types.js'; import type { TunnelbrokerDeviceToken } from 'lib/types/tunnelbroker-device-token-types'; import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js'; import type { DimensionsInfo } from './dimensions-updater.react.js'; import type { NavInfo } from '../navigation/default-state.js'; import type { DeviceCameraInfo } from '../types/camera.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; import type { LocalSettings } from '../types/local-settings-types.js'; const nonUserSpecificFieldsNative = [ 'initialStateLoaded', 'loadingStatuses', 'customServer', 'lifecycleState', 'dimensions', 'connectivity', 'deviceCameraInfo', 'deviceOrientation', 'frozen', 'keyserverStore', '_persist', 'commServicesAccessToken', ]; export type AppState = { +navInfo: NavInfo, +currentUserInfo: ?CurrentUserInfo, +draftStore: DraftStore, +entryStore: EntryStore, +threadStore: ThreadStore, +userStore: UserStore, +messageStore: MessageStore, +initialStateLoaded: boolean, +loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } }, +calendarFilters: $ReadOnlyArray, +dataLoaded: boolean, +customServer: ?string, +alertStore: AlertStore, +watchedThreadIDs: $ReadOnlyArray, +lifecycleState: LifecycleState, +enabledApps: EnabledApps, +reportStore: ReportStore, +_persist: ?PersistState, +dimensions: DimensionsInfo, +connectivity: ConnectivityInfo, +globalThemeInfo: GlobalThemeInfo, +deviceCameraInfo: DeviceCameraInfo, +deviceOrientation: Orientations, +frozen: boolean, +userPolicies: UserPolicies, +commServicesAccessToken: ?string, +inviteLinksStore: InviteLinksStore, +keyserverStore: KeyserverStore, +threadActivityStore: ThreadActivityStore, +localSettings: LocalSettings, +integrityStore: IntegrityStore, +communityStore: CommunityStore, +dbOpsStore: DBOpsStore, +syncedMetadataStore: SyncedMetadataStore, +auxUserStore: AuxUserStore, +tunnelbrokerDeviceToken: TunnelbrokerDeviceToken, +queuedDMOperations: QueuedDMOperations, +holderStore: HolderStore, + +backupStore: BackupStore, }; export { nonUserSpecificFieldsNative };