1 import type { VERIFICATION_STATUS } from '@proton/crypto';
3 import type { Photo } from '../_photos';
4 import type { ThumbnailType } from '../_uploads/media';
7 * Link should not be used directly. It is general set of attributes
8 * commont for both EncryptedLink and DecryptedLink.
19 // metaDataModifyTime represents time when the meta data of the link were
20 // modified on the server, such as renaming the link, moving to different
21 // folder and so on. Note that renaming is not cousing the change of modify
22 // time in regular file system. The "real" modify is encrypted in XAttr
23 // which is then available in fileModifyTime of DecryptedLink.
24 metaDataModifyTime: number;
25 trashed: number | null;
26 // trashedByParent is set only by internal state in case when parent is
27 // trashed which needs to trash also all children as well.
28 // Child items need to be trashed so they do not pop up anywhere, for
29 // example on shared links page, but at the same time childs of trashed
30 // folders should not be listed in trash section to match API behaviour.
31 // Note there is also other solution: simply delete childs of trashed
32 // folder from the cache, as they should not be needed at all. That is
33 // correct, but restoring it quickly back (in case of a mistake) would
34 // lead to re-download the whole cache again, and there would be need
35 // to re-fetch shared links. So better to keep it around.
36 trashedByParent?: boolean;
37 hasThumbnail: boolean;
38 hasHdThumbnail?: boolean;
40 // Note that shareId is ID of the share, that is pointer of what is shared
41 // with someone else. Link can be part of many shares; for example part of
42 // user's default share and of shared folder with someone else.
43 // Don't use this ID on places where the top/default share should be used.
44 // The current share context needs to be always passed explicitely, never
45 // used from the link itself.
47 // Links associated with Shared URLs don't have share id
49 shareUrl?: LinkShareUrl;
50 sharingDetails?: LinkSharingDetails;
54 // Address used for signature checks of blocks and xattributes.
55 signatureAddress: string;
56 // Thumbnails URL is not part of all requests, because that would be
57 // too heavy for API. For example, events do not include it.
70 signatureAddress?: string; // Addresss used for key signatures.
71 nameSignatureAddress?: string; // Address used for name signature.
72 // If there is no issue, the value should be undefined.
73 signatureIssues?: SignatureIssues;
77 export interface LinkShareUrl {
82 expireTime: number | null;
83 // numAccesses is not part of API requests, because that would be too
84 // heavy for API. This number needs to be loaded explicitely with route
85 // to get info about share URL.
89 interface LinkSharingDetails {
90 shareUrl?: LinkShareUrl;
94 export type SignatureIssues = {
95 // Key represents where the issue originated, e.g., passphrase, hash, name
96 // xattributes, block, and so on.
97 [day in SignatureIssueLocation]?: VERIFICATION_STATUS;
100 export type SignatureIssueLocation =
110 export interface EncryptedLink extends Link {
112 nodePassphrase: string;
113 nodePassphraseSignature?: string;
114 nodeHashKey?: string;
115 contentKeyPacket?: string;
116 contentKeyPacketSignature?: string;
120 export interface DecryptedLink extends Link {
121 // name in DecryptedLink is the decrypted part, but we need to keep also
122 // encryptedName for renaming procedure (to generate new sessionKey).
123 encryptedName: string;
124 // See metaDataModifyTime of Link.
125 fileModifyTime: number;
126 // isLocked is set to true when file is being manipulated, such as moved
127 // to different location. When link is locked, it should not be allowed
128 // to do anything else with the link (until the operation is done).
130 // isStale is indicating whether link needs to be re-decrypted due to
131 // server-side update. By default, we don't want to automatically decrypt
132 // everything, also, we don't want to simply remove stale link from cache
133 // to not cause GUI blinks. App should re-decrypt link on background next
134 // time link should be displayed.
136 // cachedThumbnailUrl is computed URL to cached image. This is not part
137 // of any request and not filled automatically. To get this value, use
138 // `loadLinkThumbnail` from `useDrive`.
139 cachedThumbnailUrl?: string;
140 originalSize?: number;
141 // In case of image it might contain dimensions stored in XAttributes.
142 originalDimensions?: {
146 // Digests stored in XAttributes
153 // corruptedLink is set when a link failed to be decrypted.
154 // In this case we still want to show it to the user so he can delete it.
155 corruptedLink?: boolean;