@protontech/drive-sdk 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/cache/index.d.ts +2 -0
  2. package/dist/cache/index.js +6 -0
  3. package/dist/cache/index.js.map +1 -0
  4. package/dist/cache/interface.d.ts +105 -0
  5. package/dist/cache/interface.js +3 -0
  6. package/dist/cache/interface.js.map +1 -0
  7. package/dist/cache/memoryCache.d.ts +18 -0
  8. package/dist/cache/memoryCache.js +78 -0
  9. package/dist/cache/memoryCache.js.map +1 -0
  10. package/dist/cache/memoryCache.test.d.ts +1 -0
  11. package/dist/cache/memoryCache.test.js +121 -0
  12. package/dist/cache/memoryCache.test.js.map +1 -0
  13. package/dist/crypto/hmac.d.ts +22 -0
  14. package/dist/crypto/hmac.js +44 -0
  15. package/dist/crypto/hmac.js.map +1 -0
  16. package/dist/crypto/utils.d.ts +2 -0
  17. package/dist/crypto/utils.js +35 -0
  18. package/dist/crypto/utils.js.map +1 -0
  19. package/dist/errors.d.ts +142 -0
  20. package/dist/errors.js +168 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/interface/account.js +3 -0
  23. package/dist/interface/account.js.map +1 -0
  24. package/dist/interface/author.d.ts +26 -0
  25. package/dist/interface/author.js +3 -0
  26. package/dist/interface/author.js.map +1 -0
  27. package/dist/interface/download.d.ts +29 -0
  28. package/dist/interface/download.js +3 -0
  29. package/dist/interface/download.js.map +1 -0
  30. package/dist/interface/httpClient.d.ts +38 -0
  31. package/dist/interface/httpClient.js +3 -0
  32. package/dist/interface/httpClient.js.map +1 -0
  33. package/dist/interface/index.d.ts +1 -1
  34. package/dist/interface/nodes.d.ts +12 -1
  35. package/dist/interface/nodes.js +11 -0
  36. package/dist/interface/nodes.js.map +1 -1
  37. package/dist/interface/result.d.ts +9 -0
  38. package/dist/interface/result.js +11 -0
  39. package/dist/interface/result.js.map +1 -0
  40. package/dist/interface/thumbnail.d.ts +17 -0
  41. package/dist/interface/thumbnail.js +9 -0
  42. package/dist/interface/thumbnail.js.map +1 -0
  43. package/dist/interface/upload.d.ts +64 -0
  44. package/dist/interface/upload.js +3 -0
  45. package/dist/interface/upload.js.map +1 -0
  46. package/dist/internal/apiService/driveTypes.d.ts +1341 -465
  47. package/dist/internal/apiService/errorCodes.d.ts +30 -0
  48. package/dist/internal/apiService/errorCodes.js +11 -0
  49. package/dist/internal/apiService/errorCodes.js.map +1 -0
  50. package/dist/internal/apiService/errors.js +2 -2
  51. package/dist/internal/apiService/errors.js.map +1 -1
  52. package/dist/internal/apiService/observerStream.d.ts +3 -0
  53. package/dist/internal/apiService/observerStream.js +15 -0
  54. package/dist/internal/apiService/observerStream.js.map +1 -0
  55. package/dist/internal/apiService/transformers.js +2 -0
  56. package/dist/internal/apiService/transformers.js.map +1 -1
  57. package/dist/internal/asyncIteratorMap.d.ts +15 -0
  58. package/dist/internal/asyncIteratorMap.js +59 -0
  59. package/dist/internal/asyncIteratorMap.js.map +1 -0
  60. package/dist/internal/asyncIteratorMap.test.d.ts +1 -0
  61. package/dist/internal/asyncIteratorMap.test.js +120 -0
  62. package/dist/internal/asyncIteratorMap.test.js.map +1 -0
  63. package/dist/internal/batchLoading.d.ts +34 -0
  64. package/dist/internal/batchLoading.js +68 -0
  65. package/dist/internal/batchLoading.js.map +1 -0
  66. package/dist/internal/batchLoading.test.d.ts +1 -0
  67. package/dist/internal/batchLoading.test.js +50 -0
  68. package/dist/internal/batchLoading.test.js.map +1 -0
  69. package/dist/internal/download/controller.d.ts +8 -0
  70. package/dist/internal/download/controller.js +22 -0
  71. package/dist/internal/download/controller.js.map +1 -0
  72. package/dist/internal/download/queue.d.ts +5 -0
  73. package/dist/internal/download/queue.js +31 -0
  74. package/dist/internal/download/queue.js.map +1 -0
  75. package/dist/internal/errors.js +28 -0
  76. package/dist/internal/errors.js.map +1 -0
  77. package/dist/internal/errors.test.js +22 -0
  78. package/dist/internal/errors.test.js.map +1 -0
  79. package/dist/internal/events/interface.d.ts +47 -0
  80. package/dist/internal/events/interface.js +12 -0
  81. package/dist/internal/events/interface.js.map +1 -0
  82. package/dist/internal/nodes/apiService.d.ts +2 -2
  83. package/dist/internal/nodes/apiService.js +16 -6
  84. package/dist/internal/nodes/apiService.js.map +1 -1
  85. package/dist/internal/nodes/apiService.test.js +30 -8
  86. package/dist/internal/nodes/apiService.test.js.map +1 -1
  87. package/dist/internal/nodes/cache.js +1 -0
  88. package/dist/internal/nodes/cache.js.map +1 -1
  89. package/dist/internal/nodes/cache.test.js +1 -0
  90. package/dist/internal/nodes/cache.test.js.map +1 -1
  91. package/dist/internal/nodes/cryptoService.test.js +34 -0
  92. package/dist/internal/nodes/cryptoService.test.js.map +1 -1
  93. package/dist/internal/nodes/index.test.js +3 -1
  94. package/dist/internal/nodes/index.test.js.map +1 -1
  95. package/dist/internal/nodes/interface.d.ts +3 -1
  96. package/dist/internal/nodes/mediaTypes.d.ts +2 -0
  97. package/dist/internal/nodes/mediaTypes.js +13 -0
  98. package/dist/internal/nodes/mediaTypes.js.map +1 -0
  99. package/dist/internal/nodes/nodesAccess.js +28 -7
  100. package/dist/internal/nodes/nodesAccess.js.map +1 -1
  101. package/dist/internal/nodes/nodesAccess.test.js +7 -6
  102. package/dist/internal/nodes/nodesAccess.test.js.map +1 -1
  103. package/dist/internal/nodes/validations.d.ts +4 -0
  104. package/dist/internal/nodes/validations.js +21 -0
  105. package/dist/internal/nodes/validations.js.map +1 -0
  106. package/dist/internal/sharing/apiService.js +19 -2
  107. package/dist/internal/sharing/apiService.js.map +1 -1
  108. package/dist/internal/uids.d.ts +38 -0
  109. package/dist/internal/uids.js +85 -0
  110. package/dist/internal/uids.js.map +1 -0
  111. package/dist/internal/upload/chunkStreamReader.d.ts +13 -0
  112. package/dist/internal/upload/chunkStreamReader.js +46 -0
  113. package/dist/internal/upload/chunkStreamReader.js.map +1 -0
  114. package/dist/internal/upload/chunkStreamReader.test.d.ts +1 -0
  115. package/dist/internal/upload/chunkStreamReader.test.js +75 -0
  116. package/dist/internal/upload/chunkStreamReader.test.js.map +1 -0
  117. package/dist/internal/upload/controller.d.ts +8 -0
  118. package/dist/internal/upload/controller.js +25 -0
  119. package/dist/internal/upload/controller.js.map +1 -0
  120. package/dist/internal/upload/digests.d.ts +8 -0
  121. package/dist/internal/upload/digests.js +22 -0
  122. package/dist/internal/upload/digests.js.map +1 -0
  123. package/dist/internal/upload/fileUploader.d.ts +49 -53
  124. package/dist/internal/upload/fileUploader.js +91 -395
  125. package/dist/internal/upload/fileUploader.js.map +1 -1
  126. package/dist/internal/upload/fileUploader.test.js +38 -292
  127. package/dist/internal/upload/fileUploader.test.js.map +1 -1
  128. package/dist/internal/upload/index.d.ts +3 -3
  129. package/dist/internal/upload/index.js +20 -41
  130. package/dist/internal/upload/index.js.map +1 -1
  131. package/dist/internal/upload/manager.d.ts +1 -1
  132. package/dist/internal/upload/manager.js +16 -19
  133. package/dist/internal/upload/manager.js.map +1 -1
  134. package/dist/internal/upload/manager.test.js +42 -83
  135. package/dist/internal/upload/manager.test.js.map +1 -1
  136. package/dist/internal/upload/queue.d.ts +5 -0
  137. package/dist/internal/upload/queue.js +32 -0
  138. package/dist/internal/upload/queue.js.map +1 -0
  139. package/dist/internal/upload/streamUploader.d.ts +62 -0
  140. package/dist/internal/upload/streamUploader.js +441 -0
  141. package/dist/internal/upload/streamUploader.js.map +1 -0
  142. package/dist/internal/upload/streamUploader.test.d.ts +1 -0
  143. package/dist/internal/upload/streamUploader.test.js +358 -0
  144. package/dist/internal/upload/streamUploader.test.js.map +1 -0
  145. package/dist/internal/utils.d.ts +1 -0
  146. package/dist/internal/utils.js +13 -0
  147. package/dist/internal/utils.js.map +1 -0
  148. package/dist/internal/wait.d.ts +3 -0
  149. package/dist/internal/wait.js +28 -0
  150. package/dist/internal/wait.js.map +1 -0
  151. package/dist/internal/wait.test.d.ts +1 -0
  152. package/dist/internal/wait.test.js +21 -0
  153. package/dist/internal/wait.test.js.map +1 -0
  154. package/dist/protonDriveClient.d.ts +4 -4
  155. package/dist/protonDriveClient.js +1 -1
  156. package/dist/protonDriveClient.js.map +1 -1
  157. package/package.json +2 -2
  158. package/src/errors.ts +10 -4
  159. package/src/interface/index.ts +1 -1
  160. package/src/interface/nodes.ts +11 -0
  161. package/src/interface/upload.ts +53 -3
  162. package/src/internal/apiService/driveTypes.ts +1341 -465
  163. package/src/internal/apiService/errors.ts +3 -2
  164. package/src/internal/apiService/transformers.ts +2 -0
  165. package/src/internal/asyncIteratorMap.test.ts +150 -0
  166. package/src/internal/asyncIteratorMap.ts +64 -0
  167. package/src/internal/nodes/apiService.test.ts +36 -7
  168. package/src/internal/nodes/apiService.ts +19 -7
  169. package/src/internal/nodes/cache.test.ts +1 -0
  170. package/src/internal/nodes/cache.ts +1 -0
  171. package/src/internal/nodes/cryptoService.test.ts +38 -0
  172. package/src/internal/nodes/index.test.ts +3 -1
  173. package/src/internal/nodes/interface.ts +4 -1
  174. package/src/internal/nodes/nodesAccess.test.ts +7 -6
  175. package/src/internal/nodes/nodesAccess.ts +30 -7
  176. package/src/internal/sharing/apiService.ts +24 -2
  177. package/src/internal/upload/fileUploader.test.ts +46 -376
  178. package/src/internal/upload/fileUploader.ts +114 -494
  179. package/src/internal/upload/index.ts +26 -50
  180. package/src/internal/upload/manager.test.ts +45 -92
  181. package/src/internal/upload/manager.ts +30 -32
  182. package/src/internal/upload/streamUploader.test.ts +469 -0
  183. package/src/internal/upload/streamUploader.ts +552 -0
  184. package/src/protonDriveClient.ts +5 -4
