@protontech/drive-sdk 0.5.1 → 0.6.1

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 (201) hide show
  1. package/dist/diagnostic/diagnostic.d.ts +7 -4
  2. package/dist/diagnostic/diagnostic.js +16 -8
  3. package/dist/diagnostic/diagnostic.js.map +1 -1
  4. package/dist/diagnostic/index.d.ts +1 -1
  5. package/dist/diagnostic/index.js +9 -1
  6. package/dist/diagnostic/index.js.map +1 -1
  7. package/dist/diagnostic/interface.d.ts +24 -9
  8. package/dist/diagnostic/nodeUtils.d.ts +13 -0
  9. package/dist/diagnostic/nodeUtils.js +90 -0
  10. package/dist/diagnostic/nodeUtils.js.map +1 -0
  11. package/dist/diagnostic/sdkDiagnosticBase.d.ts +36 -0
  12. package/dist/diagnostic/sdkDiagnosticBase.js +305 -0
  13. package/dist/diagnostic/sdkDiagnosticBase.js.map +1 -0
  14. package/dist/diagnostic/sdkDiagnosticMain.d.ts +16 -0
  15. package/dist/diagnostic/sdkDiagnosticMain.js +79 -0
  16. package/dist/diagnostic/sdkDiagnosticMain.js.map +1 -0
  17. package/dist/diagnostic/sdkDiagnosticPhotos.d.ts +13 -0
  18. package/dist/diagnostic/sdkDiagnosticPhotos.js +65 -0
  19. package/dist/diagnostic/sdkDiagnosticPhotos.js.map +1 -0
  20. package/dist/interface/index.d.ts +1 -1
  21. package/dist/interface/upload.d.ts +1 -12
  22. package/dist/internal/devices/interface.d.ts +1 -1
  23. package/dist/internal/devices/manager.js +1 -1
  24. package/dist/internal/devices/manager.js.map +1 -1
  25. package/dist/internal/devices/manager.test.js +3 -3
  26. package/dist/internal/devices/manager.test.js.map +1 -1
  27. package/dist/internal/errors.d.ts +5 -0
  28. package/dist/internal/errors.js +23 -0
  29. package/dist/internal/errors.js.map +1 -1
  30. package/dist/internal/errors.test.js +53 -2
  31. package/dist/internal/errors.test.js.map +1 -1
  32. package/dist/internal/nodes/apiService.d.ts +11 -1
  33. package/dist/internal/nodes/apiService.js +20 -1
  34. package/dist/internal/nodes/apiService.js.map +1 -1
  35. package/dist/internal/nodes/apiService.test.js +1 -1
  36. package/dist/internal/nodes/apiService.test.js.map +1 -1
  37. package/dist/internal/nodes/cryptoReporter.js +3 -0
  38. package/dist/internal/nodes/cryptoReporter.js.map +1 -1
  39. package/dist/internal/nodes/cryptoService.d.ts +4 -0
  40. package/dist/internal/nodes/cryptoService.js +6 -0
  41. package/dist/internal/nodes/cryptoService.js.map +1 -1
  42. package/dist/internal/nodes/index.d.ts +1 -1
  43. package/dist/internal/nodes/index.js +2 -2
  44. package/dist/internal/nodes/index.js.map +1 -1
  45. package/dist/internal/nodes/index.test.js +2 -2
  46. package/dist/internal/nodes/index.test.js.map +1 -1
  47. package/dist/internal/nodes/interface.d.ts +1 -1
  48. package/dist/internal/nodes/nodeName.d.ts +8 -0
  49. package/dist/internal/nodes/nodeName.js +30 -0
  50. package/dist/internal/nodes/nodeName.js.map +1 -0
  51. package/dist/internal/nodes/nodeName.test.d.ts +1 -0
  52. package/dist/internal/nodes/nodeName.test.js +50 -0
  53. package/dist/internal/nodes/nodeName.test.js.map +1 -0
  54. package/dist/internal/nodes/nodesAccess.d.ts +1 -1
  55. package/dist/internal/nodes/nodesAccess.js +4 -4
  56. package/dist/internal/nodes/nodesAccess.js.map +1 -1
  57. package/dist/internal/nodes/nodesAccess.test.js +2 -2
  58. package/dist/internal/nodes/nodesAccess.test.js.map +1 -1
  59. package/dist/internal/nodes/nodesManagement.d.ts +1 -0
  60. package/dist/internal/nodes/nodesManagement.js +30 -1
  61. package/dist/internal/nodes/nodesManagement.js.map +1 -1
  62. package/dist/internal/nodes/nodesManagement.test.js +61 -0
  63. package/dist/internal/nodes/nodesManagement.test.js.map +1 -1
  64. package/dist/internal/photos/albums.js +1 -1
  65. package/dist/internal/photos/albums.js.map +1 -1
  66. package/dist/internal/photos/apiService.d.ts +6 -0
  67. package/dist/internal/photos/apiService.js +16 -0
  68. package/dist/internal/photos/apiService.js.map +1 -1
  69. package/dist/internal/photos/index.d.ts +3 -1
  70. package/dist/internal/photos/index.js +6 -2
  71. package/dist/internal/photos/index.js.map +1 -1
  72. package/dist/internal/photos/interface.d.ts +4 -1
  73. package/dist/internal/photos/shares.d.ts +1 -1
  74. package/dist/internal/photos/shares.js +3 -3
  75. package/dist/internal/photos/shares.js.map +1 -1
  76. package/dist/internal/photos/timeline.d.ts +8 -1
  77. package/dist/internal/photos/timeline.js +36 -2
  78. package/dist/internal/photos/timeline.js.map +1 -1
  79. package/dist/internal/photos/timeline.test.d.ts +1 -0
  80. package/dist/internal/photos/timeline.test.js +99 -0
  81. package/dist/internal/photos/timeline.test.js.map +1 -0
  82. package/dist/internal/shares/cryptoService.js +3 -0
  83. package/dist/internal/shares/cryptoService.js.map +1 -1
  84. package/dist/internal/shares/index.d.ts +1 -0
  85. package/dist/internal/shares/index.js +3 -0
  86. package/dist/internal/shares/index.js.map +1 -1
  87. package/dist/internal/shares/interface.d.ts +8 -0
  88. package/dist/internal/shares/interface.js +10 -1
  89. package/dist/internal/shares/interface.js.map +1 -1
  90. package/dist/internal/shares/manager.d.ts +1 -1
  91. package/dist/internal/shares/manager.js +4 -4
  92. package/dist/internal/shares/manager.js.map +1 -1
  93. package/dist/internal/shares/manager.test.js +7 -7
  94. package/dist/internal/shares/manager.test.js.map +1 -1
  95. package/dist/internal/sharing/apiService.d.ts +3 -1
  96. package/dist/internal/sharing/apiService.js +16 -12
  97. package/dist/internal/sharing/apiService.js.map +1 -1
  98. package/dist/internal/sharing/index.d.ts +2 -1
  99. package/dist/internal/sharing/index.js +6 -2
  100. package/dist/internal/sharing/index.js.map +1 -1
  101. package/dist/internal/sharing/interface.d.ts +1 -1
  102. package/dist/internal/sharing/sharingAccess.js +1 -1
  103. package/dist/internal/sharing/sharingAccess.js.map +1 -1
  104. package/dist/internal/sharing/sharingAccess.test.js +1 -1
  105. package/dist/internal/sharing/sharingAccess.test.js.map +1 -1
  106. package/dist/internal/sharing/sharingManagement.js +32 -14
  107. package/dist/internal/sharing/sharingManagement.js.map +1 -1
  108. package/dist/internal/sharing/sharingManagement.test.js +46 -1
  109. package/dist/internal/sharing/sharingManagement.test.js.map +1 -1
  110. package/dist/internal/sharingPublic/cryptoReporter.js +3 -0
  111. package/dist/internal/sharingPublic/cryptoReporter.js.map +1 -1
  112. package/dist/internal/sharingPublic/index.d.ts +3 -0
  113. package/dist/internal/sharingPublic/index.js +5 -1
  114. package/dist/internal/sharingPublic/index.js.map +1 -1
  115. package/dist/internal/sharingPublic/shares.d.ts +1 -1
  116. package/dist/internal/sharingPublic/shares.js +1 -2
  117. package/dist/internal/sharingPublic/shares.js.map +1 -1
  118. package/dist/internal/upload/apiService.d.ts +0 -9
  119. package/dist/internal/upload/apiService.js +0 -16
  120. package/dist/internal/upload/apiService.js.map +1 -1
  121. package/dist/internal/upload/cryptoService.d.ts +0 -4
  122. package/dist/internal/upload/cryptoService.js +0 -6
  123. package/dist/internal/upload/cryptoService.js.map +1 -1
  124. package/dist/internal/upload/fileUploader.d.ts +0 -1
  125. package/dist/internal/upload/fileUploader.js +0 -4
  126. package/dist/internal/upload/fileUploader.js.map +1 -1
  127. package/dist/internal/upload/manager.d.ts +0 -1
  128. package/dist/internal/upload/manager.js +0 -51
  129. package/dist/internal/upload/manager.js.map +1 -1
  130. package/dist/internal/upload/manager.test.js +0 -61
  131. package/dist/internal/upload/manager.test.js.map +1 -1
  132. package/dist/protonDriveClient.d.ts +17 -2
  133. package/dist/protonDriveClient.js +19 -1
  134. package/dist/protonDriveClient.js.map +1 -1
  135. package/dist/protonDrivePhotosClient.d.ts +119 -4
  136. package/dist/protonDrivePhotosClient.js +183 -10
  137. package/dist/protonDrivePhotosClient.js.map +1 -1
  138. package/dist/protonDrivePublicLinkClient.d.ts +33 -1
  139. package/dist/protonDrivePublicLinkClient.js +51 -2
  140. package/dist/protonDrivePublicLinkClient.js.map +1 -1
  141. package/package.json +1 -1
  142. package/src/diagnostic/diagnostic.ts +27 -8
  143. package/src/diagnostic/index.ts +17 -2
  144. package/src/diagnostic/interface.ts +35 -9
  145. package/src/diagnostic/nodeUtils.ts +100 -0
  146. package/src/diagnostic/{sdkDiagnostic.ts → sdkDiagnosticBase.ts} +204 -204
  147. package/src/diagnostic/sdkDiagnosticMain.ts +95 -0
  148. package/src/diagnostic/sdkDiagnosticPhotos.ts +70 -0
  149. package/src/interface/index.ts +1 -1
  150. package/src/interface/upload.ts +1 -13
  151. package/src/internal/devices/interface.ts +1 -1
  152. package/src/internal/devices/manager.test.ts +3 -3
  153. package/src/internal/devices/manager.ts +1 -1
  154. package/src/internal/errors.test.ts +62 -1
  155. package/src/internal/errors.ts +27 -0
  156. package/src/internal/nodes/apiService.test.ts +1 -1
  157. package/src/internal/nodes/apiService.ts +42 -0
  158. package/src/internal/nodes/cryptoReporter.ts +6 -5
  159. package/src/internal/nodes/cryptoService.ts +9 -0
  160. package/src/internal/nodes/index.test.ts +2 -1
  161. package/src/internal/nodes/index.ts +2 -1
  162. package/src/internal/nodes/interface.ts +1 -1
  163. package/src/internal/nodes/nodeName.test.ts +57 -0
  164. package/src/internal/nodes/nodeName.ts +26 -0
  165. package/src/internal/nodes/nodesAccess.test.ts +2 -2
  166. package/src/internal/nodes/nodesAccess.ts +5 -5
  167. package/src/internal/nodes/nodesManagement.test.ts +65 -0
  168. package/src/internal/nodes/nodesManagement.ts +43 -1
  169. package/src/internal/photos/albums.ts +1 -1
  170. package/src/internal/photos/apiService.ts +40 -0
  171. package/src/internal/photos/index.ts +13 -1
  172. package/src/internal/photos/interface.ts +4 -1
  173. package/src/internal/photos/shares.ts +3 -3
  174. package/src/internal/photos/timeline.test.ts +116 -0
  175. package/src/internal/photos/timeline.ts +47 -2
  176. package/src/internal/shares/cryptoService.ts +5 -1
  177. package/src/internal/shares/index.ts +1 -0
  178. package/src/internal/shares/interface.ts +9 -0
  179. package/src/internal/shares/manager.test.ts +7 -7
  180. package/src/internal/shares/manager.ts +4 -4
  181. package/src/internal/sharing/apiService.ts +15 -12
  182. package/src/internal/sharing/index.ts +7 -1
  183. package/src/internal/sharing/interface.ts +1 -1
  184. package/src/internal/sharing/sharingAccess.test.ts +1 -1
  185. package/src/internal/sharing/sharingAccess.ts +1 -1
  186. package/src/internal/sharing/sharingManagement.test.ts +59 -1
  187. package/src/internal/sharing/sharingManagement.ts +33 -14
  188. package/src/internal/sharingPublic/cryptoReporter.ts +5 -1
  189. package/src/internal/sharingPublic/index.ts +5 -1
  190. package/src/internal/sharingPublic/shares.ts +1 -2
  191. package/src/internal/upload/apiService.ts +0 -39
  192. package/src/internal/upload/cryptoService.ts +0 -9
  193. package/src/internal/upload/fileUploader.ts +0 -5
  194. package/src/internal/upload/manager.test.ts +0 -65
  195. package/src/internal/upload/manager.ts +0 -64
  196. package/src/protonDriveClient.ts +21 -2
  197. package/src/protonDrivePhotosClient.ts +217 -9
  198. package/src/protonDrivePublicLinkClient.ts +77 -2
  199. package/dist/diagnostic/sdkDiagnostic.d.ts +0 -23
  200. package/dist/diagnostic/sdkDiagnostic.js +0 -320
  201. package/dist/diagnostic/sdkDiagnostic.js.map +0 -1
