Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / applications / drive / src / app / store / _uploads / interface.ts
blob4d71eec549548888cbaf63d23666434db4cc2b2b
1 import type { PrivateKeyReference, SessionKey } from '@proton/crypto';
3 import type { ThumbnailType } from './media';
5 export interface UploadFileControls {
6     start: (progressCallbacks?: UploadFileProgressCallbacks) => Promise<void>;
7     pause: () => void;
8     resume: () => void;
9     cancel: () => void;
12 export interface UploadFileProgressCallbacks {
13     onInit?: (mimeType: string, fileName: string) => void;
14     onProgress?: (bytes: number) => void;
15     onNetworkError?: (error: any) => void;
16     onFinalize?: () => void;
19 export interface UploadFolderControls {
20     start: () => Promise<{ folderId: string; folderName: string }>;
21     cancel: () => void;
24 export interface UploadCallbacks {
25     initialize: (abortSignal: AbortSignal) => Promise<{
26         addressPrivateKey: PrivateKeyReference;
27         parentPrivateKey: PrivateKeyReference;
28     }>;
29     getVerificationData: (abortSignal: AbortSignal) => Promise<VerificationData>;
30     createFileRevision: (abortSignal: AbortSignal, mimeType: string, keys: FileKeys) => Promise<InitializedFileMeta>;
31     createBlockLinks: (
32         abortSignal: AbortSignal,
33         fileBlocks: FileRequestBlock[],
34         thumbnailBlocks?: ThumbnailRequestBlock[]
35     ) => Promise<{ fileLinks: Link[]; thumbnailLinks?: Link[] }>;
36     finalize: (signature: string, signatureAddress: string, xattr: string, photo?: PhotoUpload) => Promise<void>;
37     onError?: (error: Error) => void;
38     notifyVerificationError: (retryHelped: boolean) => void;
41 export type UploadFileList = (UploadFileItem | UploadFolderItem)[];
42 export type UploadFileItem = { path: string[]; file: File };
43 export type UploadFolderItem = { path: string[]; folder: string; modificationTime?: Date };
45 export type FileKeys = {
46     nodeKey: string;
47     nodePassphrase: string;
48     nodePassphraseSignature: string;
49     contentKeyPacket: string;
50     contentKeyPacketSignature: string;
51     privateKey: PrivateKeyReference;
52     sessionKey: SessionKey;
55 type InitializedFileMeta = {
56     fileName: string;
57     privateKey: PrivateKeyReference;
58     sessionKey: SessionKey;
59     parentHashKey: Uint8Array;
60     address: {
61         privateKey: PrivateKeyReference;
62         email: string;
63     };
66 export type EncryptedBlock = {
67     index: number;
68     originalSize: number;
69     encryptedData: Uint8Array;
70     hash: Uint8Array;
71     signature: string;
72     verificationToken: Uint8Array;
74     // Thumbnails specific properties
75     thumbnailType?: never;
78 export type ThumbnailEncryptedBlock = {
79     index: number;
80     originalSize: number;
81     encryptedData: Uint8Array;
82     hash: Uint8Array;
84     // Thumbnails specific properties
85     thumbnailType: ThumbnailType;
88 export type FileRequestBlock = {
89     index: number;
90     size: number;
91     hash: Uint8Array;
92     signature: string;
93     verificationToken: Uint8Array;
96 export type ThumbnailRequestBlock = {
97     index: number;
98     size: number;
99     hash: Uint8Array;
100     type: ThumbnailType;
103 export type VerificationData = {
104     verificationCode: Uint8Array;
105     verifierSessionKey: SessionKey;
108 export type Link = {
109     index: number;
110     token: string;
111     url: string;
114 export type PhotoUpload = {
115     encryptedExif?: string;
116     captureTime: number;
117     contentHash?: string;
120 export enum TransferConflictStrategy {
121     Rename = 'rename',
122     Replace = 'replace',
123     Skip = 'skip',