1 import { SORT_DIRECTION } from '../constants';
2 import { isMobile } from '../helpers/browser';
3 import type { UserSettings } from '../interfaces/drive/userSettings';
4 import { LayoutSetting, SortSetting } from '../interfaces/drive/userSettings';
6 export const MB = 1024 * 1024;
7 export const FOLDER_PAGE_SIZE = 150;
8 export const BATCH_REQUEST_SIZE = 50;
9 export const FILE_CHUNK_SIZE = 4 * MB;
10 export const MEMORY_DOWNLOAD_LIMIT = (isMobile() ? 100 : 500) * MB;
11 export const HARDWARE_CONCURRENCY = (typeof window !== 'undefined' && window.navigator?.hardwareConcurrency) || 1;
12 // openpgp.js creates hardwareConcurrency of web workers to do decryption.
13 // Using less threads for download means we don't use available potential.
14 // Using more threads will not speed things up much because thread in this
15 // context is not real thread but concurrently running downloads in the main
17 // In the future, with the openpgp.js v5, we will create web workers manually.
18 // That will allow us to create more workers and keep download and decryption
19 // part in the same thread to save some data exchanges between threads.
20 // We could really allow more workers than available CPUs, because decryption
21 // is done on the stream as data comes in, i.e., not that heavy operation.
22 // Of course, we cannot allow, lets say, twice as many workers per download
23 // of one file but for all downloads to not kill user's device. Ideally, we
24 // want to make download of one file as fast as possible, but limit it to the
25 // same speed with more ongoing downloads or uploads.
26 export const MAX_THREADS_PER_DOWNLOAD = HARDWARE_CONCURRENCY;
27 export const MAX_THREADS_PER_REQUEST = 5;
28 export const DEFAULT_SORT_FIELD = 'ModifyTime';
29 export const DEFAULT_SORT_ORDER: SORT_DIRECTION = SORT_DIRECTION.DESC;
31 export const DEFAULT_USER_SETTINGS: UserSettings = {
32 Layout: LayoutSetting.List,
33 Sort: SortSetting.ModifiedDesc,
34 RevisionRetentionDays: 0,
35 B2BPhotosEnabled: false,
38 export const UPLOAD_TIMEOUT = 90000;
39 export const DOWNLOAD_TIMEOUT = 90000;
40 export const DOWNLOAD_RETRIES_ON_TIMEOUT = 3;
41 export const EXPENSIVE_REQUEST_TIMEOUT = 60000;
42 export const MAX_NAME_LENGTH = 255;
43 export const MAX_SHARED_URL_PASSWORD_LENGTH = 50;
45 export const SHARE_GENERATED_PASSWORD_LENGTH = 12;
47 export const DEFAULT_SHARE_MAX_ACCESSES = 0; // Zero means unlimited.
49 export const MAX_SAFE_UPLOADING_FILE_COUNT = 500;
50 export const MAX_SAFE_UPLOADING_FILE_SIZE = 5 * 1024 * 1024 * 1024; // GB
52 export const CUSTOM_DATA_FORMAT = 'pd-custom';
54 export const THUMBNAIL_MAX_SIDE = 512; // in pixels
55 export const THUMBNAIL_MAX_SIZE = 60 * 1024; // in bytes, 60kB
57 export const HD_THUMBNAIL_MAX_SIDE = 1920; // in pixels
58 export const HD_THUMBNAIL_MAX_SIZE = 1024 * 1024; // in bytes, 1mB
60 export const THUMBNAIL_QUALITIES = [0.7, 0.5, 0.3, 0.1, 0]; // Used qualities to stick under THUMBNAIL_MAX_SIZE.
62 export const VIDEO_THUMBNAIL_MAX_TIME_LOCATION: number = 300; // In seconds
64 export enum LinkURLType {
69 export enum EVENT_TYPES {
76 export enum EXPIRATION_DAYS {
86 * @deprecated common to different products, should be removed and use `API_CODES` from _/lib/constants.ts_ instead
88 export enum RESPONSE_CODE {
91 INVALID_REQUIREMENT = 2000,
92 INVALID_LINK_TYPE = 2001,
93 ALREADY_EXISTS = 2500,
98 export enum SupportedMimeTypes {
100 apk = 'application/vnd.android.package-archive',
102 arc = 'application/x-freearc',
103 avi = 'video/x-msvideo',
106 bzip2 = 'application/x-bzip2',
107 cr3 = 'image/x-canon-cr3',
108 docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
109 eot = 'application/vnd.ms-fontobject',
110 epub = 'application/epub+zip',
111 flac = 'audio/x-flac',
114 gzip = 'application/gzip',
116 heics = 'image/heic-sequence',
118 heifs = 'image/heif-sequence',
119 ico = 'image/x-icon',
122 keynote = 'application/vnd.apple.keynote',
133 numbers = 'application/vnd.apple.numbers',
134 odp = 'application/vnd.oasis.opendocument.presentation',
135 ods = 'application/vnd.oasis.opendocument.spreadsheet',
136 odt = 'application/vnd.oasis.opendocument.text',
138 ogg = 'application/ogg',
142 pages = 'application/vnd.apple.pages',
143 pdf = 'application/pdf',
145 pptx = 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
147 qt = 'video/quicktime',
148 rar = 'application/vnd.rar',
149 rtf = 'application/rtf',
150 svg = 'image/svg+xml',
151 swf = 'application/x-shockwave-flash',
152 tar = 'application/x-tar',
155 v3g2 = 'video/3gpp2',
160 woff2 = 'font/woff2',
161 x7zip = 'application/x-7z-compressed',
162 xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
164 zip = 'application/zip',
165 vdnMicrosoftIcon = 'image/vnd.microsoft.icon',
168 export enum SupportedProtonDocsMimeTypes {
169 docx = SupportedMimeTypes.docx,
171 md = 'text/markdown',
175 export const EXTRA_EXTENSION_TYPES: { [ext: string]: string } = {
177 ts: 'application/typescript',
181 export enum SHARE_MEMBER_STATE {
187 export enum SHARE_EXTERNAL_INVITATION_STATE {
192 export const DS_STORE = '.DS_Store';
194 // Delete once sharing between members is fully implemented.
195 export const MEMBER_SHARING_ENABLED = false;
197 export const PHOTOS_PAGE_SIZE = 500;
199 // Accepted files for photos. This value must be used in input `accept` attribute
200 export const PHOTOS_ACCEPTED_INPUT = `image/*,video/*,${SupportedMimeTypes.heic},${SupportedMimeTypes.heif}`;
202 const HOURS_IN_MS = 60 * 60 * 1000;
203 export const ACTIVE_PING_INTERVAL = 6 * HOURS_IN_MS;
205 export enum DRIVE_SIGNATURE_CONTEXT {
206 SHARE_MEMBER_INVITER = 'drive.share-member.inviter',
207 SHARE_MEMBER_MEMBER = 'drive.share-member.member',
208 SHARE_MEMBER_EXTERNAL_INVITATION = 'drive.share-member.external-invitation',
211 export const SHARE_INVITE_MESSAGE_MAX_LENGTH = 500;
214 * Used in the context of Drive / Docs public sharing.
216 export enum DriveDocsPublicShareMessageType {
217 CUSTOM_PASSWORD = 'CUSTOM_PASSWORD',
218 READY_TO_RECEIVE_CUSTOM_PASSWORD = 'READY_TO_RECEIVE_CUSTOM_PASSWORD',
221 export type DriveDocsPublicShareMessage =
223 type: DriveDocsPublicShareMessageType.CUSTOM_PASSWORD;
224 customPassword: string;
227 type: DriveDocsPublicShareMessageType.READY_TO_RECEIVE_CUSTOM_PASSWORD;