package/dist/errors.js ADDED
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrityError = exports.DecryptionError = exports.ConnectionError = exports.RateLimitedError = exports.ServerError = exports.NodeAlreadyExistsValidationError = exports.ValidationError = exports.AbortError = exports.ProtonDriveError = void 0;
4
+ const ttag_1 = require("ttag");
5
+ /**
6
+ * Base class for all SDK errors.
7
+ *
8
+ * This class can be used for catching all SDK errors. The error should have
9
+ * translated message in the `message` property that should be shown to the
10
+ * user without any modification.
11
+ *
12
+ * No retries should be done as that is already handled by the SDK.
13
+ *
14
+ * When SDK throws an error and it is not `ProtonDriveError`, it is unhandled error
15
+ * by the SDK and usually indicates bug in the SDK. Please, report it.
16
+ */
17
+ class ProtonDriveError extends Error {
18
+ name = 'ProtonDriveError';
19
+ }
20
+ exports.ProtonDriveError = ProtonDriveError;
21
+ /**
22
+ * Error thrown when the operation is aborted.
23
+ *
24
+ * This error is thrown when the operation is aborted by the user.
25
+ * For example, by calling `abort()` on the `AbortSignal`.
26
+ */
27
+ class AbortError extends ProtonDriveError {
28
+ name = 'AbortError';
29
+ constructor(message) {
30
+ super(message || (0, ttag_1.c)('Error').t `Operation aborted`);
31
+ }
32
+ }
33
+ exports.AbortError = AbortError;
34
+ /**
35
+ * Error thrown when the validation fails.
36
+ *
37
+ * This error is thrown when the validation of the input fails.
38
+ * Validation can be done on the client side or on the server side.
39
+ *
40
+ * For example, on the client, it can be thrown when the node name doesn't
41
+ * follow the required format, etc., while on the server side, it can be thrown
42
+ * when there is not enough permissions, etc.
43
+ */
44
+ class ValidationError extends ProtonDriveError {
45
+ name = 'ValidationError';
46
+ /**
47
+ * Internal API code.
48
+ *
49
+ * Use only for debugging purposes.
50
+ */
51
+ code;
52
+ /**
53
+ * Additional details about the error provided by the server.
54
+ */
55
+ details;
56
+ constructor(message, code, details) {
57
+ super(message);
58
+ this.code = code;
59
+ this.details = details;
60
+ }
61
+ }
62
+ exports.ValidationError = ValidationError;
63
+ /**
64
+ * Error thrown when the node already exists.
65
+ *
66
+ * This error is thrown when the node with the same name already exists in the
67
+ * parent folder. The client should ask the user to replace the existing node
68
+ * or choose another name. The available name is provided in the `availableName`
69
+ * property (that will contain original name with the index that can be used).
70
+ */
71
+ class NodeAlreadyExistsValidationError extends ValidationError {
72
+ name = 'NodeAlreadyExistsValidationError';
73
+ existingNodeUid;
74
+ constructor(message, code, existingNodeUid) {
75
+ super(message, code);
76
+ this.existingNodeUid = existingNodeUid;
77
+ }
78
+ }
79
+ exports.NodeAlreadyExistsValidationError = NodeAlreadyExistsValidationError;
80
+ /**
81
+ * Error thrown when the API call fails.
82
+ *
83
+ * This error covers both HTTP errors and API errors. SDK automatically
84
+ * retries the request before the error is thrown. The sepcific algorithm
85
+ * used for retries depends on the type of the error.
86
+ *
87
+ * Client should not retry the request when this error is thrown.
88
+ */
89
+ class ServerError extends ProtonDriveError {
90
+ name = 'ServerError';
91
+ /**
92
+ * HTTP status code of the response.
93
+ *
94
+ * Use only for debugging purposes.
95
+ */
96
+ statusCode;
97
+ /**
98
+ * Internal API code.
99
+ *
100
+ * Use only for debugging purposes.
101
+ */
102
+ code;
103
+ }
104
+ exports.ServerError = ServerError;
105
+ /**
106
+ * Error thrown when the client makes too many requests to the API.
107
+ *
108
+ * SDK is configured to stay below the rate limits, but it can still happen if
109
+ * client is running multiple SDKs in parallel, or if the rate limits are
110
+ * changed on the server side.
111
+ *
112
+ * SDK automatically retries the request before the error is thrown after
113
+ * waiting for the required time specified by the server.
114
+ *
115
+ * Client should slow down calling SDK when this error is thrown.
116
+ *
117
+ * You can be also notified about the rate limits by the `requestsThrottled`
118
+ * event. See `onMessage` method on the SDK class for more details.
119
+ */
120
+ class RateLimitedError extends ServerError {
121
+ name = 'RateLimitedError';
122
+ code = 429;
123
+ }
124
+ exports.RateLimitedError = RateLimitedError;
125
+ /**
126
+ * Error thrown when the client is not connected to the internet.
127
+ *
128
+ * Client should check the internet connection when this error is thrown.
129
+ *
130
+ * You can also be notified about the connection status by the `offline` event
131
+ * See `onMessage` method on the SDK class for more details.
132
+ */
133
+ class ConnectionError extends ProtonDriveError {
134
+ name = 'ConnectionError';
135
+ }
136
+ exports.ConnectionError = ConnectionError;
137
+ /**
138
+ * Error thrown when the decryption fails.
139
+ *
140
+ * Client should report this error to the user and report bug report.
141
+ *
142
+ * In most cases, there is no decryption error. Every decryption error should
143
+ * be not exposed but set as empty value on the node, for example. But in the
144
+ * case of the file content, if block cannot be decrypted, decryption error
145
+ * is thrown.
146
+ */
147
+ class DecryptionError extends ProtonDriveError {
148
+ name = 'DecryptionError';
149
+ }
150
+ exports.DecryptionError = DecryptionError;
151
+ /**
152
+ * Error thrown when the data integrity check fails.
153
+ *
154
+ * Client should report this error to the user and report bug report.
155
+ *
156
+ * For example, it can happen when hashes don't match, etc. In some cases,
157
+ * SDK allows to run command without verification checks for debug purposes.
158
+ */
159
+ class IntegrityError extends ProtonDriveError {
160
+ name = 'IntegrityError';
161
+ debug;
162
+ constructor(message, debug) {
163
+ super(message);
164
+ this.debug = debug;
165
+ }
166
+ }
167
+ exports.IntegrityError = IntegrityError;
168
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,+BAAyB;AAEzB;;;;;;;;;;;GAWG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IACvC,IAAI,GAAG,kBAAkB,CAAC;CAC7B;AAFD,4CAEC;AAED;;;;;GAKG;AACH,MAAa,UAAW,SAAQ,gBAAgB;IAC5C,IAAI,GAAG,YAAY,CAAC;IAEpB,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,IAAI,IAAA,QAAC,EAAC,OAAO,CAAC,CAAC,CAAC,CAAA,mBAAmB,CAAC,CAAC;IACtD,CAAC;CACJ;AAND,gCAMC;AAED;;;;;;;;;GASG;AACH,MAAa,eAAgB,SAAQ,gBAAgB;IACjD,IAAI,GAAG,iBAAiB,CAAC;IAEzB;;;;OAIG;IACa,IAAI,CAAU;IAE9B;;OAEG;IACa,OAAO,CAAU;IAEjC,YAAY,OAAe,EAAE,IAAa,EAAE,OAAgB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AApBD,0CAoBC;AAED;;;;;;;GAOG;AACH,MAAa,gCAAiC,SAAQ,eAAe;IACjE,IAAI,GAAG,kCAAkC,CAAC;IAE1B,eAAe,CAAU;IAEzC,YAAY,OAAe,EAAE,IAAY,EAAE,eAAwB;QAC/D,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;CACJ;AATD,4EASC;AAED;;;;;;;;GAQG;AACH,MAAa,WAAY,SAAQ,gBAAgB;IAC7C,IAAI,GAAG,aAAa,CAAC;IAErB;;;;OAIG;IACa,UAAU,CAAU;IACpC;;;;OAIG;IACa,IAAI,CAAU;CACjC;AAfD,kCAeC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAa,gBAAiB,SAAQ,WAAW;IAC7C,IAAI,GAAG,kBAAkB,CAAC;IAE1B,IAAI,GAAG,GAAG,CAAC;CACd;AAJD,4CAIC;AAED;;;;;;;GAOG;AACH,MAAa,eAAgB,SAAQ,gBAAgB;IACjD,IAAI,GAAG,iBAAiB,CAAC;CAC5B;AAFD,0CAEC;AAED;;;;;;;;;GASG;AACH,MAAa,eAAgB,SAAQ,gBAAgB;IACjD,IAAI,GAAG,iBAAiB,CAAC;CAC5B;AAFD,0CAEC;AAED;;;;;;;GAOG;AACH,MAAa,cAAe,SAAQ,gBAAgB;IAChD,IAAI,GAAG,gBAAgB,CAAC;IAER,KAAK,CAAU;IAE/B,YAAY,OAAe,EAAE,KAAc;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AATD,wCASC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/interface/account.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { Result } from './result';
2
+ /**
3
+ * Author with verification status.
4
+ *
5
+ * It can be either a string (email) or an anonymous user.
6
+ *
7
+ * If author cannot be verified, the result is failure with an error.
8
+ * The client can still get claimed author from the error object, but
9
+ * it must be used with caution.
10
+ */
11
+ export type Author = Result<string | AnonymousUser, UnverifiedAuthorError>;
12
+ /**
13
+ * Anonymous user. Used when user shares folder publicly and anonymous
14
+ * users can access the folder and upload new files without being logged in.
15
+ */
16
+ export type AnonymousUser = null;
17
+ /**
18
+ * Unverified author.
19
+ *
20
+ * If author cannot be verified, the result is this object containing
21
+ * the claimed author and the verification error.
22
+ */
23
+ export type UnverifiedAuthorError = {
24
+ claimedAuthor?: string;
25
+ error: string;
26
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=author.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"author.js","sourceRoot":"","sources":["../../src/interface/author.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ export interface FileDownloader {
2
+ /**
3
+ * Get the claimed size of the file in bytes.
4
+ *
5
+ * This provides total clear-text size of the file. This is encrypted
6
+ * information that is not known to the Proton Drive and thus it is
7
+ * explicitely stated as claimed only and must be treated that way.
8
+ * It can be wrong or missing completely.
9
+ */
10
+ getClaimedSizeInBytes(): number | undefined;
11
+ /**
12
+ * Download, decrypt and verify the content from the server and write
13
+ * to the provided stream.
14
+ *
15
+ * @param onProgress - Callback that is called with the number of downloaded bytes
16
+ */
17
+ writeToStream(streamFactory: WritableStream, onProgress: (downloadedBytes: number) => void): DownloadController;
18
+ /**
19
+ * Same as `writeToStream` but without verification checks.
20
+ *
21
+ * Use this only for debugging purposes.
22
+ */
23
+ unsafeWriteToStream(streamFactory: WritableStream, onProgress: (downloadedBytes: number) => void): DownloadController;
24
+ }
25
+ export interface DownloadController {
26
+ pause(): void;
27
+ resume(): void;
28
+ completion(): Promise<void>;
29
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/interface/download.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ export interface ProtonDriveHTTPClient {
2
+ fetchJson(options: ProtonDriveHTTPClientJsonOptions): Promise<Response>;
3
+ fetchBlob(options: ProtonDriveHTTPClientBlobOptions): Promise<Response>;
4
+ }
5
+ export type ProtonDriveHTTPClientJsonOptions = ProtonDriveHTTPClientBaseOptions & {
6
+ json?: object;
7
+ };
8
+ export type ProtonDriveHTTPClientBlobOptions = ProtonDriveHTTPClientBaseOptions & {
9
+ body?: XMLHttpRequestBodyInit;
10
+ onProgress?: (progress: number) => void;
11
+ };
12
+ type ProtonDriveHTTPClientBaseOptions = {
13
+ url: string;
14
+ method: string;
15
+ headers: Headers;
16
+ /**
17
+ * The timeout in milliseconds.
18
+ *
19
+ * When timeout is reached, the request will be aborted with TimeoutError.
20
+ */
21
+ timeoutMs: number;
22
+ signal?: AbortSignal;
23
+ };
24
+ export type ProtonDriveConfig = {
25
+ /**
26
+ * The base URL for the Proton Drive (without schema).
27
+ *
28
+ * If not provided, defaults to 'drive-api.proton.me'.
29
+ */
30
+ baseUrl?: string;
31
+ /**
32
+ * The language to use for error messages.
33
+ *
34
+ * If not provided, defaults to 'en'.
35
+ */
36
+ language?: string;
37
+ };
38
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=httpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../src/interface/httpClient.ts"],"names":[],"mappings":""}
@@ -19,7 +19,7 @@ export type { ProtonInvitation, ProtonInvitationWithNode, NonProtonInvitation, M
19
19
  export { NonProtonInvitationState } from './sharing';
20
20
  export type { Telemetry, Logger, MetricAPIRetrySucceededEvent, MetricUploadEvent, MetricsUploadErrorType, MetricDownloadEvent, MetricsDownloadErrorType, MetricDecryptionErrorEvent, MetricsDecryptionErrorField, MetricVerificationErrorEvent, MetricVerificationErrorField, MetricBlockVerificationErrorEvent, MetricVolumeEventsSubscriptionsChangedEvent, MetricEvent } from './telemetry';
21
21
  export { MetricVolumeType } from './telemetry';
22
- export type { Fileuploader, UploadController, UploadMetadata } from './upload';
22
+ export type { FileUploader, FileRevisionUploader, UploadController, UploadMetadata } from './upload';
23
23
  export type { Thumbnail, ThumbnailResult } from './thumbnail';
24
24
  export { ThumbnailType } from './thumbnail';
25
25
  export type ProtonDriveTelemetry = Telemetry<MetricEvent>;
@@ -127,7 +127,18 @@ export type InvalidNameError = {
127
127
  };
128
128
  export declare enum NodeType {
129
129
  File = "file",
130
- Folder = "folder"
130
+ Folder = "folder",
131
+ /**
132
+ * Album is a special type available only in Photos section.
133
+ *
134
+ * The SDK does not support any album-specific actions, but it can load
135
+ * the node and do general operations on it, such as sharing. However,
136
+ * you should not rely that anything can work. It is not guaranteed that
137
+ * and in the future specific Photos SDK will support albums.
138
+ *
139
+ * @deprecated This type is not part of the public API.
140
+ */
141
+ Album = "album"
131
142
  }
132
143
  export declare enum MemberRole {
133
144
  Viewer = "viewer",
@@ -5,6 +5,17 @@ var NodeType;
5
5
  (function (NodeType) {
6
6
  NodeType["File"] = "file";
7
7
  NodeType["Folder"] = "folder";
8
+ /**
9
+ * Album is a special type available only in Photos section.
10
+ *
11
+ * The SDK does not support any album-specific actions, but it can load
12
+ * the node and do general operations on it, such as sharing. However,
13
+ * you should not rely that anything can work. It is not guaranteed that
14
+ * and in the future specific Photos SDK will support albums.
15
+ *
16
+ * @deprecated This type is not part of the public API.
17
+ */
18
+ NodeType["Album"] = "album";
8
19
  })(NodeType || (exports.NodeType = NodeType = {}));
9
20
  var MemberRole;
10
21
  (function (MemberRole) {
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/interface/nodes.ts"],"names":[],"mappings":";;;AAsIA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAChB,yBAAa,CAAA;IACb,6BAAiB,CAAA;AACrB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAED,IAAY,UAKX;AALD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,qCAAuB,CAAA;AAC3B,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAsBD,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;AAC7B,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/interface/nodes.ts"],"names":[],"mappings":";;;AAsIA,IAAY,QAcX;AAdD,WAAY,QAAQ;IAChB,yBAAa,CAAA;IACb,6BAAiB,CAAA;IACjB;;;;;;;;;OASG;IACH,2BAAe,CAAA;AACnB,CAAC,EAdW,QAAQ,wBAAR,QAAQ,QAcnB;AAED,IAAY,UAKX;AALD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,qCAAuB,CAAA;AAC3B,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAsBD,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;AAC7B,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
@@ -0,0 +1,9 @@
1
+ export type Result<T, E> = {
2
+ ok: true;
3
+ value: T;
4
+ } | {
5
+ ok: false;
6
+ error: E;
7
+ };
8
+ export declare function resultOk<T, E>(value: T): Result<T, E>;
9
+ export declare function resultError<T, E>(error: E): Result<T, E>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resultOk = resultOk;
4
+ exports.resultError = resultError;
5
+ function resultOk(value) {
6
+ return { ok: true, value };
7
+ }
8
+ function resultError(error) {
9
+ return { ok: false, error };
10
+ }
11
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/interface/result.ts"],"names":[],"mappings":";;AAIA,4BAEC;AAED,kCAEC;AAND,SAAgB,QAAQ,CAAO,KAAQ;IACnC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC;AAED,SAAgB,WAAW,CAAO,KAAQ;IACtC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export type Thumbnail = {
2
+ type: ThumbnailType;
3
+ thumbnail: Uint8Array;
4
+ };
5
+ export declare enum ThumbnailType {
6
+ Type1 = 1,
7
+ Type2 = 2
8
+ }
9
+ export type ThumbnailResult = {
10
+ nodeUid: string;
11
+ ok: true;
12
+ thumbnail: Uint8Array;
13
+ } | {
14
+ nodeUid: string;
15
+ ok: false;
16
+ error: string;
17
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThumbnailType = void 0;
4
+ var ThumbnailType;
5
+ (function (ThumbnailType) {
6
+ ThumbnailType[ThumbnailType["Type1"] = 1] = "Type1";
7
+ ThumbnailType[ThumbnailType["Type2"] = 2] = "Type2";
8
+ })(ThumbnailType || (exports.ThumbnailType = ThumbnailType = {}));
9
+ //# sourceMappingURL=thumbnail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thumbnail.js","sourceRoot":"","sources":["../../src/interface/thumbnail.ts"],"names":[],"mappings":";;;AAMA,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,mDAAS,CAAA;IACT,mDAAS,CAAA;AACb,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
@@ -0,0 +1,64 @@
1
+ import { Thumbnail } from "./thumbnail";
2
+ export type UploadMetadata = {
3
+ mediaType: string;
4
+ /**
5
+ * Expected size of the file.
6
+ *
7
+ * The file size is used to verify the integrity of the file during upload.
8
+ * If the expected size does not match the actual size, the upload will
9
+ * fail.
10
+ */
11
+ expectedSize: number;
12
+ /**
13
+ * Modification time of the file.
14
+ *
15
+ * The modification time will be encrypted and stored with the file.
16
+ */
17
+ modificationTime?: Date;
18
+ /**
19
+ * Additional metadata to be stored with the file.
20
+ *
21
+ * These metadata must be object that can be serialized to JSON.
22
+ *
23
+ * The metadata will be encrypted and stored with the file.
24
+ */
25
+ additionalMetadata?: object;
26
+ };
27
+ export interface FileRevisionUploader {
28
+ /**
29
+ * Uploads a file from a stream.
30
+ *
31
+ * The function will resolve to a controller that can be used to pause,
32
+ * resume and complete the upload.
33
+ *
34
+ * The function will reject if the node with the given name already exists.
35
+ */
36
+ writeStream(stream: ReadableStream, thumnbails: Thumbnail[], onProgress?: (uploadedBytes: number) => void): Promise<UploadController>;
37
+ /**
38
+ * Uploads a file from a file object. It is convenient to use this method
39
+ * when the file is already in memory. The file object is used to get the
40
+ * metadata, such as the media type, size or modification time.
41
+ *
42
+ * The function will resolve to a controller that can be used to pause,
43
+ * resume and complete the upload.
44
+ *
45
+ * The function will reject if the node with the given name already exists.
46
+ */
47
+ writeFile(fileObject: File, thumnbails: Thumbnail[], onProgress?: (uploadedBytes: number) => void): Promise<UploadController>;
48
+ }
49
+ export interface FileUploader extends FileRevisionUploader {
50
+ /**
51
+ * Returns the available name for the file.
52
+ *
53
+ * The function will return a name that includes the original name with the
54
+ * available index. The name is guaranteed to be unique in the parent folder.
55
+ *
56
+ * Example new name: `file (2).txt`.
57
+ */
58
+ getAvailableName(): Promise<string>;
59
+ }
60
+ export interface UploadController {
61
+ pause(): void;
62
+ resume(): void;
63
+ completion(): Promise<string>;
64
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/interface/upload.ts"],"names":[],"mappings":""}