@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.
- package/dist/diagnostic/diagnostic.d.ts +7 -4
- package/dist/diagnostic/diagnostic.js +16 -8
- package/dist/diagnostic/diagnostic.js.map +1 -1
- package/dist/diagnostic/index.d.ts +1 -1
- package/dist/diagnostic/index.js +9 -1
- package/dist/diagnostic/index.js.map +1 -1
- package/dist/diagnostic/interface.d.ts +24 -9
- package/dist/diagnostic/nodeUtils.d.ts +13 -0
- package/dist/diagnostic/nodeUtils.js +90 -0
- package/dist/diagnostic/nodeUtils.js.map +1 -0
- package/dist/diagnostic/sdkDiagnosticBase.d.ts +36 -0
- package/dist/diagnostic/sdkDiagnosticBase.js +305 -0
- package/dist/diagnostic/sdkDiagnosticBase.js.map +1 -0
- package/dist/diagnostic/sdkDiagnosticMain.d.ts +16 -0
- package/dist/diagnostic/sdkDiagnosticMain.js +79 -0
- package/dist/diagnostic/sdkDiagnosticMain.js.map +1 -0
- package/dist/diagnostic/sdkDiagnosticPhotos.d.ts +13 -0
- package/dist/diagnostic/sdkDiagnosticPhotos.js +65 -0
- package/dist/diagnostic/sdkDiagnosticPhotos.js.map +1 -0
- package/dist/interface/index.d.ts +1 -1
- package/dist/interface/upload.d.ts +1 -12
- package/dist/internal/devices/interface.d.ts +1 -1
- package/dist/internal/devices/manager.js +1 -1
- package/dist/internal/devices/manager.js.map +1 -1
- package/dist/internal/devices/manager.test.js +3 -3
- package/dist/internal/devices/manager.test.js.map +1 -1
- package/dist/internal/errors.d.ts +5 -0
- package/dist/internal/errors.js +23 -0
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/errors.test.js +53 -2
- package/dist/internal/errors.test.js.map +1 -1
- package/dist/internal/nodes/apiService.d.ts +11 -1
- package/dist/internal/nodes/apiService.js +20 -1
- package/dist/internal/nodes/apiService.js.map +1 -1
- package/dist/internal/nodes/apiService.test.js +1 -1
- package/dist/internal/nodes/apiService.test.js.map +1 -1
- package/dist/internal/nodes/cryptoReporter.js +3 -0
- package/dist/internal/nodes/cryptoReporter.js.map +1 -1
- package/dist/internal/nodes/cryptoService.d.ts +4 -0
- package/dist/internal/nodes/cryptoService.js +6 -0
- package/dist/internal/nodes/cryptoService.js.map +1 -1
- package/dist/internal/nodes/index.d.ts +1 -1
- package/dist/internal/nodes/index.js +2 -2
- package/dist/internal/nodes/index.js.map +1 -1
- package/dist/internal/nodes/index.test.js +2 -2
- package/dist/internal/nodes/index.test.js.map +1 -1
- package/dist/internal/nodes/interface.d.ts +1 -1
- package/dist/internal/nodes/nodeName.d.ts +8 -0
- package/dist/internal/nodes/nodeName.js +30 -0
- package/dist/internal/nodes/nodeName.js.map +1 -0
- package/dist/internal/nodes/nodeName.test.d.ts +1 -0
- package/dist/internal/nodes/nodeName.test.js +50 -0
- package/dist/internal/nodes/nodeName.test.js.map +1 -0
- package/dist/internal/nodes/nodesAccess.d.ts +1 -1
- package/dist/internal/nodes/nodesAccess.js +4 -4
- package/dist/internal/nodes/nodesAccess.js.map +1 -1
- package/dist/internal/nodes/nodesAccess.test.js +2 -2
- package/dist/internal/nodes/nodesAccess.test.js.map +1 -1
- package/dist/internal/nodes/nodesManagement.d.ts +1 -0
- package/dist/internal/nodes/nodesManagement.js +30 -1
- package/dist/internal/nodes/nodesManagement.js.map +1 -1
- package/dist/internal/nodes/nodesManagement.test.js +61 -0
- package/dist/internal/nodes/nodesManagement.test.js.map +1 -1
- package/dist/internal/photos/albums.js +1 -1
- package/dist/internal/photos/albums.js.map +1 -1
- package/dist/internal/photos/apiService.d.ts +6 -0
- package/dist/internal/photos/apiService.js +16 -0
- package/dist/internal/photos/apiService.js.map +1 -1
- package/dist/internal/photos/index.d.ts +3 -1
- package/dist/internal/photos/index.js +6 -2
- package/dist/internal/photos/index.js.map +1 -1
- package/dist/internal/photos/interface.d.ts +4 -1
- package/dist/internal/photos/shares.d.ts +1 -1
- package/dist/internal/photos/shares.js +3 -3
- package/dist/internal/photos/shares.js.map +1 -1
- package/dist/internal/photos/timeline.d.ts +8 -1
- package/dist/internal/photos/timeline.js +36 -2
- package/dist/internal/photos/timeline.js.map +1 -1
- package/dist/internal/photos/timeline.test.d.ts +1 -0
- package/dist/internal/photos/timeline.test.js +99 -0
- package/dist/internal/photos/timeline.test.js.map +1 -0
- package/dist/internal/shares/cryptoService.js +3 -0
- package/dist/internal/shares/cryptoService.js.map +1 -1
- package/dist/internal/shares/index.d.ts +1 -0
- package/dist/internal/shares/index.js +3 -0
- package/dist/internal/shares/index.js.map +1 -1
- package/dist/internal/shares/interface.d.ts +8 -0
- package/dist/internal/shares/interface.js +10 -1
- package/dist/internal/shares/interface.js.map +1 -1
- package/dist/internal/shares/manager.d.ts +1 -1
- package/dist/internal/shares/manager.js +4 -4
- package/dist/internal/shares/manager.js.map +1 -1
- package/dist/internal/shares/manager.test.js +7 -7
- package/dist/internal/shares/manager.test.js.map +1 -1
- package/dist/internal/sharing/apiService.d.ts +3 -1
- package/dist/internal/sharing/apiService.js +16 -12
- package/dist/internal/sharing/apiService.js.map +1 -1
- package/dist/internal/sharing/index.d.ts +2 -1
- package/dist/internal/sharing/index.js +6 -2
- package/dist/internal/sharing/index.js.map +1 -1
- package/dist/internal/sharing/interface.d.ts +1 -1
- package/dist/internal/sharing/sharingAccess.js +1 -1
- package/dist/internal/sharing/sharingAccess.js.map +1 -1
- package/dist/internal/sharing/sharingAccess.test.js +1 -1
- package/dist/internal/sharing/sharingAccess.test.js.map +1 -1
- package/dist/internal/sharing/sharingManagement.js +32 -14
- package/dist/internal/sharing/sharingManagement.js.map +1 -1
- package/dist/internal/sharing/sharingManagement.test.js +46 -1
- package/dist/internal/sharing/sharingManagement.test.js.map +1 -1
- package/dist/internal/sharingPublic/cryptoReporter.js +3 -0
- package/dist/internal/sharingPublic/cryptoReporter.js.map +1 -1
- package/dist/internal/sharingPublic/index.d.ts +3 -0
- package/dist/internal/sharingPublic/index.js +5 -1
- package/dist/internal/sharingPublic/index.js.map +1 -1
- package/dist/internal/sharingPublic/shares.d.ts +1 -1
- package/dist/internal/sharingPublic/shares.js +1 -2
- package/dist/internal/sharingPublic/shares.js.map +1 -1
- package/dist/internal/upload/apiService.d.ts +0 -9
- package/dist/internal/upload/apiService.js +0 -16
- package/dist/internal/upload/apiService.js.map +1 -1
- package/dist/internal/upload/cryptoService.d.ts +0 -4
- package/dist/internal/upload/cryptoService.js +0 -6
- package/dist/internal/upload/cryptoService.js.map +1 -1
- package/dist/internal/upload/fileUploader.d.ts +0 -1
- package/dist/internal/upload/fileUploader.js +0 -4
- package/dist/internal/upload/fileUploader.js.map +1 -1
- package/dist/internal/upload/manager.d.ts +0 -1
- package/dist/internal/upload/manager.js +0 -51
- package/dist/internal/upload/manager.js.map +1 -1
- package/dist/internal/upload/manager.test.js +0 -61
- package/dist/internal/upload/manager.test.js.map +1 -1
- package/dist/protonDriveClient.d.ts +17 -2
- package/dist/protonDriveClient.js +19 -1
- package/dist/protonDriveClient.js.map +1 -1
- package/dist/protonDrivePhotosClient.d.ts +119 -4
- package/dist/protonDrivePhotosClient.js +183 -10
- package/dist/protonDrivePhotosClient.js.map +1 -1
- package/dist/protonDrivePublicLinkClient.d.ts +33 -1
- package/dist/protonDrivePublicLinkClient.js +51 -2
- package/dist/protonDrivePublicLinkClient.js.map +1 -1
- package/package.json +1 -1
- package/src/diagnostic/diagnostic.ts +27 -8
- package/src/diagnostic/index.ts +17 -2
- package/src/diagnostic/interface.ts +35 -9
- package/src/diagnostic/nodeUtils.ts +100 -0
- package/src/diagnostic/{sdkDiagnostic.ts → sdkDiagnosticBase.ts} +204 -204
- package/src/diagnostic/sdkDiagnosticMain.ts +95 -0
- package/src/diagnostic/sdkDiagnosticPhotos.ts +70 -0
- package/src/interface/index.ts +1 -1
- package/src/interface/upload.ts +1 -13
- package/src/internal/devices/interface.ts +1 -1
- package/src/internal/devices/manager.test.ts +3 -3
- package/src/internal/devices/manager.ts +1 -1
- package/src/internal/errors.test.ts +62 -1
- package/src/internal/errors.ts +27 -0
- package/src/internal/nodes/apiService.test.ts +1 -1
- package/src/internal/nodes/apiService.ts +42 -0
- package/src/internal/nodes/cryptoReporter.ts +6 -5
- package/src/internal/nodes/cryptoService.ts +9 -0
- package/src/internal/nodes/index.test.ts +2 -1
- package/src/internal/nodes/index.ts +2 -1
- package/src/internal/nodes/interface.ts +1 -1
- package/src/internal/nodes/nodeName.test.ts +57 -0
- package/src/internal/nodes/nodeName.ts +26 -0
- package/src/internal/nodes/nodesAccess.test.ts +2 -2
- package/src/internal/nodes/nodesAccess.ts +5 -5
- package/src/internal/nodes/nodesManagement.test.ts +65 -0
- package/src/internal/nodes/nodesManagement.ts +43 -1
- package/src/internal/photos/albums.ts +1 -1
- package/src/internal/photos/apiService.ts +40 -0
- package/src/internal/photos/index.ts +13 -1
- package/src/internal/photos/interface.ts +4 -1
- package/src/internal/photos/shares.ts +3 -3
- package/src/internal/photos/timeline.test.ts +116 -0
- package/src/internal/photos/timeline.ts +47 -2
- package/src/internal/shares/cryptoService.ts +5 -1
- package/src/internal/shares/index.ts +1 -0
- package/src/internal/shares/interface.ts +9 -0
- package/src/internal/shares/manager.test.ts +7 -7
- package/src/internal/shares/manager.ts +4 -4
- package/src/internal/sharing/apiService.ts +15 -12
- package/src/internal/sharing/index.ts +7 -1
- package/src/internal/sharing/interface.ts +1 -1
- package/src/internal/sharing/sharingAccess.test.ts +1 -1
- package/src/internal/sharing/sharingAccess.ts +1 -1
- package/src/internal/sharing/sharingManagement.test.ts +59 -1
- package/src/internal/sharing/sharingManagement.ts +33 -14
- package/src/internal/sharingPublic/cryptoReporter.ts +5 -1
- package/src/internal/sharingPublic/index.ts +5 -1
- package/src/internal/sharingPublic/shares.ts +1 -2
- package/src/internal/upload/apiService.ts +0 -39
- package/src/internal/upload/cryptoService.ts +0 -9
- package/src/internal/upload/fileUploader.ts +0 -5
- package/src/internal/upload/manager.test.ts +0 -65
- package/src/internal/upload/manager.ts +0 -64
- package/src/protonDriveClient.ts +21 -2
- package/src/protonDrivePhotosClient.ts +217 -9
- package/src/protonDrivePublicLinkClient.ts +77 -2
- package/dist/diagnostic/sdkDiagnostic.d.ts +0 -23
- package/dist/diagnostic/sdkDiagnostic.js +0 -320
- 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 {
|
|
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
|
-
*
|
|
254
|
+
* Rename the node.
|
|
230
255
|
*
|
|
231
|
-
*
|
|
256
|
+
* See `ProtonDriveClient.renameNode` for more information.
|
|
232
257
|
*/
|
|
233
|
-
async
|
|
234
|
-
this.logger.info(
|
|
235
|
-
|
|
236
|
-
|
|
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.
|
|
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
|
-
}
|