-
Notifications
You must be signed in to change notification settings - Fork 685
Expand file tree
/
Copy pathconstants.ts
More file actions
281 lines (250 loc) · 9.07 KB
/
constants.ts
File metadata and controls
281 lines (250 loc) · 9.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import { SORT_DIRECTION } from '../constants';
import { isMobile } from '../helpers/browser';
import type { UserSettings } from '../interfaces/drive/userSettings';
import { LayoutSetting, SortSetting } from '../interfaces/drive/userSettings';
export const MB = 1024 * 1024;
export const FOLDER_PAGE_SIZE = 150;
export const BATCH_REQUEST_SIZE = 50;
export const FILE_CHUNK_SIZE = 4 * MB;
export const MEMORY_DOWNLOAD_LIMIT = (isMobile() ? 100 : 500) * MB;
export const HARDWARE_CONCURRENCY = (typeof window !== 'undefined' && window.navigator?.hardwareConcurrency) || 1;
// openpgp.js creates hardwareConcurrency of web workers to do decryption.
// Using less threads for download means we don't use available potential.
// Using more threads will not speed things up much because thread in this
// context is not real thread but concurrently running downloads in the main
// thread.
// In the future, with the openpgp.js v5, we will create web workers manually.
// That will allow us to create more workers and keep download and decryption
// part in the same thread to save some data exchanges between threads.
// We could really allow more workers than available CPUs, because decryption
// is done on the stream as data comes in, i.e., not that heavy operation.
// Of course, we cannot allow, lets say, twice as many workers per download
// of one file but for all downloads to not kill user's device. Ideally, we
// want to make download of one file as fast as possible, but limit it to the
// same speed with more ongoing downloads or uploads.
export const MAX_THREADS_PER_DOWNLOAD = HARDWARE_CONCURRENCY;
export const MAX_THREADS_PER_REQUEST = 5;
export const DEFAULT_SORT_FIELD = 'ModifyTime';
export const DEFAULT_SORT_ORDER: SORT_DIRECTION = SORT_DIRECTION.DESC;
export const DEFAULT_USER_SETTINGS: UserSettings = {
Layout: LayoutSetting.List,
Sort: SortSetting.ModifiedDesc,
RevisionRetentionDays: 0,
B2BPhotosEnabled: false,
PhotoTags: [],
};
export const UPLOAD_TIMEOUT = 90000;
export const DOWNLOAD_TIMEOUT = 90000;
export const DOWNLOAD_RETRIES_ON_TIMEOUT = 3;
export const EXPENSIVE_REQUEST_TIMEOUT = 60000;
export const MAX_NAME_LENGTH = 255;
export const MAX_SHARED_URL_PASSWORD_LENGTH = 50;
export const SHARE_GENERATED_PASSWORD_LENGTH = 12;
export const DEFAULT_SHARE_MAX_ACCESSES = 0; // Zero means unlimited.
export const MAX_SAFE_UPLOADING_FILE_COUNT = 500;
export const MAX_SAFE_UPLOADING_FILE_SIZE = 5 * 1024 * 1024 * 1024; // GB
export const CUSTOM_DATA_FORMAT = 'pd-custom';
export const THUMBNAIL_MAX_SIDE = 512; // in pixels
export const THUMBNAIL_MAX_SIZE = 60 * 1024; // in bytes, 60kB
export const HD_THUMBNAIL_MAX_SIDE = 1920; // in pixels
export const HD_THUMBNAIL_MAX_SIZE = 1024 * 1024; // in bytes, 1mB
export const THUMBNAIL_QUALITIES = [0.7, 0.5, 0.3, 0.1, 0]; // Used qualities to stick under THUMBNAIL_MAX_SIZE.
export const VIDEO_THUMBNAIL_MAX_TIME_LOCATION: number = 300; // In seconds
export enum LinkURLType {
FOLDER = 'folder',
FILE = 'file',
}
export enum EVENT_TYPES {
DELETE = 0,
CREATE = 1,
UPDATE = 2,
UPDATE_METADATA = 3,
}
export enum EXPIRATION_DAYS {
NEVER = 'never',
ONE = '1',
FIFTEEN = '15',
THIRTY = '30',
SIXTY = '60',
NINETY = '90',
}
/**
* @deprecated common to different products, should be removed and use `API_CODES` from _/lib/constants.ts_ instead
*/
export enum RESPONSE_CODE {
SUCCESS = 1000,
NOT_ALLOWED = 2011,
INVALID_REQUIREMENT = 2000,
INVALID_LINK_TYPE = 2001,
ALREADY_EXISTS = 2500,
NOT_FOUND = 2501,
INVALID_ID = 2061,
}
export enum SupportedMimeTypes {
aac = 'audio/aac',
apk = 'application/vnd.android.package-archive',
apng = 'image/apng',
arc = 'application/x-freearc',
avi = 'video/x-msvideo',
avif = 'image/avif',
bmp = 'image/bmp',
bzip2 = 'application/x-bzip2',
cr3 = 'image/x-canon-cr3',
docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
eot = 'application/vnd.ms-fontobject',
epub = 'application/epub+zip',
flac = 'audio/x-flac',
flv = 'video/x-flv',
gif = 'image/gif',
gzip = 'application/gzip',
heic = 'image/heic',
heics = 'image/heic-sequence',
heif = 'image/heif',
heifs = 'image/heif-sequence',
ico = 'image/x-icon',
jpg = 'image/jpeg',
jxl = 'image/jxl',
keynote = 'application/vnd.apple.keynote',
m4a = 'audio/x-m4a',
m4v = 'video/x-m4v',
midi = 'audio/midi',
mp1s = 'video/MP1S',
mp2p = 'video/MP2P',
mp2t = 'video/mp2t',
mp4a = 'audio/mp4',
mp4v = 'video/mp4',
mpeg = 'audio/mpeg',
mpg = 'video/mpeg',
numbers = 'application/vnd.apple.numbers',
odp = 'application/vnd.oasis.opendocument.presentation',
ods = 'application/vnd.oasis.opendocument.spreadsheet',
odt = 'application/vnd.oasis.opendocument.text',
oga = 'audio/ogg',
ogg = 'application/ogg',
ogv = 'video/ogg',
opus = 'audio/opus',
otf = 'font/otf',
pages = 'application/vnd.apple.pages',
pdf = 'application/pdf',
png = 'image/png',
pptx = 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
qcp = 'audio/qcelp',
qt = 'video/quicktime',
rar = 'application/vnd.rar',
rtf = 'application/rtf',
svg = 'image/svg+xml',
swf = 'application/x-shockwave-flash',
tar = 'application/x-tar',
tiff = 'image/tiff',
ttf = 'font/ttf',
v3g2 = 'video/3gpp2',
v3gp = 'video/3gpp',
wav = 'audio/wav',
webp = 'image/webp',
woff = 'font/woff',
woff2 = 'font/woff2',
x7zip = 'application/x-7z-compressed',
xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
xml = 'text/xml',
zip = 'application/zip',
vdnMicrosoftIcon = 'image/vnd.microsoft.icon',
}
export enum SupportedProtonDocsMimeTypes {
docx = SupportedMimeTypes.docx,
txt = 'text/plain',
md = 'text/markdown',
html = 'text/html',
xlsx = SupportedMimeTypes.xlsx,
csv = 'text/csv',
tsv = 'text/tab-separated-values',
ods = SupportedMimeTypes.ods,
}
// RAWMimeTypes keys must be the usual extension of the file. It is used in validation, see `isRAWExtension`.
export enum RAWMimeTypes {
dcraw = 'image/x-dcraw',
dng = 'image/x-adobe-dng',
crw = 'image/x-canon-crw',
cr2 = 'image/x-canon-cr2',
cr3 = 'image/x-canon-cr3',
erf = 'image/x-epson-erf',
raf = 'image/x-fuji-raf',
dcr = 'image/x-kodak-dcr',
k25 = 'image/x-kodak-k25',
kdc = 'image/x-kodak-kdc',
mrw = 'image/x-minolta-mrw',
nef = 'image/x-nikon-nef',
nrw = 'image/x-nikon-nrw',
orf = 'image/x-olympus-orf',
raw = 'image/x-panasonic-raw',
rw2 = 'image/x-panasonic-rw2',
pef = 'image/x-pentax-pef',
ptx = 'image/x-pentax-ptx',
x3f = 'image/x-sigma-x3f',
srf = 'image/x-sony-srf',
sr2 = 'image/x-sony-sr2',
arw = 'image/x-sony-arw',
iiq = 'image/x-phaseone-iiq',
mef = 'image/x-mamiya-mef',
rwl = 'image/x-leica-rwl',
'3fr' = 'image/x-hasselblad-3fr',
fff = 'image/x-hasselblad-fff',
}
export enum RAWThumbnailExtractionSupported {
dng = 'image/x-adobe-dng',
arw = 'image/x-sony-arw',
erf = 'image/x-epson-erf',
mrw = 'image/x-minolta-mrw',
nrw = 'image/x-nikon-nrw',
orf = 'image/x-olympus-orf',
raf = 'image/x-fuji-raf',
rw2 = 'image/x-panasonic-rw2',
cr2 = 'image/x-canon-cr2',
cr3 = 'image/x-canon-cr3',
heic = 'image/heic',
nef = 'image/x-nikon-nef',
}
export const EXTRA_EXTENSION_TYPES: { [ext: string]: string } = {
py: 'text/x-python',
ts: 'application/typescript',
jxl: 'image/jxl',
};
export enum SHARE_MEMBER_STATE {
PENDING = 1,
REJECTED = 2,
DELETED = 3,
}
export enum SHARE_EXTERNAL_INVITATION_STATE {
PENDING = 1,
USER_REGISTERED = 2,
}
export const DS_STORE = '.DS_Store';
export const PHOTOS_PAGE_SIZE = 500;
// Accepted files for photos. This value must be used in input `accept` attribute
export const PHOTOS_ACCEPTED_INPUT = 'image/*,video/*';
const HOURS_IN_MS = 60 * 60 * 1000;
export const ACTIVE_PING_INTERVAL = 6 * HOURS_IN_MS;
export enum DRIVE_SIGNATURE_CONTEXT {
SHARE_MEMBER_INVITER = 'drive.share-member.inviter',
SHARE_MEMBER_MEMBER = 'drive.share-member.member',
SHARE_MEMBER_EXTERNAL_INVITATION = 'drive.share-member.external-invitation',
SEARCH_INDEX = 'drive.search.index',
}
export const SHARE_INVITE_MESSAGE_MAX_LENGTH = 500;
/**
* Used in the context of Drive / Docs public sharing.
*/
export enum DriveDocsPublicShareMessageType {
CUSTOM_PASSWORD = 'CUSTOM_PASSWORD',
READY_TO_RECEIVE_CUSTOM_PASSWORD = 'READY_TO_RECEIVE_CUSTOM_PASSWORD',
}
export type DriveDocsPublicShareMessage =
| {
type: DriveDocsPublicShareMessageType.CUSTOM_PASSWORD;
customPassword: string;
}
| {
type: DriveDocsPublicShareMessageType.READY_TO_RECEIVE_CUSTOM_PASSWORD;
};
export const DRIVE_IOS_URL = 'https://apps.apple.com/us/app/proton-drive-cloud-storage/id1509667851';
export const DRIVE_ANDROID_URL = 'https://play.google.com/store/apps/details?id=me.proton.android.drive';
export const DRIVE_DOWNLOAD_URL = 'https://proton.me/drive/download';