@@ -10,12 +10,20 @@ import {
10
10
  MaybeNode,
11
11
  ThumbnailType,
12
12
  ThumbnailResult,
13
+ ShareNodeSettings,
14
+ ShareResult,
15
+ UnshareNodeSettings,
16
+ ProtonInvitationOrUid,
17
+ NonProtonInvitationOrUid,
18
+ ProtonInvitationWithNode,
19
+ NodeResult,
13
20
  } from './interface';
14
21
  import { getConfig } from './config';
15
22
  import { DriveCrypto } from './crypto';
16
23
  import { Telemetry } from './telemetry';
17
24
  import {
18
25
  convertInternalMissingNodeIterator,
26
+ convertInternalNode,
19
27
  convertInternalNodeIterator,
20
28
  convertInternalNodePromise,
21
29
  getUid,
@@ -25,7 +33,12 @@ import { DriveAPIService } from './internal/apiService';
25
33
  import { initDownloadModule } from './internal/download';
26
34
  import { DriveEventsService, DriveListener, EventSubscription } from './internal/events';
27
35
  import { initNodesModule } from './internal/nodes';
28
- import { initPhotosModule, initPhotoSharesModule, initPhotoUploadModule } from './internal/photos';
36
+ import {
37
+ PHOTOS_SHARE_TARGET_TYPES,
38
+ initPhotosModule,
39
+ initPhotoSharesModule,
40
+ initPhotoUploadModule,
41
+ } from './internal/photos';
29
42
  import { SDKEvents } from './internal/sdkEvents';
30
43
  import { initSharesModule } from './internal/shares';
31
44
  import { initSharingModule } from './internal/sharing';
@@ -72,7 +85,7 @@ export class ProtonDrivePhotosClient {
72
85
  if (!telemetry) {
73
86
  telemetry = new Telemetry();
74
87
  }
75
- this.logger = telemetry.getLogger('interface');
88
+ this.logger = telemetry.getLogger('photos-interface');
76
89
 
77
90
  const fullConfig = getConfig(config);
78
91
  this.sdkEvents = new SDKEvents(telemetry);
@@ -102,8 +115,9 @@ export class ProtonDrivePhotosClient {
102
115
  account,
103
116
  cryptoModule,
104
117
  this.photoShares,
118
+ fullConfig.clientUid,
105
119
  );
106
- this.photos = initPhotosModule(apiService, this.photoShares, this.nodes.access);
120
+ this.photos = initPhotosModule(telemetry, apiService, cryptoModule, this.photoShares, this.nodes.access);
107
121
  this.sharing = initSharingModule(
108
122
  telemetry,
109
123
  apiService,
@@ -112,6 +126,7 @@ export class ProtonDrivePhotosClient {
112
126
  cryptoModule,
113
127
  this.photoShares,
114
128
  this.nodes.access,
129
+ PHOTOS_SHARE_TARGET_TYPES,
115
130
  );
116
131
  this.download = initDownloadModule(
117
132
  telemetry,
@@ -204,6 +219,16 @@ export class ProtonDrivePhotosClient {
204
219
  yield* this.photos.timeline.iterateTimeline(signal);
205
220
  }
206
221
 
222
+ /**
223
+ * Iterates the trashed nodes.
224
+ *
225
+ * See `ProtonDriveClient.iterateTrashedNodes` for more information.
226
+ */
227
+ async *iterateTrashedNodes(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
228
+ this.logger.info('Iterating trashed nodes');
229
+ yield* convertInternalNodeIterator(this.nodes.access.iterateTrashedNodes(signal));
230
+ }
231
+
207
232
  /**
208
233
  * Iterates the nodes by their UIDs.
209
234
  *
@@ -226,14 +251,163 @@ export class ProtonDrivePhotosClient {
226
251
  }
227
252
 
228
253
  /**
229
- * Iterates the albums.
254
+ * Rename the node.
230
255
  *
231
- * The output is not sorted and the order of the nodes is not guaranteed.
256
+ * See `ProtonDriveClient.renameNode` for more information.
232
257
  */
233
- async *iterateAlbums(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
234
- this.logger.info('Iterating albums');
235
- // TODO: expose album type
236
- yield* convertInternalNodeIterator(this.photos.albums.iterateAlbums(signal));
258
+ async renameNode(nodeUid: NodeOrUid, newName: string): Promise<MaybeNode> {
259
+ this.logger.info(`Renaming node ${getUid(nodeUid)}`);
260
+ return convertInternalNodePromise(this.nodes.management.renameNode(getUid(nodeUid), newName));
261
+ }
262
+
263
+ /**
264
+ * Trash the nodes.
265
+ *
266
+ * See `ProtonDriveClient.trashNodes` for more information.
267
+ */
268
+ async *trashNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
269
+ this.logger.info(`Trashing ${nodeUids.length} nodes`);
270
+ yield* this.nodes.management.trashNodes(getUids(nodeUids), signal);
271
+ }
272
+
273
+ /**
274
+ * Restore the nodes from the trash to their original place.
275
+ *
276
+ * See `ProtonDriveClient.restoreNodes` for more information.
277
+ */
278
+ async *restoreNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
279
+ this.logger.info(`Restoring ${nodeUids.length} nodes`);
280
+ yield* this.nodes.management.restoreNodes(getUids(nodeUids), signal);
281
+ }
282
+
283
+ /**
284
+ * Delete the nodes permanently.
285
+ *
286
+ * See `ProtonDriveClient.deleteNodes` for more information.
287
+ */
288
+ async *deleteNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
289
+ this.logger.info(`Deleting ${nodeUids.length} nodes`);
290
+ yield* this.nodes.management.deleteNodes(getUids(nodeUids), signal);
291
+ }
292
+
293
+ /**
294
+ * Empty the trash.
295
+ *
296
+ * See `ProtonDriveClient.emptyTrash` for more information.
297
+ */
298
+ async emptyTrash(): Promise<void> {
299
+ this.logger.info('Emptying trash');
300
+ throw new Error('Method not implemented');
301
+ }
302
+
303
+ /**
304
+ * Iterates the nodes shared by the user.
305
+ *
306
+ * See `ProtonDriveClient.iterateSharedNodes` for more information.
307
+ */
308
+ async *iterateSharedNodes(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
309
+ this.logger.info('Iterating shared nodes by me');
310
+ yield* convertInternalNodeIterator(this.sharing.access.iterateSharedNodes(signal));
311
+ }
312
+
313
+ /**
314
+ * Iterates the nodes shared with the user.
315
+ *
316
+ * See `ProtonDriveClient.iterateSharedNodesWithMe` for more information.
317
+ */
318
+ async *iterateSharedNodesWithMe(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
319
+ this.logger.info('Iterating shared nodes with me');
320
+
321
+ for await (const node of this.sharing.access.iterateSharedNodesWithMe(signal)) {
322
+ yield convertInternalNode(node);
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Leave shared node that was previously shared with the user.
328
+ *
329
+ * See `ProtonDriveClient.leaveSharedNode` for more information.
330
+ */
331
+ async leaveSharedNode(nodeUid: NodeOrUid): Promise<void> {
332
+ this.logger.info(`Leaving shared node with me ${getUid(nodeUid)}`);
333
+ await this.sharing.access.removeSharedNodeWithMe(getUid(nodeUid));
334
+ }
335
+
336
+ /**
337
+ * Iterates the invitations to shared nodes.
338
+ *
339
+ * See `ProtonDriveClient.iterateInvitations` for more information.
340
+ */
341
+ async *iterateInvitations(signal?: AbortSignal): AsyncGenerator<ProtonInvitationWithNode> {
342
+ this.logger.info('Iterating invitations');
343
+ yield* this.sharing.access.iterateInvitations(signal);
344
+ }
345
+
346
+ /**
347
+ * Accept the invitation to the shared node.
348
+ *
349
+ * See `ProtonDriveClient.acceptInvitation` for more information.
350
+ */
351
+ async acceptInvitation(invitationUid: ProtonInvitationOrUid): Promise<void> {
352
+ this.logger.info(`Accepting invitation ${getUid(invitationUid)}`);
353
+ await this.sharing.access.acceptInvitation(getUid(invitationUid));
354
+ }
355
+
356
+ /**
357
+ * Reject the invitation to the shared node.
358
+ *
359
+ * See `ProtonDriveClient.rejectInvitation` for more information.
360
+ */
361
+ async rejectInvitation(invitationUid: ProtonInvitationOrUid): Promise<void> {
362
+ this.logger.info(`Rejecting invitation ${getUid(invitationUid)}`);
363
+ await this.sharing.access.rejectInvitation(getUid(invitationUid));
364
+ }
365
+
366
+ /**
367
+ * Get sharing info of the node.
368
+ *
369
+ * See `ProtonDriveClient.getSharingInfo` for more information.
370
+ */
371
+ async getSharingInfo(nodeUid: NodeOrUid): Promise<ShareResult | undefined> {
372
+ this.logger.info(`Getting sharing info for ${getUid(nodeUid)}`);
373
+ return this.sharing.management.getSharingInfo(getUid(nodeUid));
374
+ }
375
+
376
+ /**
377
+ * Share or update sharing of the node.
378
+ *
379
+ * See `ProtonDriveClient.shareNode` for more information.
380
+ */
381
+ async shareNode(nodeUid: NodeOrUid, settings: ShareNodeSettings): Promise<ShareResult> {
382
+ this.logger.info(`Sharing node ${getUid(nodeUid)}`);
383
+ return this.sharing.management.shareNode(getUid(nodeUid), settings);
384
+ }
385
+
386
+ /**
387
+ * Unshare the node, completely or partially.
388
+ *
389
+ * See `ProtonDriveClient.unshareNode` for more information.
390
+ */
391
+ async unshareNode(nodeUid: NodeOrUid, settings?: UnshareNodeSettings): Promise<ShareResult | undefined> {
392
+ if (!settings) {
393
+ this.logger.info(`Unsharing node ${getUid(nodeUid)}`);
394
+ } else {
395
+ this.logger.info(`Partially unsharing ${getUid(nodeUid)}`);
396
+ }
397
+ return this.sharing.management.unshareNode(getUid(nodeUid), settings);
398
+ }
399
+
400
+ /**
401
+ * Resend the invitation email to shared node.
402
+ *
403
+ * See `ProtonDriveClient.resendInvitation` for more information.
404
+ */
405
+ async resendInvitation(
406
+ nodeUid: NodeOrUid,
407
+ invitationUid: ProtonInvitationOrUid | NonProtonInvitationOrUid,
408
+ ): Promise<void> {
409
+ this.logger.info(`Resending invitation ${getUid(invitationUid)}`);
410
+ return this.sharing.management.resendInvitationEmail(getUid(nodeUid), getUid(invitationUid));
237
411
  }
238
412
 
239
413
  /**
@@ -279,4 +453,38 @@ export class ProtonDrivePhotosClient {
279
453
  const parentFolderUid = await this.nodes.access.getVolumeRootFolder();
280
454
  return this.upload.getFileUploader(getUid(parentFolderUid), name, metadata, signal);
281
455
  }
456
+
457
+ /**
458
+ * Check if the photo is a duplicate.
459
+ *
460
+ * For given photo name, find existing photos with the same name
461
+ * in the timeline and check if the photo content is also the same.
462
+ * Only the same name is not considered as duplicate photo because
463
+ * it is expected that there are photos with the same name (e.g.,
464
+ * date as a name from multiple cameras, or rolling number).
465
+ *
466
+ * The function accepts a callback to generate the SHA1 and it is
467
+ * called only when there is any matching node name hash to avoid
468
+ * computation for every node if its not necessary.
469
+ *
470
+ * @param name - The name of the photo to check for duplicates.
471
+ * @param generateSha1 - A callback to generate the hex string representation of the SHA1 of the photo content.
472
+ * @param signal - An optional abort signal to cancel the operation.
473
+ * @returns True if the photo already exists in the timeline, false otherwise.
474
+ */
475
+ async isDuplicatePhoto(name: string, generateSha1: () => Promise<string>, signal?: AbortSignal): Promise<boolean> {
476
+ this.logger.info(`Checking if photo is a duplicate`);
477
+ return this.photos.timeline.isDuplicatePhoto(name, generateSha1, signal);
478
+ }
479
+
480
+ /**
481
+ * Iterates the albums.
482
+ *
483
+ * The output is not sorted and the order of the nodes is not guaranteed.
484
+ */
485
+ async *iterateAlbums(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
486
+ this.logger.info('Iterating albums');
487
+ // TODO: expose album type
488
+ yield* convertInternalNodeIterator(this.photos.albums.iterateAlbums(signal));
489
+ }
282
490
  }
@@ -15,6 +15,9 @@ import {
15
15
  FileDownloader,
16
16
  ThumbnailType,
17
17
  ThumbnailResult,
18
+ UploadMetadata,
19
+ FileUploader,
20
+ NodeResult,
18
21
  } from './interface';
19
22
  import { Telemetry } from './telemetry';
20
23
  import {
@@ -28,6 +31,7 @@ import { DriveAPIService } from './internal/apiService';
28
31
  import { initDownloadModule } from './internal/download';
29
32
  import { SDKEvents } from './internal/sdkEvents';
30
33
  import { initSharingPublicModule } from './internal/sharingPublic';
34
+ import { initUploadModule } from './internal/upload';
31
35
 
32
36
  /**
33
37
  * ProtonDrivePublicLinkClient is the interface for the public link client.
@@ -47,6 +51,7 @@ export class ProtonDrivePublicLinkClient {
47
51
  private sdkEvents: SDKEvents;
48
52
  private sharingPublic: ReturnType<typeof initSharingPublicModule>;
49
53
  private download: ReturnType<typeof initDownloadModule>;
54
+ private upload: ReturnType<typeof initUploadModule>;
50
55
 
51
56
  public experimental: {
52
57
  /**
@@ -91,7 +96,7 @@ export class ProtonDrivePublicLinkClient {
91
96
  if (!telemetry) {
92
97
  telemetry = new Telemetry();
93
98
  }
94
- this.logger = telemetry.getLogger('interface');
99
+ this.logger = telemetry.getLogger('publicLink-interface');
95
100
 
96
101
  // Use only in memory cache for public link as there are no events to keep it up to date if persisted.
97
102
  const entitiesCache = new MemoryCache<string>();
@@ -129,6 +134,14 @@ export class ProtonDrivePublicLinkClient {
129
134
  this.sharingPublic.nodes.access,
130
135
  this.sharingPublic.nodes.revisions,
131
136
  );
137
+ this.upload = initUploadModule(
138
+ telemetry,
139
+ apiService,
140
+ cryptoModule,
141
+ this.sharingPublic.shares,
142
+ this.sharingPublic.nodes.access,
143
+ fullConfig.clientUid,
144
+ );
132
145
 
133
146
  this.experimental = {
134
147
  getNodeUrl: async (nodeUid: NodeOrUid) => {
@@ -151,7 +164,7 @@ export class ProtonDrivePublicLinkClient {
151
164
  */
152
165
  async getRootNode(): Promise<MaybeNode> {
153
166
  this.logger.info(`Getting root node`);
154
- const { rootNodeUid } = await this.sharingPublic.shares.getOwnVolumeIDs();
167
+ const { rootNodeUid } = await this.sharingPublic.shares.getRootIDs();
155
168
  return convertInternalNodePromise(this.sharingPublic.nodes.access.getNode(rootNodeUid));
156
169
  }
157
170
 
@@ -193,6 +206,38 @@ export class ProtonDrivePublicLinkClient {
193
206
  return convertInternalNodePromise(this.sharingPublic.nodes.access.getNode(getUid(nodeUid)));
194
207
  }
195
208
 
209
+ /**
210
+ * Rename the node.
211
+ *
212
+ * See `ProtonDriveClient.renameNode` for more information.
213
+ */
214
+ async renameNode(nodeUid: NodeOrUid, newName: string): Promise<MaybeNode> {
215
+ this.logger.info(`Renaming node ${getUid(nodeUid)}`);
216
+ return convertInternalNodePromise(this.sharingPublic.nodes.management.renameNode(getUid(nodeUid), newName));
217
+ }
218
+
219
+ /**
220
+ * Delete the nodes permanently.
221
+ *
222
+ * See `ProtonDriveClient.deleteNodes` for more information.
223
+ */
224
+ async *deleteNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
225
+ this.logger.info(`Deleting ${nodeUids.length} nodes`);
226
+ yield* this.sharingPublic.nodes.management.deleteNodes(getUids(nodeUids), signal);
227
+ }
228
+
229
+ /**
230
+ * Create a new folder.
231
+ *
232
+ * See `ProtonDriveClient.createFolder` for more information.
233
+ */
234
+ async createFolder(parentNodeUid: NodeOrUid, name: string, modificationTime?: Date): Promise<MaybeNode> {
235
+ this.logger.info(`Creating folder in ${getUid(parentNodeUid)}`);
236
+ return convertInternalNodePromise(
237
+ this.sharingPublic.nodes.management.createFolder(getUid(parentNodeUid), name, modificationTime),
238
+ );
239
+ }
240
+
196
241
  /**
197
242
  * Get the file downloader to download the node content.
198
243
  *
@@ -216,4 +261,34 @@ export class ProtonDrivePublicLinkClient {
216
261
  this.logger.info(`Iterating ${nodeUids.length} thumbnails`);
217
262
  yield* this.download.iterateThumbnails(getUids(nodeUids), thumbnailType, signal);
218
263
  }
264
+
265
+ /**
266
+ * Get the file uploader to upload a new file. For uploading a new
267
+ * revision, use `getFileRevisionUploader` instead.
268
+ *
269
+ * See `ProtonDriveClient.getFileUploader` for more information.
270
+ */
271
+ async getFileUploader(
272
+ parentFolderUid: NodeOrUid,
273
+ name: string,
274
+ metadata: UploadMetadata,
275
+ signal?: AbortSignal,
276
+ ): Promise<FileUploader> {
277
+ this.logger.info(`Getting file uploader for parent ${getUid(parentFolderUid)}`);
278
+ return this.upload.getFileUploader(getUid(parentFolderUid), name, metadata, signal);
279
+ }
280
+
281
+ /**
282
+ * Same as `getFileUploader`, but for a uploading new revision of the file.
283
+ *
284
+ * See `ProtonDriveClient.getFileRevisionUploader` for more information.
285
+ */
286
+ async getFileRevisionUploader(
287
+ nodeUid: NodeOrUid,
288
+ metadata: UploadMetadata,
289
+ signal?: AbortSignal,
290
+ ): Promise<FileUploader> {
291
+ this.logger.info(`Getting file revision uploader for ${getUid(nodeUid)}`);
292
+ return this.upload.getFileRevisionUploader(getUid(nodeUid), metadata, signal);
293
+ }
219
294
  }
@@ -1,23 +0,0 @@
1
- import { MaybeNode } from '../interface';
2
- import { ProtonDriveClient } from '../protonDriveClient';
3
- import { DiagnosticOptions, DiagnosticResult } from './interface';
4
- /**
5
- * Diagnostic tool that uses SDK to traverse the node tree and verify
6
- * the integrity of the node tree.
7
- *
8
- * It produces only events that can be read by direct SDK invocation.
9
- * To get the full diagnostic, use {@link FullSDKDiagnostic}.
10
- */
11
- export declare class SDKDiagnostic {
12
- private protonDriveClient;
13
- constructor(protonDriveClient: ProtonDriveClient);
14
- verifyMyFiles(options?: DiagnosticOptions): AsyncGenerator<DiagnosticResult>;
15
- verifyNodeTree(node: MaybeNode, options?: DiagnosticOptions): AsyncGenerator<DiagnosticResult>;
16
- private verifyNode;
17
- private verifyAuthor;
18
- private verifyFileExtendedAttributes;
19
- private verifyContent;
20
- private verifyThumbnails;
21
- private verifyNodeChildren;
22
- private verifyExpectedNodeChildren;
23
- }