@protontech/drive-sdk 0.5.0 → 0.6.0
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/{sdkDiagnosticFull.d.ts → diagnostic.d.ts} +5 -4
- package/dist/diagnostic/{sdkDiagnosticFull.js → diagnostic.js} +13 -10
- package/dist/diagnostic/diagnostic.js.map +1 -0
- package/dist/diagnostic/index.js +2 -4
- package/dist/diagnostic/index.js.map +1 -1
- package/dist/diagnostic/interface.d.ts +22 -1
- package/dist/diagnostic/sdkDiagnostic.d.ts +3 -2
- package/dist/diagnostic/sdkDiagnostic.js +79 -7
- package/dist/diagnostic/sdkDiagnostic.js.map +1 -1
- package/dist/interface/index.d.ts +2 -2
- package/dist/interface/index.js.map +1 -1
- package/dist/interface/nodes.d.ts +9 -0
- package/dist/interface/telemetry.d.ts +4 -1
- package/dist/interface/telemetry.js.map +1 -1
- package/dist/interface/upload.d.ts +1 -12
- package/dist/internal/apiService/driveTypes.d.ts +2571 -2356
- package/dist/internal/download/controller.d.ts +2 -0
- package/dist/internal/download/controller.js +15 -1
- package/dist/internal/download/controller.js.map +1 -1
- package/dist/internal/download/fileDownloader.js +6 -1
- package/dist/internal/download/fileDownloader.js.map +1 -1
- package/dist/internal/nodes/apiService.d.ts +11 -1
- package/dist/internal/nodes/apiService.js +47 -13
- package/dist/internal/nodes/apiService.js.map +1 -1
- package/dist/internal/nodes/apiService.test.js +61 -3
- package/dist/internal/nodes/apiService.test.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/debouncer.d.ts +3 -2
- package/dist/internal/nodes/debouncer.js +16 -4
- package/dist/internal/nodes/debouncer.js.map +1 -1
- package/dist/internal/nodes/debouncer.test.js +20 -12
- package/dist/internal/nodes/debouncer.test.js.map +1 -1
- package/dist/internal/nodes/extendedAttributes.js +2 -2
- package/dist/internal/nodes/extendedAttributes.js.map +1 -1
- package/dist/internal/nodes/index.d.ts +1 -1
- package/dist/internal/nodes/index.js +3 -3
- package/dist/internal/nodes/index.js.map +1 -1
- package/dist/internal/nodes/index.test.js +1 -1
- package/dist/internal/nodes/index.test.js.map +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 +5 -4
- package/dist/internal/nodes/nodesAccess.js +6 -5
- package/dist/internal/nodes/nodesAccess.js.map +1 -1
- package/dist/internal/nodes/nodesAccess.test.js +17 -5
- package/dist/internal/nodes/nodesAccess.test.js.map +1 -1
- package/dist/internal/nodes/nodesManagement.d.ts +3 -2
- package/dist/internal/nodes/nodesManagement.js +35 -4
- package/dist/internal/nodes/nodesManagement.js.map +1 -1
- package/dist/internal/nodes/nodesManagement.test.js +64 -1
- package/dist/internal/nodes/nodesManagement.test.js.map +1 -1
- package/dist/internal/photos/apiService.js +9 -20
- package/dist/internal/photos/apiService.js.map +1 -1
- package/dist/internal/photos/index.d.ts +2 -0
- package/dist/internal/photos/index.js +4 -0
- package/dist/internal/photos/index.js.map +1 -1
- package/dist/internal/photos/upload.js +7 -1
- package/dist/internal/photos/upload.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/sharing/apiService.d.ts +4 -2
- package/dist/internal/sharing/apiService.js +18 -14
- 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/sharingManagement.d.ts +4 -1
- package/dist/internal/sharing/sharingManagement.js +7 -4
- package/dist/internal/sharing/sharingManagement.js.map +1 -1
- package/dist/internal/sharingPublic/apiService.d.ts +8 -10
- package/dist/internal/sharingPublic/apiService.js +9 -63
- package/dist/internal/sharingPublic/apiService.js.map +1 -1
- package/dist/internal/sharingPublic/index.d.ts +3 -3
- package/dist/internal/sharingPublic/index.js +7 -12
- package/dist/internal/sharingPublic/index.js.map +1 -1
- package/dist/internal/sharingPublic/nodes.d.ts +13 -8
- package/dist/internal/sharingPublic/nodes.js +20 -2
- package/dist/internal/sharingPublic/nodes.js.map +1 -1
- package/dist/internal/sharingPublic/session/apiService.d.ts +7 -5
- package/dist/internal/sharingPublic/session/apiService.js +25 -4
- package/dist/internal/sharingPublic/session/apiService.js.map +1 -1
- package/dist/internal/sharingPublic/session/interface.d.ts +17 -0
- package/dist/internal/sharingPublic/session/manager.d.ts +12 -4
- package/dist/internal/sharingPublic/session/manager.js +14 -4
- package/dist/internal/sharingPublic/session/manager.js.map +1 -1
- package/dist/internal/sharingPublic/session/session.d.ts +5 -2
- package/dist/internal/sharingPublic/session/session.js +7 -3
- package/dist/internal/sharingPublic/session/session.js.map +1 -1
- package/dist/internal/sharingPublic/shares.d.ts +3 -10
- package/dist/internal/sharingPublic/shares.js +10 -33
- 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/controller.d.ts +3 -1
- package/dist/internal/upload/controller.js +16 -2
- package/dist/internal/upload/controller.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 +2 -6
- 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/internal/upload/streamUploader.d.ts +4 -3
- package/dist/internal/upload/streamUploader.js +61 -18
- package/dist/internal/upload/streamUploader.js.map +1 -1
- package/dist/internal/upload/streamUploader.test.js +38 -12
- package/dist/internal/upload/streamUploader.test.js.map +1 -1
- package/dist/protonDriveClient.d.ts +24 -4
- package/dist/protonDriveClient.js +26 -7
- package/dist/protonDriveClient.js.map +1 -1
- package/dist/protonDrivePhotosClient.d.ts +100 -4
- package/dist/protonDrivePhotosClient.js +160 -9
- package/dist/protonDrivePhotosClient.js.map +1 -1
- package/dist/protonDrivePublicLinkClient.d.ts +4 -3
- package/dist/protonDrivePublicLinkClient.js +2 -2
- package/dist/protonDrivePublicLinkClient.js.map +1 -1
- package/dist/tests/telemetry.d.ts +4 -2
- package/dist/tests/telemetry.js +3 -1
- package/dist/tests/telemetry.js.map +1 -1
- package/dist/transformers.d.ts +3 -2
- package/dist/transformers.js +6 -0
- package/dist/transformers.js.map +1 -1
- package/package.json +1 -1
- package/src/diagnostic/{sdkDiagnosticFull.ts → diagnostic.ts} +10 -6
- package/src/diagnostic/index.ts +3 -5
- package/src/diagnostic/interface.ts +39 -0
- package/src/diagnostic/sdkDiagnostic.ts +110 -9
- package/src/interface/index.ts +2 -1
- package/src/interface/nodes.ts +3 -0
- package/src/interface/telemetry.ts +5 -0
- package/src/interface/upload.ts +1 -13
- package/src/internal/apiService/driveTypes.ts +2698 -2529
- package/src/internal/download/controller.ts +13 -1
- package/src/internal/download/fileDownloader.ts +8 -1
- package/src/internal/nodes/apiService.test.ts +65 -1
- package/src/internal/nodes/apiService.ts +80 -17
- package/src/internal/nodes/cryptoService.ts +9 -0
- package/src/internal/nodes/debouncer.test.ts +25 -13
- package/src/internal/nodes/debouncer.ts +20 -4
- package/src/internal/nodes/extendedAttributes.ts +2 -2
- package/src/internal/nodes/index.test.ts +1 -0
- package/src/internal/nodes/index.ts +3 -9
- package/src/internal/nodes/nodeName.test.ts +57 -0
- package/src/internal/nodes/nodeName.ts +26 -0
- package/src/internal/nodes/nodesAccess.test.ts +17 -5
- package/src/internal/nodes/nodesAccess.ts +15 -5
- package/src/internal/nodes/nodesManagement.test.ts +68 -1
- package/src/internal/nodes/nodesManagement.ts +54 -6
- package/src/internal/photos/apiService.ts +12 -29
- package/src/internal/photos/index.ts +4 -0
- package/src/internal/photos/upload.ts +19 -1
- package/src/internal/shares/index.ts +1 -0
- package/src/internal/shares/interface.ts +9 -0
- package/src/internal/sharing/apiService.ts +17 -14
- package/src/internal/sharing/index.ts +7 -1
- package/src/internal/sharing/sharingManagement.ts +7 -4
- package/src/internal/sharingPublic/apiService.ts +23 -77
- package/src/internal/sharingPublic/index.ts +13 -11
- package/src/internal/sharingPublic/nodes.ts +33 -11
- package/src/internal/sharingPublic/session/apiService.ts +31 -9
- package/src/internal/sharingPublic/session/interface.ts +20 -0
- package/src/internal/sharingPublic/session/manager.ts +31 -8
- package/src/internal/sharingPublic/session/session.ts +10 -5
- package/src/internal/sharingPublic/shares.ts +7 -43
- package/src/internal/upload/apiService.ts +0 -39
- package/src/internal/upload/controller.ts +16 -4
- package/src/internal/upload/cryptoService.ts +0 -9
- package/src/internal/upload/fileUploader.ts +2 -7
- package/src/internal/upload/manager.test.ts +0 -65
- package/src/internal/upload/manager.ts +0 -64
- package/src/internal/upload/streamUploader.test.ts +46 -14
- package/src/internal/upload/streamUploader.ts +74 -21
- package/src/protonDriveClient.ts +46 -9
- package/src/protonDrivePhotosClient.ts +193 -8
- package/src/protonDrivePublicLinkClient.ts +7 -4
- package/src/tests/telemetry.ts +6 -3
- package/src/transformers.ts +8 -0
- package/dist/diagnostic/sdkDiagnosticFull.js.map +0 -1
- package/dist/internal/sharingPublic/cryptoCache.d.ts +0 -15
- package/dist/internal/sharingPublic/cryptoCache.js +0 -44
- package/dist/internal/sharingPublic/cryptoCache.js.map +0 -1
- package/dist/internal/sharingPublic/cryptoService.d.ts +0 -8
- package/dist/internal/sharingPublic/cryptoService.js +0 -19
- package/dist/internal/sharingPublic/cryptoService.js.map +0 -1
- package/dist/internal/sharingPublic/interface.d.ts +0 -5
- package/dist/internal/sharingPublic/interface.js +0 -3
- package/dist/internal/sharingPublic/interface.js.map +0 -1
- package/src/internal/sharingPublic/cryptoCache.ts +0 -45
- package/src/internal/sharingPublic/cryptoService.ts +0 -22
- package/src/internal/sharingPublic/interface.ts +0 -5
|
@@ -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,6 +115,7 @@ export class ProtonDrivePhotosClient {
|
|
|
102
115
|
account,
|
|
103
116
|
cryptoModule,
|
|
104
117
|
this.photoShares,
|
|
118
|
+
fullConfig.clientUid,
|
|
105
119
|
);
|
|
106
120
|
this.photos = initPhotosModule(apiService, this.photoShares, this.nodes.access);
|
|
107
121
|
this.sharing = initSharingModule(
|
|
@@ -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,15 @@ 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
|
+
* Iterates the albums.
|
|
459
|
+
*
|
|
460
|
+
* The output is not sorted and the order of the nodes is not guaranteed.
|
|
461
|
+
*/
|
|
462
|
+
async *iterateAlbums(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
|
|
463
|
+
this.logger.info('Iterating albums');
|
|
464
|
+
// TODO: expose album type
|
|
465
|
+
yield* convertInternalNodeIterator(this.photos.albums.iterateAlbums(signal));
|
|
466
|
+
}
|
|
282
467
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MemoryCache } from './cache';
|
|
2
2
|
import { getConfig } from './config';
|
|
3
|
-
import { DriveCrypto, OpenPGPCrypto, SRPModule, SessionKey } from './crypto';
|
|
3
|
+
import { DriveCrypto, OpenPGPCrypto, PrivateKey, SRPModule, SessionKey } from './crypto';
|
|
4
4
|
import {
|
|
5
5
|
ProtonDriveHTTPClient,
|
|
6
6
|
ProtonDriveTelemetry,
|
|
@@ -74,7 +74,8 @@ export class ProtonDrivePublicLinkClient {
|
|
|
74
74
|
telemetry,
|
|
75
75
|
url,
|
|
76
76
|
token,
|
|
77
|
-
|
|
77
|
+
publicShareKey,
|
|
78
|
+
publicRootNodeUid,
|
|
78
79
|
}: {
|
|
79
80
|
httpClient: ProtonDriveHTTPClient;
|
|
80
81
|
account: ProtonDriveAccount;
|
|
@@ -84,7 +85,8 @@ export class ProtonDrivePublicLinkClient {
|
|
|
84
85
|
telemetry?: ProtonDriveTelemetry;
|
|
85
86
|
url: string;
|
|
86
87
|
token: string;
|
|
87
|
-
|
|
88
|
+
publicShareKey: PrivateKey;
|
|
89
|
+
publicRootNodeUid: string;
|
|
88
90
|
}) {
|
|
89
91
|
if (!telemetry) {
|
|
90
92
|
telemetry = new Telemetry();
|
|
@@ -115,7 +117,8 @@ export class ProtonDrivePublicLinkClient {
|
|
|
115
117
|
account,
|
|
116
118
|
url,
|
|
117
119
|
token,
|
|
118
|
-
|
|
120
|
+
publicShareKey,
|
|
121
|
+
publicRootNodeUid,
|
|
119
122
|
);
|
|
120
123
|
this.download = initDownloadModule(
|
|
121
124
|
telemetry,
|
package/src/tests/telemetry.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { ProtonDriveTelemetry } from '../interface';
|
|
1
|
+
import { Logger, ProtonDriveTelemetry } from '../interface';
|
|
2
2
|
import { getMockLogger } from './logger';
|
|
3
3
|
|
|
4
|
-
export function getMockTelemetry(): ProtonDriveTelemetry {
|
|
4
|
+
export function getMockTelemetry(): ProtonDriveTelemetry & { mockLogger: Logger } {
|
|
5
|
+
const mockLogger = getMockLogger();
|
|
6
|
+
|
|
5
7
|
return {
|
|
6
|
-
|
|
8
|
+
mockLogger,
|
|
9
|
+
getLogger: () => mockLogger,
|
|
7
10
|
recordMetric: jest.fn(),
|
|
8
11
|
};
|
|
9
12
|
}
|
package/src/transformers.ts
CHANGED
|
@@ -121,6 +121,14 @@ export function convertInternalNode(node: InternalPartialNode): PublicMaybeNode
|
|
|
121
121
|
} as PublicNodeEntity);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
export async function* convertInternalRevisionIterator(
|
|
125
|
+
revisionIterator: AsyncGenerator<InternalRevision>,
|
|
126
|
+
): AsyncGenerator<PublicRevision> {
|
|
127
|
+
for await (const revision of revisionIterator) {
|
|
128
|
+
yield convertInternalRevision(revision);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
124
132
|
function convertInternalRevision(revision: InternalRevision): PublicRevision {
|
|
125
133
|
return {
|
|
126
134
|
uid: revision.uid,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdkDiagnosticFull.js","sourceRoot":"","sources":["../../src/diagnostic/sdkDiagnosticFull.ts"],"names":[],"mappings":";;;AAIA,mDAAgD;AAEhD;;;GAGG;AACH,MAAa,iBAAiB;IAEd;IACA;IACA;IAHZ,YACY,UAAsB,EACtB,SAA8B,EAC9B,UAAgC;QAFhC,eAAU,GAAV,UAAU,CAAY;QACtB,cAAS,GAAT,SAAS,CAAqB;QAC9B,eAAU,GAAV,UAAU,CAAsB;QAExC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,CAAC,aAAa,CAAC,OAA2B;QAC5C,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,CAAC,cAAc,CAAC,IAAe,EAAE,OAA2B;QAC9D,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEO,KAAK,CAAC,CAAC,WAAW,CAAC,SAA2C;QAClE,KAAK,CAAC,CAAC,IAAA,6BAAa,EAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IACzF,CAAC;IAEO,KAAK,CAAC,CAAC,iBAAiB;QAC5B,KAAK,CAAC,CAAC,IAAA,6BAAa,EAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1F,CAAC;CACJ;AA1BD,8CA0BC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PrivateKey } from '../../crypto';
|
|
2
|
-
import { ProtonDriveCryptoCache, Logger } from '../../interface';
|
|
3
|
-
/**
|
|
4
|
-
* Provides caching for public link crypto material.
|
|
5
|
-
*
|
|
6
|
-
* The cache is responsible for serialising and deserialising public link
|
|
7
|
-
* crypto material.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SharingPublicCryptoCache {
|
|
10
|
-
private logger;
|
|
11
|
-
private driveCache;
|
|
12
|
-
constructor(logger: Logger, driveCache: ProtonDriveCryptoCache);
|
|
13
|
-
setShareKey(shareKey: PrivateKey): Promise<void>;
|
|
14
|
-
getShareKey(): Promise<PrivateKey>;
|
|
15
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharingPublicCryptoCache = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Provides caching for public link crypto material.
|
|
6
|
-
*
|
|
7
|
-
* The cache is responsible for serialising and deserialising public link
|
|
8
|
-
* crypto material.
|
|
9
|
-
*/
|
|
10
|
-
class SharingPublicCryptoCache {
|
|
11
|
-
logger;
|
|
12
|
-
driveCache;
|
|
13
|
-
constructor(logger, driveCache) {
|
|
14
|
-
this.logger = logger;
|
|
15
|
-
this.driveCache = driveCache;
|
|
16
|
-
this.logger = logger;
|
|
17
|
-
this.driveCache = driveCache;
|
|
18
|
-
}
|
|
19
|
-
async setShareKey(shareKey) {
|
|
20
|
-
await this.driveCache.setEntity(getShareKeyCacheKey(), {
|
|
21
|
-
publicShareKey: {
|
|
22
|
-
key: shareKey,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async getShareKey() {
|
|
27
|
-
const shareKeyData = await this.driveCache.getEntity(getShareKeyCacheKey());
|
|
28
|
-
if (!shareKeyData.publicShareKey) {
|
|
29
|
-
try {
|
|
30
|
-
await this.driveCache.removeEntities([getShareKeyCacheKey()]);
|
|
31
|
-
}
|
|
32
|
-
catch (removingError) {
|
|
33
|
-
this.logger.warn(`Failed to remove corrupted public share key from the cache: ${removingError instanceof Error ? removingError.message : removingError}`);
|
|
34
|
-
}
|
|
35
|
-
throw new Error('Failed to deserialize public share key');
|
|
36
|
-
}
|
|
37
|
-
return shareKeyData.publicShareKey.key;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.SharingPublicCryptoCache = SharingPublicCryptoCache;
|
|
41
|
-
function getShareKeyCacheKey() {
|
|
42
|
-
return 'publicShareKey';
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=cryptoCache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoCache.js","sourceRoot":"","sources":["../../../src/internal/sharingPublic/cryptoCache.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,MAAa,wBAAwB;IAErB;IACA;IAFZ,YACY,MAAc,EACd,UAAkC;QADlC,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAwB;QAE1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAoB;QAClC,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE;YACnD,cAAc,EAAE;gBACZ,GAAG,EAAE,QAAQ;aAChB;SACJ,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,WAAW;QACb,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC5E,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YAClE,CAAC;YAAC,OAAO,aAAsB,EAAE,CAAC;gBAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,+DAA+D,aAAa,YAAY,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,CAC1I,CAAC;YACN,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC;IAC3C,CAAC;CACJ;AA/BD,4DA+BC;AAED,SAAS,mBAAmB;IACxB,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DriveCrypto, PrivateKey } from '../../crypto';
|
|
2
|
-
import { EncryptedShareCrypto } from './interface';
|
|
3
|
-
export declare class SharingPublicCryptoService {
|
|
4
|
-
private driveCrypto;
|
|
5
|
-
private password;
|
|
6
|
-
constructor(driveCrypto: DriveCrypto, password: string);
|
|
7
|
-
decryptPublicLinkShareKey(encryptedShare: EncryptedShareCrypto): Promise<PrivateKey>;
|
|
8
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharingPublicCryptoService = void 0;
|
|
4
|
-
class SharingPublicCryptoService {
|
|
5
|
-
driveCrypto;
|
|
6
|
-
password;
|
|
7
|
-
constructor(driveCrypto, password) {
|
|
8
|
-
this.driveCrypto = driveCrypto;
|
|
9
|
-
this.password = password;
|
|
10
|
-
this.driveCrypto = driveCrypto;
|
|
11
|
-
this.password = password;
|
|
12
|
-
}
|
|
13
|
-
async decryptPublicLinkShareKey(encryptedShare) {
|
|
14
|
-
const { key: shareKey } = await this.driveCrypto.decryptKeyWithSrpPassword(this.password, encryptedShare.base64UrlPasswordSalt, encryptedShare.armoredKey, encryptedShare.armoredPassphrase);
|
|
15
|
-
return shareKey;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.SharingPublicCryptoService = SharingPublicCryptoService;
|
|
19
|
-
//# sourceMappingURL=cryptoService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoService.js","sourceRoot":"","sources":["../../../src/internal/sharingPublic/cryptoService.ts"],"names":[],"mappings":";;;AAGA,MAAa,0BAA0B;IAEvB;IACA;IAFZ,YACY,WAAwB,EACxB,QAAgB;QADhB,gBAAW,GAAX,WAAW,CAAa;QACxB,aAAQ,GAAR,QAAQ,CAAQ;QAExB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,cAAoC;QAChE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,yBAAyB,CACtE,IAAI,CAAC,QAAQ,EACb,cAAc,CAAC,qBAAqB,EACpC,cAAc,CAAC,UAAU,EACzB,cAAc,CAAC,iBAAiB,CACnC,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAlBD,gEAkBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/internal/sharingPublic/interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { PrivateKey } from '../../crypto';
|
|
2
|
-
import { ProtonDriveCryptoCache, Logger } from '../../interface';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Provides caching for public link crypto material.
|
|
6
|
-
*
|
|
7
|
-
* The cache is responsible for serialising and deserialising public link
|
|
8
|
-
* crypto material.
|
|
9
|
-
*/
|
|
10
|
-
export class SharingPublicCryptoCache {
|
|
11
|
-
constructor(
|
|
12
|
-
private logger: Logger,
|
|
13
|
-
private driveCache: ProtonDriveCryptoCache,
|
|
14
|
-
) {
|
|
15
|
-
this.logger = logger;
|
|
16
|
-
this.driveCache = driveCache;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async setShareKey(shareKey: PrivateKey): Promise<void> {
|
|
20
|
-
await this.driveCache.setEntity(getShareKeyCacheKey(), {
|
|
21
|
-
publicShareKey: {
|
|
22
|
-
key: shareKey,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async getShareKey(): Promise<PrivateKey> {
|
|
28
|
-
const shareKeyData = await this.driveCache.getEntity(getShareKeyCacheKey());
|
|
29
|
-
if (!shareKeyData.publicShareKey) {
|
|
30
|
-
try {
|
|
31
|
-
await this.driveCache.removeEntities([getShareKeyCacheKey()]);
|
|
32
|
-
} catch (removingError: unknown) {
|
|
33
|
-
this.logger.warn(
|
|
34
|
-
`Failed to remove corrupted public share key from the cache: ${removingError instanceof Error ? removingError.message : removingError}`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
throw new Error('Failed to deserialize public share key');
|
|
38
|
-
}
|
|
39
|
-
return shareKeyData.publicShareKey.key;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getShareKeyCacheKey() {
|
|
44
|
-
return 'publicShareKey';
|
|
45
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DriveCrypto, PrivateKey } from '../../crypto';
|
|
2
|
-
import { EncryptedShareCrypto } from './interface';
|
|
3
|
-
|
|
4
|
-
export class SharingPublicCryptoService {
|
|
5
|
-
constructor(
|
|
6
|
-
private driveCrypto: DriveCrypto,
|
|
7
|
-
private password: string,
|
|
8
|
-
) {
|
|
9
|
-
this.driveCrypto = driveCrypto;
|
|
10
|
-
this.password = password;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async decryptPublicLinkShareKey(encryptedShare: EncryptedShareCrypto): Promise<PrivateKey> {
|
|
14
|
-
const { key: shareKey } = await this.driveCrypto.decryptKeyWithSrpPassword(
|
|
15
|
-
this.password,
|
|
16
|
-
encryptedShare.base64UrlPasswordSalt,
|
|
17
|
-
encryptedShare.armoredKey,
|
|
18
|
-
encryptedShare.armoredPassphrase,
|
|
19
|
-
);
|
|
20
|
-
return shareKey;
|
|
21
|
-
}
|
|
22
|
-
}
|