feat(files): refactor circular deps
This commit is contained in:
@@ -35,7 +35,6 @@
|
|||||||
"@standardnotes/filepicker": "workspace:*",
|
"@standardnotes/filepicker": "workspace:*",
|
||||||
"@standardnotes/models": "workspace:*",
|
"@standardnotes/models": "workspace:*",
|
||||||
"@standardnotes/responses": "workspace:*",
|
"@standardnotes/responses": "workspace:*",
|
||||||
"@standardnotes/services": "workspace:*",
|
|
||||||
"@standardnotes/sncrypto-common": "workspace:*",
|
"@standardnotes/sncrypto-common": "workspace:*",
|
||||||
"@standardnotes/utils": "workspace:*",
|
"@standardnotes/utils": "workspace:*",
|
||||||
"reflect-metadata": "^0.1.13"
|
"reflect-metadata": "^0.1.13"
|
||||||
|
|||||||
3
packages/files/src/Domain/Api/DirectoryHandle.ts
Normal file
3
packages/files/src/Domain/Api/DirectoryHandle.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export interface DirectoryHandle {
|
||||||
|
nativeHandle: unknown
|
||||||
|
}
|
||||||
3
packages/files/src/Domain/Api/FileHandleRead.ts
Normal file
3
packages/files/src/Domain/Api/FileHandleRead.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export interface FileHandleRead {
|
||||||
|
nativeHandle: unknown
|
||||||
|
}
|
||||||
4
packages/files/src/Domain/Api/FileHandleReadWrite.ts
Normal file
4
packages/files/src/Domain/Api/FileHandleReadWrite.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export interface FileHandleReadWrite {
|
||||||
|
nativeHandle: unknown
|
||||||
|
writableStream: unknown
|
||||||
|
}
|
||||||
@@ -1,16 +1,8 @@
|
|||||||
export interface DirectoryHandle {
|
import { DirectoryHandle } from './DirectoryHandle'
|
||||||
nativeHandle: unknown
|
import { FileHandleRead } from './FileHandleRead'
|
||||||
}
|
import { FileHandleReadWrite } from './FileHandleReadWrite'
|
||||||
export interface FileHandleReadWrite {
|
import { FileSystemNoSelection } from './FileSystemNoSelection'
|
||||||
nativeHandle: unknown
|
import { FileSystemResult } from './FileSystemResult'
|
||||||
writableStream: unknown
|
|
||||||
}
|
|
||||||
export interface FileHandleRead {
|
|
||||||
nativeHandle: unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FileSystemResult = 'aborted' | 'success' | 'failed'
|
|
||||||
export type FileSystemNoSelection = 'aborted' | 'failed'
|
|
||||||
|
|
||||||
export interface FileSystemApi {
|
export interface FileSystemApi {
|
||||||
selectDirectory(): Promise<DirectoryHandle | FileSystemNoSelection>
|
selectDirectory(): Promise<DirectoryHandle | FileSystemNoSelection>
|
||||||
1
packages/files/src/Domain/Api/FileSystemNoSelection.ts
Normal file
1
packages/files/src/Domain/Api/FileSystemNoSelection.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export type FileSystemNoSelection = 'aborted' | 'failed'
|
||||||
1
packages/files/src/Domain/Api/FileSystemResult.ts
Normal file
1
packages/files/src/Domain/Api/FileSystemResult.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export type FileSystemResult = 'aborted' | 'success' | 'failed'
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { BackupFileEncryptedContextualPayload } from '@standardnotes/models'
|
||||||
|
|
||||||
|
export interface FileBackupMetadataFile {
|
||||||
|
info: Record<string, string>
|
||||||
|
file: BackupFileEncryptedContextualPayload
|
||||||
|
itemsKey: BackupFileEncryptedContextualPayload
|
||||||
|
version: '1.0.0'
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export const FileBackupsConstantsV1 = {
|
||||||
|
Version: '1.0.0',
|
||||||
|
MetadataFileName: 'metadata.sn.json',
|
||||||
|
BinaryFileName: 'file.encrypted',
|
||||||
|
}
|
||||||
21
packages/files/src/Domain/Device/FileBackupsDevice.ts
Normal file
21
packages/files/src/Domain/Device/FileBackupsDevice.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Uuid } from '@standardnotes/common'
|
||||||
|
import { FileBackupsMapping } from './FileBackupsMapping'
|
||||||
|
|
||||||
|
export interface FileBackupsDevice {
|
||||||
|
getFilesBackupsMappingFile(): Promise<FileBackupsMapping>
|
||||||
|
saveFilesBackupsFile(
|
||||||
|
uuid: Uuid,
|
||||||
|
metaFile: string,
|
||||||
|
downloadRequest: {
|
||||||
|
chunkSizes: number[]
|
||||||
|
valetToken: string
|
||||||
|
url: string
|
||||||
|
},
|
||||||
|
): Promise<'success' | 'failed'>
|
||||||
|
isFilesBackupsEnabled(): Promise<boolean>
|
||||||
|
enableFilesBackups(): Promise<void>
|
||||||
|
disableFilesBackups(): Promise<void>
|
||||||
|
changeFilesBackupsLocation(): Promise<string | undefined>
|
||||||
|
getFilesBackupsLocation(): Promise<string>
|
||||||
|
openFilesBackupsLocation(): Promise<void>
|
||||||
|
}
|
||||||
17
packages/files/src/Domain/Device/FileBackupsMapping.ts
Normal file
17
packages/files/src/Domain/Device/FileBackupsMapping.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Uuid } from '@standardnotes/common'
|
||||||
|
import { FileBackupsConstantsV1 } from './FileBackupsConstantsV1'
|
||||||
|
|
||||||
|
export interface FileBackupsMapping {
|
||||||
|
version: typeof FileBackupsConstantsV1.Version
|
||||||
|
files: Record<
|
||||||
|
Uuid,
|
||||||
|
{
|
||||||
|
backedUpOn: Date
|
||||||
|
absolutePath: string
|
||||||
|
relativePath: string
|
||||||
|
metadataFileName: typeof FileBackupsConstantsV1.MetadataFileName
|
||||||
|
binaryFileName: typeof FileBackupsConstantsV1.BinaryFileName
|
||||||
|
version: typeof FileBackupsConstantsV1.Version
|
||||||
|
}
|
||||||
|
>
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { sleep } from '@standardnotes/utils'
|
import { sleep } from '@standardnotes/utils'
|
||||||
import { PureCryptoInterface, StreamEncryptor } from '@standardnotes/sncrypto-common'
|
import { PureCryptoInterface, StreamEncryptor } from '@standardnotes/sncrypto-common'
|
||||||
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
||||||
import { FilesApiInterface } from '@standardnotes/services'
|
|
||||||
import { DownloadAndDecryptFileOperation } from './DownloadAndDecrypt'
|
import { DownloadAndDecryptFileOperation } from './DownloadAndDecrypt'
|
||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
|
|
||||||
describe('download and decrypt', () => {
|
describe('download and decrypt', () => {
|
||||||
let apiService: FilesApiInterface
|
let apiService: FilesApiInterface
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import { ClientDisplayableError } from '@standardnotes/responses'
|
|||||||
import { AbortFunction, FileDownloader } from '../UseCase/FileDownloader'
|
import { AbortFunction, FileDownloader } from '../UseCase/FileDownloader'
|
||||||
import { FileDecryptor } from '../UseCase/FileDecryptor'
|
import { FileDecryptor } from '../UseCase/FileDecryptor'
|
||||||
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
||||||
import { FilesApiInterface } from '@standardnotes/services'
|
|
||||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
import { DecryptedBytes, EncryptedBytes } from '@standardnotes/filepicker'
|
import { DecryptedBytes, EncryptedBytes } from '@standardnotes/filepicker'
|
||||||
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
|
|
||||||
export type DownloadAndDecryptResult = { success: boolean; error?: ClientDisplayableError; aborted?: boolean }
|
export type DownloadAndDecryptResult = { success: boolean; error?: ClientDisplayableError; aborted?: boolean }
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { EncryptAndUploadFileOperation } from './EncryptAndUpload'
|
import { EncryptAndUploadFileOperation } from './EncryptAndUpload'
|
||||||
import { PureCryptoInterface, StreamEncryptor } from '@standardnotes/sncrypto-common'
|
import { PureCryptoInterface, StreamEncryptor } from '@standardnotes/sncrypto-common'
|
||||||
import { FilesApiInterface } from '@standardnotes/services'
|
|
||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
|
|
||||||
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
|
|
||||||
describe('encrypt and upload', () => {
|
describe('encrypt and upload', () => {
|
||||||
let apiService: FilesApiInterface
|
let apiService: FilesApiInterface
|
||||||
let operation: EncryptAndUploadFileOperation
|
let operation: EncryptAndUploadFileOperation
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { FileUploadProgress } from '../Types/FileUploadProgress'
|
import { FileUploadProgress } from '../Types/FileUploadProgress'
|
||||||
import { FileUploadResult } from '../Types/FileUploadResult'
|
import { FileUploadResult } from '../Types/FileUploadResult'
|
||||||
import { FilesApiInterface } from '@standardnotes/services'
|
|
||||||
import { FileUploader } from '../UseCase/FileUploader'
|
import { FileUploader } from '../UseCase/FileUploader'
|
||||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||||
import { FileEncryptor } from '../UseCase/FileEncryptor'
|
import { FileEncryptor } from '../UseCase/FileEncryptor'
|
||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
|
|
||||||
export class EncryptAndUploadFileOperation {
|
export class EncryptAndUploadFileOperation {
|
||||||
public readonly encryptedChunkSizes: number[] = []
|
public readonly encryptedChunkSizes: number[] = []
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import { EncryptAndUploadFileOperation } from '../Operations/EncryptAndUpload'
|
|||||||
import { FileItem, FileMetadata } from '@standardnotes/models'
|
import { FileItem, FileMetadata } from '@standardnotes/models'
|
||||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||||
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
||||||
import { FileSystemApi, FileBackupMetadataFile, FileHandleRead, FileSystemNoSelection } from '@standardnotes/services'
|
import { FileSystemApi } from '../Api/FileSystemApi'
|
||||||
|
import { FileHandleRead } from '../Api/FileHandleRead'
|
||||||
|
import { FileSystemNoSelection } from '../Api/FileSystemNoSelection'
|
||||||
|
import { FileBackupMetadataFile } from '../Device/FileBackupMetadataFile'
|
||||||
|
|
||||||
export interface FilesClientInterface {
|
export interface FilesClientInterface {
|
||||||
beginNewFileUpload(sizeInBytes: number): Promise<EncryptAndUploadFileOperation | ClientDisplayableError>
|
beginNewFileUpload(sizeInBytes: number): Promise<EncryptAndUploadFileOperation | ClientDisplayableError>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
import { FileSystemApi, FileHandleRead } from '@standardnotes/services'
|
|
||||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||||
import { OrderedByteChunker } from '@standardnotes/filepicker'
|
import { OrderedByteChunker } from '@standardnotes/filepicker'
|
||||||
import { FileDecryptor } from '../UseCase/FileDecryptor'
|
import { FileDecryptor } from '../UseCase/FileDecryptor'
|
||||||
|
import { FileSystemApi } from '../Api/FileSystemApi'
|
||||||
|
import { FileHandleRead } from '../Api/FileHandleRead'
|
||||||
|
|
||||||
export async function readAndDecryptBackupFile(
|
export async function readAndDecryptBackupFile(
|
||||||
fileHandle: FileHandleRead,
|
fileHandle: FileHandleRead,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
import { FilesApiInterface } from '@standardnotes/services'
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
import { FileDownloader } from './FileDownloader'
|
import { FileDownloader } from './FileDownloader'
|
||||||
|
|
||||||
describe('file downloader', () => {
|
describe('file downloader', () => {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||||
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
||||||
import { FilesApiInterface } from '@standardnotes/services'
|
|
||||||
import { Deferred } from '@standardnotes/utils'
|
import { Deferred } from '@standardnotes/utils'
|
||||||
import { FileContent } from '@standardnotes/models'
|
import { FileContent } from '@standardnotes/models'
|
||||||
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
|
|
||||||
export type AbortSignal = 'aborted'
|
export type AbortSignal = 'aborted'
|
||||||
export type AbortFunction = () => void
|
export type AbortFunction = () => void
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FilesApiInterface } from '@standardnotes/services'
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
import { FileUploader } from './FileUploader'
|
import { FileUploader } from './FileUploader'
|
||||||
|
|
||||||
describe('file uploader', () => {
|
describe('file uploader', () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FilesApiInterface } from '@standardnotes/services'
|
import { FilesApiInterface } from '../Api/FilesApiInterface'
|
||||||
|
|
||||||
export class FileUploader {
|
export class FileUploader {
|
||||||
constructor(private apiService: FilesApiInterface) {}
|
constructor(private apiService: FilesApiInterface) {}
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
export * from './Service/FileService'
|
export * from './Api/DirectoryHandle'
|
||||||
|
export * from './Api/FileHandleRead'
|
||||||
|
export * from './Api/FileHandleReadWrite'
|
||||||
|
export * from './Api/FileSystemApi'
|
||||||
|
export * from './Api/FileSystemNoSelection'
|
||||||
|
export * from './Api/FileSystemResult'
|
||||||
|
export * from './Api/FilesApiInterface'
|
||||||
|
export * from './Device/FileBackupMetadataFile'
|
||||||
|
export * from './Device/FileBackupsConstantsV1'
|
||||||
|
export * from './Device/FileBackupsDevice'
|
||||||
|
export * from './Device/FileBackupsMapping'
|
||||||
export * from './Service/FilesClientInterface'
|
export * from './Service/FilesClientInterface'
|
||||||
|
export * from './Service/ReadAndDecryptBackupFile'
|
||||||
export * from './Operations/DownloadAndDecrypt'
|
export * from './Operations/DownloadAndDecrypt'
|
||||||
export * from './Operations/EncryptAndUpload'
|
export * from './Operations/EncryptAndUpload'
|
||||||
export * from './UseCase/FileDecryptor'
|
export * from './UseCase/FileDecryptor'
|
||||||
@@ -9,4 +20,3 @@ export * from './UseCase/FileDownloader'
|
|||||||
export * from './Types/FileDownloadProgress'
|
export * from './Types/FileDownloadProgress'
|
||||||
export * from './Types/FileUploadProgress'
|
export * from './Types/FileUploadProgress'
|
||||||
export * from './Types/FileUploadResult'
|
export * from './Types/FileUploadResult'
|
||||||
export * from './Backups/BackupService'
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@standardnotes/auth": "^3.19.4",
|
"@standardnotes/auth": "^3.19.4",
|
||||||
"@standardnotes/common": "^1.30.0",
|
"@standardnotes/common": "^1.30.0",
|
||||||
|
"@standardnotes/files": "workspace:^",
|
||||||
"@standardnotes/models": "workspace:^",
|
"@standardnotes/models": "workspace:^",
|
||||||
"@standardnotes/responses": "workspace:*",
|
"@standardnotes/responses": "workspace:*",
|
||||||
"@standardnotes/security": "^1.2.0",
|
"@standardnotes/security": "^1.2.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AbstractService } from '../Service/AbstractService'
|
import { AbstractService } from '../Service/AbstractService'
|
||||||
import { Uuid } from '@standardnotes/common'
|
import { Uuid } from '@standardnotes/common'
|
||||||
import { Role } from '@standardnotes/auth'
|
import { Role } from '@standardnotes/auth'
|
||||||
import { FilesApiInterface } from '../Files/FilesApiInterface'
|
import { FilesApiInterface } from '@standardnotes/files'
|
||||||
|
|
||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import { ApplicationIdentifier, ContentType } from '@standardnotes/common'
|
import { ApplicationIdentifier, ContentType } from '@standardnotes/common'
|
||||||
import { BackupFile, DecryptedItemInterface, ItemStream, PrefKey, PrefValue } from '@standardnotes/models'
|
import { BackupFile, DecryptedItemInterface, ItemStream, PrefKey, PrefValue } from '@standardnotes/models'
|
||||||
|
import { FilesClientInterface } from '@standardnotes/files'
|
||||||
|
import { AlertService } from '../Alert/AlertService'
|
||||||
|
|
||||||
import { ComponentManagerInterface } from '../Component/ComponentManagerInterface'
|
import { ComponentManagerInterface } from '../Component/ComponentManagerInterface'
|
||||||
|
import { Platform } from '../Device/Environments'
|
||||||
import { ApplicationEvent } from '../Event/ApplicationEvent'
|
import { ApplicationEvent } from '../Event/ApplicationEvent'
|
||||||
import { ApplicationEventCallback } from '../Event/ApplicationEventCallback'
|
import { ApplicationEventCallback } from '../Event/ApplicationEventCallback'
|
||||||
import { FeaturesClientInterface } from '../Feature/FeaturesClientInterface'
|
import { FeaturesClientInterface } from '../Feature/FeaturesClientInterface'
|
||||||
@@ -12,6 +15,7 @@ import { StorageValueModes } from '../Storage/StorageTypes'
|
|||||||
import { DeinitMode } from './DeinitMode'
|
import { DeinitMode } from './DeinitMode'
|
||||||
import { DeinitSource } from './DeinitSource'
|
import { DeinitSource } from './DeinitSource'
|
||||||
import { UserClientInterface } from './UserClientInterface'
|
import { UserClientInterface } from './UserClientInterface'
|
||||||
|
import { DeviceInterface } from '../Device/DeviceInterface'
|
||||||
|
|
||||||
export interface ApplicationInterface {
|
export interface ApplicationInterface {
|
||||||
deinit(mode: DeinitMode, source: DeinitSource): void
|
deinit(mode: DeinitMode, source: DeinitSource): void
|
||||||
@@ -21,6 +25,7 @@ export interface ApplicationInterface {
|
|||||||
addEventObserver(callback: ApplicationEventCallback, singleEvent?: ApplicationEvent): () => void
|
addEventObserver(callback: ApplicationEventCallback, singleEvent?: ApplicationEvent): () => void
|
||||||
hasProtectionSources(): boolean
|
hasProtectionSources(): boolean
|
||||||
createEncryptedBackupFileForAutomatedDesktopBackups(): Promise<BackupFile | undefined>
|
createEncryptedBackupFileForAutomatedDesktopBackups(): Promise<BackupFile | undefined>
|
||||||
|
createEncryptedBackupFile(): Promise<BackupFile | undefined>
|
||||||
createDecryptedBackupFile(): Promise<BackupFile | undefined>
|
createDecryptedBackupFile(): Promise<BackupFile | undefined>
|
||||||
hasPasscode(): boolean
|
hasPasscode(): boolean
|
||||||
lock(): Promise<void>
|
lock(): Promise<void>
|
||||||
@@ -31,14 +36,20 @@ export interface ApplicationInterface {
|
|||||||
getPreference<K extends PrefKey>(key: K): PrefValue[K] | undefined
|
getPreference<K extends PrefKey>(key: K): PrefValue[K] | undefined
|
||||||
getPreference<K extends PrefKey>(key: K, defaultValue: PrefValue[K]): PrefValue[K]
|
getPreference<K extends PrefKey>(key: K, defaultValue: PrefValue[K]): PrefValue[K]
|
||||||
getPreference<K extends PrefKey>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] | undefined
|
getPreference<K extends PrefKey>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] | undefined
|
||||||
|
setPreference<K extends PrefKey>(key: K, value: PrefValue[K]): Promise<void>
|
||||||
streamItems<I extends DecryptedItemInterface = DecryptedItemInterface>(
|
streamItems<I extends DecryptedItemInterface = DecryptedItemInterface>(
|
||||||
contentType: ContentType | ContentType[],
|
contentType: ContentType | ContentType[],
|
||||||
stream: ItemStream<I>,
|
stream: ItemStream<I>,
|
||||||
): () => void
|
): () => void
|
||||||
|
hasAccount(): boolean
|
||||||
get features(): FeaturesClientInterface
|
get features(): FeaturesClientInterface
|
||||||
get componentManager(): ComponentManagerInterface
|
get componentManager(): ComponentManagerInterface
|
||||||
get items(): ItemsClientInterface
|
get items(): ItemsClientInterface
|
||||||
get mutator(): MutatorClientInterface
|
get mutator(): MutatorClientInterface
|
||||||
get user(): UserClientInterface
|
get user(): UserClientInterface
|
||||||
|
get files(): FilesClientInterface
|
||||||
readonly identifier: ApplicationIdentifier
|
readonly identifier: ApplicationIdentifier
|
||||||
|
readonly platform: Platform
|
||||||
|
deviceInterface: DeviceInterface
|
||||||
|
alertService: AlertService
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,12 @@ import { ContentType, Uuid } from '@standardnotes/common'
|
|||||||
import { EncryptionProvider } from '@standardnotes/encryption'
|
import { EncryptionProvider } from '@standardnotes/encryption'
|
||||||
import { PayloadEmitSource, FileItem, CreateEncryptedBackupFileContextPayload } from '@standardnotes/models'
|
import { PayloadEmitSource, FileItem, CreateEncryptedBackupFileContextPayload } from '@standardnotes/models'
|
||||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||||
import {
|
import { FileBackupMetadataFile, FileBackupsDevice, FileBackupsMapping } from '../Device/FileBackupsDevice'
|
||||||
ItemManagerInterface,
|
import { FilesApiInterface } from '@standardnotes/files'
|
||||||
FileBackupsDevice,
|
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
|
||||||
FileBackupsMapping,
|
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
|
||||||
AbstractService,
|
import { AbstractService } from '../Service/AbstractService'
|
||||||
InternalEventBusInterface,
|
import { StatusServiceInterface } from '../Status/StatusServiceInterface'
|
||||||
StatusServiceInterface,
|
|
||||||
FileBackupMetadataFile,
|
|
||||||
FilesApiInterface,
|
|
||||||
} from '@standardnotes/services'
|
|
||||||
|
|
||||||
export class FilesBackupService extends AbstractService {
|
export class FilesBackupService extends AbstractService {
|
||||||
private itemsObserverDisposer: () => void
|
private itemsObserverDisposer: () => void
|
||||||
@@ -20,4 +20,5 @@ export interface ComponentManagerInterface {
|
|||||||
urlOverride?: string,
|
urlOverride?: string,
|
||||||
): ComponentViewerInterface
|
): ComponentViewerInterface
|
||||||
presentPermissionsDialog(_dialog: PermissionDialog): void
|
presentPermissionsDialog(_dialog: PermissionDialog): void
|
||||||
|
getDefaultEditor(): SNComponent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import { Uuid } from '@standardnotes/common'
|
|
||||||
import { BackupFileEncryptedContextualPayload } from '@standardnotes/models'
|
|
||||||
|
|
||||||
/* istanbul ignore file */
|
|
||||||
|
|
||||||
export const FileBackupsConstantsV1 = {
|
|
||||||
Version: '1.0.0',
|
|
||||||
MetadataFileName: 'metadata.sn.json',
|
|
||||||
BinaryFileName: 'file.encrypted',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileBackupMetadataFile {
|
|
||||||
info: Record<string, string>
|
|
||||||
file: BackupFileEncryptedContextualPayload
|
|
||||||
itemsKey: BackupFileEncryptedContextualPayload
|
|
||||||
version: '1.0.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileBackupsMapping {
|
|
||||||
version: typeof FileBackupsConstantsV1.Version
|
|
||||||
files: Record<
|
|
||||||
Uuid,
|
|
||||||
{
|
|
||||||
backedUpOn: Date
|
|
||||||
absolutePath: string
|
|
||||||
relativePath: string
|
|
||||||
metadataFileName: typeof FileBackupsConstantsV1.MetadataFileName
|
|
||||||
binaryFileName: typeof FileBackupsConstantsV1.BinaryFileName
|
|
||||||
version: typeof FileBackupsConstantsV1.Version
|
|
||||||
}
|
|
||||||
>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileBackupsDevice {
|
|
||||||
getFilesBackupsMappingFile(): Promise<FileBackupsMapping>
|
|
||||||
saveFilesBackupsFile(
|
|
||||||
uuid: Uuid,
|
|
||||||
metaFile: string,
|
|
||||||
downloadRequest: {
|
|
||||||
chunkSizes: number[]
|
|
||||||
valetToken: string
|
|
||||||
url: string
|
|
||||||
},
|
|
||||||
): Promise<'success' | 'failed'>
|
|
||||||
isFilesBackupsEnabled(): Promise<boolean>
|
|
||||||
enableFilesBackups(): Promise<void>
|
|
||||||
disableFilesBackups(): Promise<void>
|
|
||||||
changeFilesBackupsLocation(): Promise<string | undefined>
|
|
||||||
getFilesBackupsLocation(): Promise<string>
|
|
||||||
openFilesBackupsLocation(): Promise<void>
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import { DecryptedBytes, EncryptedBytes, FileMemoryCache, OrderedByteChunker } from '@standardnotes/filepicker'
|
import { DecryptedBytes, EncryptedBytes, FileMemoryCache, OrderedByteChunker } from '@standardnotes/filepicker'
|
||||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||||
import { ContentType } from '@standardnotes/common'
|
import { ContentType } from '@standardnotes/common'
|
||||||
import { DownloadAndDecryptFileOperation } from '../Operations/DownloadAndDecrypt'
|
|
||||||
import { EncryptAndUploadFileOperation } from '../Operations/EncryptAndUpload'
|
|
||||||
import {
|
import {
|
||||||
FileItem,
|
FileItem,
|
||||||
FileProtocolV1Constants,
|
FileProtocolV1Constants,
|
||||||
@@ -29,11 +27,15 @@ import {
|
|||||||
ChallengeServiceInterface,
|
ChallengeServiceInterface,
|
||||||
FileBackupsConstantsV1,
|
FileBackupsConstantsV1,
|
||||||
} from '@standardnotes/services'
|
} from '@standardnotes/services'
|
||||||
import { FilesClientInterface } from './FilesClientInterface'
|
|
||||||
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
|
||||||
import { readAndDecryptBackupFile } from './ReadAndDecryptBackupFile'
|
|
||||||
import { DecryptItemsKeyWithUserFallback, EncryptionProvider, SNItemsKey } from '@standardnotes/encryption'
|
import { DecryptItemsKeyWithUserFallback, EncryptionProvider, SNItemsKey } from '@standardnotes/encryption'
|
||||||
import { FileDecryptor } from '../UseCase/FileDecryptor'
|
import {
|
||||||
|
DownloadAndDecryptFileOperation,
|
||||||
|
EncryptAndUploadFileOperation,
|
||||||
|
FileDecryptor,
|
||||||
|
FileDownloadProgress,
|
||||||
|
FilesClientInterface,
|
||||||
|
readAndDecryptBackupFile,
|
||||||
|
} from '@standardnotes/files'
|
||||||
|
|
||||||
const OneHundredMb = 100 * 1_000_000
|
const OneHundredMb = 100 * 1_000_000
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ export * from './Application/DeinitSource'
|
|||||||
export * from './Application/DeinitMode'
|
export * from './Application/DeinitMode'
|
||||||
export * from './Application/UserClientInterface'
|
export * from './Application/UserClientInterface'
|
||||||
export * from './Application/WebApplicationInterface'
|
export * from './Application/WebApplicationInterface'
|
||||||
|
export * from './Backups/BackupService'
|
||||||
export * from './Challenge'
|
export * from './Challenge'
|
||||||
export * from './Component/ComponentManagerInterface'
|
export * from './Component/ComponentManagerInterface'
|
||||||
export * from './Component/ComponentViewerError'
|
export * from './Component/ComponentViewerError'
|
||||||
@@ -33,8 +34,6 @@ export * from './Feature/FeaturesClientInterface'
|
|||||||
export * from './Feature/FeaturesEvent'
|
export * from './Feature/FeaturesEvent'
|
||||||
export * from './Feature/OfflineSubscriptionEntitlements'
|
export * from './Feature/OfflineSubscriptionEntitlements'
|
||||||
export * from './Feature/SetOfflineFeaturesFunctionResponse'
|
export * from './Feature/SetOfflineFeaturesFunctionResponse'
|
||||||
export * from './Files/FilesApiInterface'
|
|
||||||
export * from './FileSystem/FileSystemApi'
|
|
||||||
export * from './Integrity/IntegrityApiInterface'
|
export * from './Integrity/IntegrityApiInterface'
|
||||||
export * from './Integrity/IntegrityEvent'
|
export * from './Integrity/IntegrityEvent'
|
||||||
export * from './Integrity/IntegrityEventPayload'
|
export * from './Integrity/IntegrityEventPayload'
|
||||||
|
|||||||
@@ -6653,7 +6653,7 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
"@standardnotes/files@workspace:*, @standardnotes/files@workspace:packages/files":
|
"@standardnotes/files@workspace:*, @standardnotes/files@workspace:^, @standardnotes/files@workspace:packages/files":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@standardnotes/files@workspace:packages/files"
|
resolution: "@standardnotes/files@workspace:packages/files"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -6662,7 +6662,6 @@ __metadata:
|
|||||||
"@standardnotes/filepicker": "workspace:*"
|
"@standardnotes/filepicker": "workspace:*"
|
||||||
"@standardnotes/models": "workspace:*"
|
"@standardnotes/models": "workspace:*"
|
||||||
"@standardnotes/responses": "workspace:*"
|
"@standardnotes/responses": "workspace:*"
|
||||||
"@standardnotes/services": "workspace:*"
|
|
||||||
"@standardnotes/sncrypto-common": "workspace:*"
|
"@standardnotes/sncrypto-common": "workspace:*"
|
||||||
"@standardnotes/utils": "workspace:*"
|
"@standardnotes/utils": "workspace:*"
|
||||||
"@types/jest": ^28.1.5
|
"@types/jest": ^28.1.5
|
||||||
@@ -7182,6 +7181,7 @@ __metadata:
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@standardnotes/auth": ^3.19.4
|
"@standardnotes/auth": ^3.19.4
|
||||||
"@standardnotes/common": ^1.30.0
|
"@standardnotes/common": ^1.30.0
|
||||||
|
"@standardnotes/files": "workspace:^"
|
||||||
"@standardnotes/models": "workspace:^"
|
"@standardnotes/models": "workspace:^"
|
||||||
"@standardnotes/responses": "workspace:*"
|
"@standardnotes/responses": "workspace:*"
|
||||||
"@standardnotes/security": ^1.2.0
|
"@standardnotes/security": ^1.2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user