feat: file backups (#1024)

This commit is contained in:
Mo
2022-05-12 18:26:11 -05:00
committed by GitHub
parent b671ecb2b9
commit 942226e15a
20 changed files with 499 additions and 207 deletions

View File

@@ -1,11 +0,0 @@
import { DeviceInterface, Environment } from '@standardnotes/snjs'
import { WebClientRequiresDesktopMethods } from './DesktopWebCommunication'
import { WebOrDesktopDeviceInterface } from './WebOrDesktopDeviceInterface'
export function isDesktopDevice(x: DeviceInterface): x is DesktopDeviceInterface {
return x.environment === Environment.Desktop
}
export interface DesktopDeviceInterface extends WebOrDesktopDeviceInterface, WebClientRequiresDesktopMethods {
environment: Environment.Desktop
}

View File

@@ -1 +1,9 @@
export { Environment, RawKeychainValue } from '@standardnotes/snjs'
export {
Environment,
RawKeychainValue,
DesktopDeviceInterface,
WebOrDesktopDeviceInterface,
DesktopClientRequiresWebMethods,
FileBackupsMapping,
FileBackupsDevice,
} from '@standardnotes/snjs'

View File

@@ -1,42 +0,0 @@
import { DecryptedTransferPayload } from '@standardnotes/snjs'
export interface WebClientRequiresDesktopMethods {
localBackupsCount(): Promise<number>
viewlocalBackups(): void
deleteLocalBackups(): Promise<void>
syncComponents(payloads: unknown[]): void
onMajorDataChange(): void
onInitialDataLoad(): void
/**
* Destroys all sensitive storage data, such as localStorage, IndexedDB, and other log files.
*/
destroyAllData(): void
onSearch(text?: string): void
downloadBackup(): void | Promise<void>
get extensionsServerHost(): string
}
export interface DesktopClientRequiresWebMethods {
updateAvailable(): void
windowGainedFocus(): void
windowLostFocus(): void
onComponentInstallationComplete(componentData: DecryptedTransferPayload, error: unknown): Promise<void>
requestBackupFile(): Promise<string | undefined>
didBeginBackup(): void
didFinishBackup(success: boolean): void
}

View File

@@ -1,5 +1,5 @@
import { Environment, RawKeychainValue } from '@standardnotes/snjs'
import { WebOrDesktopDevice } from '@/Device/WebOrDesktopDevice'
import { WebOrDesktopDevice } from './WebOrDesktopDevice'
const KEYCHAIN_STORAGE_KEY = 'keychain'

View File

@@ -7,9 +7,9 @@ import {
TransferPayload,
NamespacedRootKeyInKeychain,
extendArray,
WebOrDesktopDeviceInterface,
} from '@standardnotes/snjs'
import { Database } from '../Database'
import { WebOrDesktopDeviceInterface } from './WebOrDesktopDeviceInterface'
export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface {
constructor(public appVersion: string) {}
@@ -18,7 +18,7 @@ export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface
abstract environment: Environment
setApplication(application: SNApplication) {
setApplication(application: SNApplication): void {
const database = new Database(application.identifier, application.alertService)
this.databases.push(database)

View File

@@ -1,9 +0,0 @@
import { DeviceInterface, RawKeychainValue } from '@standardnotes/snjs'
export interface WebOrDesktopDeviceInterface extends DeviceInterface {
readonly appVersion: string
getKeychainValue(): Promise<RawKeychainValue>
setKeychainValue(value: RawKeychainValue): Promise<void>
}