@protontech/drive-sdk 0.0.10
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/README.md +17 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.js +6 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/interface.d.ts +105 -0
- package/dist/cache/interface.js +3 -0
- package/dist/cache/interface.js.map +1 -0
- package/dist/cache/memoryCache.d.ts +18 -0
- package/dist/cache/memoryCache.js +78 -0
- package/dist/cache/memoryCache.js.map +1 -0
- package/dist/cache/memoryCache.test.d.ts +1 -0
- package/dist/cache/memoryCache.test.js +121 -0
- package/dist/cache/memoryCache.test.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -0
- package/dist/crypto/driveCrypto.d.ts +209 -0
- package/dist/crypto/driveCrypto.js +364 -0
- package/dist/crypto/driveCrypto.js.map +1 -0
- package/dist/crypto/driveCrypto.test.d.ts +1 -0
- package/dist/crypto/driveCrypto.test.js +42 -0
- package/dist/crypto/driveCrypto.test.js.map +1 -0
- package/dist/crypto/hmac.d.ts +22 -0
- package/dist/crypto/hmac.js +44 -0
- package/dist/crypto/hmac.js.map +1 -0
- package/dist/crypto/index.d.ts +6 -0
- package/dist/crypto/index.js +13 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/interface.d.ts +125 -0
- package/dist/crypto/interface.js +10 -0
- package/dist/crypto/interface.js.map +1 -0
- package/dist/crypto/openPGPCrypto.d.ts +145 -0
- package/dist/crypto/openPGPCrypto.js +250 -0
- package/dist/crypto/openPGPCrypto.js.map +1 -0
- package/dist/crypto/utils.d.ts +2 -0
- package/dist/crypto/utils.js +35 -0
- package/dist/crypto/utils.js.map +1 -0
- package/dist/errors.d.ts +138 -0
- package/dist/errors.js +163 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/account.d.ts +36 -0
- package/dist/interface/account.js +3 -0
- package/dist/interface/account.js.map +1 -0
- package/dist/interface/author.d.ts +26 -0
- package/dist/interface/author.js +3 -0
- package/dist/interface/author.js.map +1 -0
- package/dist/interface/devices.d.ts +18 -0
- package/dist/interface/devices.js +10 -0
- package/dist/interface/devices.js.map +1 -0
- package/dist/interface/download.d.ts +29 -0
- package/dist/interface/download.js +3 -0
- package/dist/interface/download.js.map +1 -0
- package/dist/interface/events.d.ts +26 -0
- package/dist/interface/events.js +11 -0
- package/dist/interface/events.js.map +1 -0
- package/dist/interface/httpClient.d.ts +38 -0
- package/dist/interface/httpClient.js +3 -0
- package/dist/interface/httpClient.js.map +1 -0
- package/dist/interface/index.d.ts +43 -0
- package/dist/interface/index.js +22 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/nodes.d.ts +161 -0
- package/dist/interface/nodes.js +21 -0
- package/dist/interface/nodes.js.map +1 -0
- package/dist/interface/result.d.ts +9 -0
- package/dist/interface/result.js +11 -0
- package/dist/interface/result.js.map +1 -0
- package/dist/interface/sharing.d.ts +73 -0
- package/dist/interface/sharing.js +9 -0
- package/dist/interface/sharing.js.map +1 -0
- package/dist/interface/telemetry.d.ts +61 -0
- package/dist/interface/telemetry.js +18 -0
- package/dist/interface/telemetry.js.map +1 -0
- package/dist/interface/thumbnail.d.ts +17 -0
- package/dist/interface/thumbnail.js +9 -0
- package/dist/interface/thumbnail.js.map +1 -0
- package/dist/interface/upload.d.ts +16 -0
- package/dist/interface/upload.js +3 -0
- package/dist/interface/upload.js.map +1 -0
- package/dist/internal/apiService/apiService.d.ts +51 -0
- package/dist/internal/apiService/apiService.js +305 -0
- package/dist/internal/apiService/apiService.js.map +1 -0
- package/dist/internal/apiService/apiService.test.d.ts +1 -0
- package/dist/internal/apiService/apiService.test.js +237 -0
- package/dist/internal/apiService/apiService.test.js.map +1 -0
- package/dist/internal/apiService/coreTypes.d.ts +24438 -0
- package/dist/internal/apiService/coreTypes.js +7 -0
- package/dist/internal/apiService/coreTypes.js.map +1 -0
- package/dist/internal/apiService/driveTypes.d.ts +11840 -0
- package/dist/internal/apiService/driveTypes.js +7 -0
- package/dist/internal/apiService/driveTypes.js.map +1 -0
- package/dist/internal/apiService/errorCodes.d.ts +30 -0
- package/dist/internal/apiService/errorCodes.js +11 -0
- package/dist/internal/apiService/errorCodes.js.map +1 -0
- package/dist/internal/apiService/errors.d.ts +19 -0
- package/dist/internal/apiService/errors.js +76 -0
- package/dist/internal/apiService/errors.js.map +1 -0
- package/dist/internal/apiService/errors.test.d.ts +1 -0
- package/dist/internal/apiService/errors.test.js +69 -0
- package/dist/internal/apiService/errors.test.js.map +1 -0
- package/dist/internal/apiService/index.d.ts +7 -0
- package/dist/internal/apiService/index.js +30 -0
- package/dist/internal/apiService/index.js.map +1 -0
- package/dist/internal/apiService/observerStream.d.ts +3 -0
- package/dist/internal/apiService/observerStream.js +15 -0
- package/dist/internal/apiService/observerStream.js.map +1 -0
- package/dist/internal/apiService/transformers.d.ts +4 -0
- package/dist/internal/apiService/transformers.js +48 -0
- package/dist/internal/apiService/transformers.js.map +1 -0
- package/dist/internal/batchLoading.d.ts +34 -0
- package/dist/internal/batchLoading.js +68 -0
- package/dist/internal/batchLoading.js.map +1 -0
- package/dist/internal/batchLoading.test.d.ts +1 -0
- package/dist/internal/batchLoading.test.js +50 -0
- package/dist/internal/batchLoading.test.js.map +1 -0
- package/dist/internal/devices/apiService.d.ts +38 -0
- package/dist/internal/devices/apiService.js +105 -0
- package/dist/internal/devices/apiService.js.map +1 -0
- package/dist/internal/devices/cryptoService.d.ts +30 -0
- package/dist/internal/devices/cryptoService.js +47 -0
- package/dist/internal/devices/cryptoService.js.map +1 -0
- package/dist/internal/devices/index.d.ts +15 -0
- package/dist/internal/devices/index.js +22 -0
- package/dist/internal/devices/index.js.map +1 -0
- package/dist/internal/devices/interface.d.ts +31 -0
- package/dist/internal/devices/interface.js +3 -0
- package/dist/internal/devices/interface.js.map +1 -0
- package/dist/internal/devices/manager.d.ts +18 -0
- package/dist/internal/devices/manager.js +103 -0
- package/dist/internal/devices/manager.js.map +1 -0
- package/dist/internal/devices/manager.test.d.ts +1 -0
- package/dist/internal/devices/manager.test.js +100 -0
- package/dist/internal/devices/manager.test.js.map +1 -0
- package/dist/internal/download/apiService.d.ts +27 -0
- package/dist/internal/download/apiService.js +110 -0
- package/dist/internal/download/apiService.js.map +1 -0
- package/dist/internal/download/controller.d.ts +8 -0
- package/dist/internal/download/controller.js +22 -0
- package/dist/internal/download/controller.js.map +1 -0
- package/dist/internal/download/cryptoService.d.ts +17 -0
- package/dist/internal/download/cryptoService.js +82 -0
- package/dist/internal/download/cryptoService.js.map +1 -0
- package/dist/internal/download/fileDownloader.d.ts +33 -0
- package/dist/internal/download/fileDownloader.js +226 -0
- package/dist/internal/download/fileDownloader.js.map +1 -0
- package/dist/internal/download/fileDownloader.test.d.ts +1 -0
- package/dist/internal/download/fileDownloader.test.js +324 -0
- package/dist/internal/download/fileDownloader.test.js.map +1 -0
- package/dist/internal/download/index.d.ts +10 -0
- package/dist/internal/download/index.js +82 -0
- package/dist/internal/download/index.js.map +1 -0
- package/dist/internal/download/interface.d.ts +35 -0
- package/dist/internal/download/interface.js +3 -0
- package/dist/internal/download/interface.js.map +1 -0
- package/dist/internal/download/queue.d.ts +5 -0
- package/dist/internal/download/queue.js +31 -0
- package/dist/internal/download/queue.js.map +1 -0
- package/dist/internal/download/telemetry.d.ts +14 -0
- package/dist/internal/download/telemetry.js +106 -0
- package/dist/internal/download/telemetry.js.map +1 -0
- package/dist/internal/download/telemetry.test.d.ts +1 -0
- package/dist/internal/download/telemetry.test.js +111 -0
- package/dist/internal/download/telemetry.test.js.map +1 -0
- package/dist/internal/download/thumbnailDownloader.d.ts +19 -0
- package/dist/internal/download/thumbnailDownloader.js +198 -0
- package/dist/internal/download/thumbnailDownloader.js.map +1 -0
- package/dist/internal/download/thumbnailDownloader.test.d.ts +1 -0
- package/dist/internal/download/thumbnailDownloader.test.js +179 -0
- package/dist/internal/download/thumbnailDownloader.test.js.map +1 -0
- package/dist/internal/errors.d.ts +6 -0
- package/dist/internal/errors.js +28 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/errors.test.d.ts +1 -0
- package/dist/internal/errors.test.js +22 -0
- package/dist/internal/errors.test.js.map +1 -0
- package/dist/internal/events/apiService.d.ts +18 -0
- package/dist/internal/events/apiService.js +81 -0
- package/dist/internal/events/apiService.js.map +1 -0
- package/dist/internal/events/cache.d.ts +28 -0
- package/dist/internal/events/cache.js +67 -0
- package/dist/internal/events/cache.js.map +1 -0
- package/dist/internal/events/cache.test.d.ts +1 -0
- package/dist/internal/events/cache.test.js +43 -0
- package/dist/internal/events/cache.test.js.map +1 -0
- package/dist/internal/events/coreEventManager.d.ts +25 -0
- package/dist/internal/events/coreEventManager.js +63 -0
- package/dist/internal/events/coreEventManager.js.map +1 -0
- package/dist/internal/events/eventManager.d.ts +62 -0
- package/dist/internal/events/eventManager.js +159 -0
- package/dist/internal/events/eventManager.js.map +1 -0
- package/dist/internal/events/eventManager.test.d.ts +1 -0
- package/dist/internal/events/eventManager.test.js +120 -0
- package/dist/internal/events/eventManager.test.js.map +1 -0
- package/dist/internal/events/index.d.ts +50 -0
- package/dist/internal/events/index.js +117 -0
- package/dist/internal/events/index.js.map +1 -0
- package/dist/internal/events/interface.d.ts +47 -0
- package/dist/internal/events/interface.js +12 -0
- package/dist/internal/events/interface.js.map +1 -0
- package/dist/internal/events/volumeEventManager.d.ts +27 -0
- package/dist/internal/events/volumeEventManager.js +69 -0
- package/dist/internal/events/volumeEventManager.js.map +1 -0
- package/dist/internal/nodes/apiService.d.ts +54 -0
- package/dist/internal/nodes/apiService.js +308 -0
- package/dist/internal/nodes/apiService.js.map +1 -0
- package/dist/internal/nodes/apiService.test.d.ts +1 -0
- package/dist/internal/nodes/apiService.test.js +344 -0
- package/dist/internal/nodes/apiService.test.js.map +1 -0
- package/dist/internal/nodes/cache.d.ts +57 -0
- package/dist/internal/nodes/cache.js +226 -0
- package/dist/internal/nodes/cache.js.map +1 -0
- package/dist/internal/nodes/cache.test.d.ts +1 -0
- package/dist/internal/nodes/cache.test.js +160 -0
- package/dist/internal/nodes/cache.test.js.map +1 -0
- package/dist/internal/nodes/cryptoCache.d.ts +16 -0
- package/dist/internal/nodes/cryptoCache.js +50 -0
- package/dist/internal/nodes/cryptoCache.js.map +1 -0
- package/dist/internal/nodes/cryptoCache.test.d.ts +1 -0
- package/dist/internal/nodes/cryptoCache.test.js +79 -0
- package/dist/internal/nodes/cryptoCache.test.js.map +1 -0
- package/dist/internal/nodes/cryptoService.d.ts +75 -0
- package/dist/internal/nodes/cryptoService.js +409 -0
- package/dist/internal/nodes/cryptoService.js.map +1 -0
- package/dist/internal/nodes/cryptoService.test.d.ts +1 -0
- package/dist/internal/nodes/cryptoService.test.js +698 -0
- package/dist/internal/nodes/cryptoService.test.js.map +1 -0
- package/dist/internal/nodes/events.d.ts +91 -0
- package/dist/internal/nodes/events.js +243 -0
- package/dist/internal/nodes/events.js.map +1 -0
- package/dist/internal/nodes/events.test.d.ts +1 -0
- package/dist/internal/nodes/events.test.js +318 -0
- package/dist/internal/nodes/events.test.js.map +1 -0
- package/dist/internal/nodes/extendedAttributes.d.ts +23 -0
- package/dist/internal/nodes/extendedAttributes.js +117 -0
- package/dist/internal/nodes/extendedAttributes.js.map +1 -0
- package/dist/internal/nodes/extendedAttributes.test.d.ts +1 -0
- package/dist/internal/nodes/extendedAttributes.test.js +176 -0
- package/dist/internal/nodes/extendedAttributes.test.js.map +1 -0
- package/dist/internal/nodes/index.d.ts +26 -0
- package/dist/internal/nodes/index.js +40 -0
- package/dist/internal/nodes/index.js.map +1 -0
- package/dist/internal/nodes/index.test.d.ts +1 -0
- package/dist/internal/nodes/index.test.js +112 -0
- package/dist/internal/nodes/index.test.js.map +1 -0
- package/dist/internal/nodes/interface.d.ts +135 -0
- package/dist/internal/nodes/interface.js +3 -0
- package/dist/internal/nodes/interface.js.map +1 -0
- package/dist/internal/nodes/mediaTypes.d.ts +2 -0
- package/dist/internal/nodes/mediaTypes.js +13 -0
- package/dist/internal/nodes/mediaTypes.js.map +1 -0
- package/dist/internal/nodes/nodesAccess.d.ts +49 -0
- package/dist/internal/nodes/nodesAccess.js +332 -0
- package/dist/internal/nodes/nodesAccess.js.map +1 -0
- package/dist/internal/nodes/nodesAccess.test.d.ts +1 -0
- package/dist/internal/nodes/nodesAccess.test.js +487 -0
- package/dist/internal/nodes/nodesAccess.test.js.map +1 -0
- package/dist/internal/nodes/nodesManagement.d.ts +33 -0
- package/dist/internal/nodes/nodesManagement.js +222 -0
- package/dist/internal/nodes/nodesManagement.js.map +1 -0
- package/dist/internal/nodes/nodesManagement.test.d.ts +1 -0
- package/dist/internal/nodes/nodesManagement.test.js +178 -0
- package/dist/internal/nodes/nodesManagement.test.js.map +1 -0
- package/dist/internal/nodes/nodesRevisions.d.ts +18 -0
- package/dist/internal/nodes/nodesRevisions.js +55 -0
- package/dist/internal/nodes/nodesRevisions.js.map +1 -0
- package/dist/internal/nodes/validations.d.ts +4 -0
- package/dist/internal/nodes/validations.js +21 -0
- package/dist/internal/nodes/validations.js.map +1 -0
- package/dist/internal/photos/albums.d.ts +13 -0
- package/dist/internal/photos/albums.js +30 -0
- package/dist/internal/photos/albums.js.map +1 -0
- package/dist/internal/photos/apiService.d.ts +8 -0
- package/dist/internal/photos/apiService.js +18 -0
- package/dist/internal/photos/apiService.js.map +1 -0
- package/dist/internal/photos/cache.d.ts +6 -0
- package/dist/internal/photos/cache.js +15 -0
- package/dist/internal/photos/cache.js.map +1 -0
- package/dist/internal/photos/index.d.ts +9 -0
- package/dist/internal/photos/index.js +18 -0
- package/dist/internal/photos/index.js.map +1 -0
- package/dist/internal/photos/interface.d.ts +6 -0
- package/dist/internal/photos/interface.js +3 -0
- package/dist/internal/photos/interface.js.map +1 -0
- package/dist/internal/photos/photosTimeline.d.ts +10 -0
- package/dist/internal/photos/photosTimeline.js +20 -0
- package/dist/internal/photos/photosTimeline.js.map +1 -0
- package/dist/internal/sdkEvents.d.ts +12 -0
- package/dist/internal/sdkEvents.js +44 -0
- package/dist/internal/sdkEvents.js.map +1 -0
- package/dist/internal/sdkEvents.test.d.ts +1 -0
- package/dist/internal/sdkEvents.test.js +45 -0
- package/dist/internal/sdkEvents.test.js.map +1 -0
- package/dist/internal/shares/apiService.d.ts +51 -0
- package/dist/internal/shares/apiService.js +128 -0
- package/dist/internal/shares/apiService.js.map +1 -0
- package/dist/internal/shares/cache.d.ts +15 -0
- package/dist/internal/shares/cache.js +63 -0
- package/dist/internal/shares/cache.js.map +1 -0
- package/dist/internal/shares/cache.test.d.ts +1 -0
- package/dist/internal/shares/cache.test.js +54 -0
- package/dist/internal/shares/cache.test.js.map +1 -0
- package/dist/internal/shares/cryptoCache.d.ts +20 -0
- package/dist/internal/shares/cryptoCache.js +35 -0
- package/dist/internal/shares/cryptoCache.js.map +1 -0
- package/dist/internal/shares/cryptoCache.test.d.ts +1 -0
- package/dist/internal/shares/cryptoCache.test.js +58 -0
- package/dist/internal/shares/cryptoCache.test.js.map +1 -0
- package/dist/internal/shares/cryptoService.d.ts +42 -0
- package/dist/internal/shares/cryptoService.js +126 -0
- package/dist/internal/shares/cryptoService.js.map +1 -0
- package/dist/internal/shares/cryptoService.test.d.ts +1 -0
- package/dist/internal/shares/cryptoService.test.js +120 -0
- package/dist/internal/shares/cryptoService.test.js.map +1 -0
- package/dist/internal/shares/index.d.ts +15 -0
- package/dist/internal/shares/index.js +26 -0
- package/dist/internal/shares/index.js.map +1 -0
- package/dist/internal/shares/interface.d.ts +94 -0
- package/dist/internal/shares/interface.js +11 -0
- package/dist/internal/shares/interface.js.map +1 -0
- package/dist/internal/shares/manager.d.ts +68 -0
- package/dist/internal/shares/manager.js +186 -0
- package/dist/internal/shares/manager.js.map +1 -0
- package/dist/internal/shares/manager.test.d.ts +1 -0
- package/dist/internal/shares/manager.test.js +176 -0
- package/dist/internal/shares/manager.test.js.map +1 -0
- package/dist/internal/sharing/apiService.d.ts +80 -0
- package/dist/internal/sharing/apiService.js +325 -0
- package/dist/internal/sharing/apiService.js.map +1 -0
- package/dist/internal/sharing/cache.d.ts +37 -0
- package/dist/internal/sharing/cache.js +105 -0
- package/dist/internal/sharing/cache.js.map +1 -0
- package/dist/internal/sharing/cache.test.d.ts +1 -0
- package/dist/internal/sharing/cache.test.js +82 -0
- package/dist/internal/sharing/cache.test.js.map +1 -0
- package/dist/internal/sharing/cryptoService.d.ts +112 -0
- package/dist/internal/sharing/cryptoService.js +269 -0
- package/dist/internal/sharing/cryptoService.js.map +1 -0
- package/dist/internal/sharing/events.d.ts +57 -0
- package/dist/internal/sharing/events.js +153 -0
- package/dist/internal/sharing/events.js.map +1 -0
- package/dist/internal/sharing/events.test.d.ts +1 -0
- package/dist/internal/sharing/events.test.js +246 -0
- package/dist/internal/sharing/events.test.js.map +1 -0
- package/dist/internal/sharing/index.d.ts +20 -0
- package/dist/internal/sharing/index.js +30 -0
- package/dist/internal/sharing/index.js.map +1 -0
- package/dist/internal/sharing/interface.d.ts +169 -0
- package/dist/internal/sharing/interface.js +9 -0
- package/dist/internal/sharing/interface.js.map +1 -0
- package/dist/internal/sharing/sharingAccess.d.ts +32 -0
- package/dist/internal/sharing/sharingAccess.js +119 -0
- package/dist/internal/sharing/sharingAccess.js.map +1 -0
- package/dist/internal/sharing/sharingAccess.test.d.ts +1 -0
- package/dist/internal/sharing/sharingAccess.test.js +84 -0
- package/dist/internal/sharing/sharingAccess.test.js.map +1 -0
- package/dist/internal/sharing/sharingManagement.d.ts +43 -0
- package/dist/internal/sharing/sharingManagement.js +439 -0
- package/dist/internal/sharing/sharingManagement.js.map +1 -0
- package/dist/internal/sharing/sharingManagement.test.d.ts +1 -0
- package/dist/internal/sharing/sharingManagement.test.js +788 -0
- package/dist/internal/sharing/sharingManagement.test.js.map +1 -0
- package/dist/internal/uids.d.ts +38 -0
- package/dist/internal/uids.js +85 -0
- package/dist/internal/uids.js.map +1 -0
- package/dist/internal/upload/apiService.d.ts +65 -0
- package/dist/internal/upload/apiService.js +137 -0
- package/dist/internal/upload/apiService.js.map +1 -0
- package/dist/internal/upload/blockVerifier.d.ts +16 -0
- package/dist/internal/upload/blockVerifier.js +33 -0
- package/dist/internal/upload/blockVerifier.js.map +1 -0
- package/dist/internal/upload/chunkStreamReader.d.ts +13 -0
- package/dist/internal/upload/chunkStreamReader.js +46 -0
- package/dist/internal/upload/chunkStreamReader.js.map +1 -0
- package/dist/internal/upload/chunkStreamReader.test.d.ts +1 -0
- package/dist/internal/upload/chunkStreamReader.test.js +75 -0
- package/dist/internal/upload/chunkStreamReader.test.js.map +1 -0
- package/dist/internal/upload/controller.d.ts +8 -0
- package/dist/internal/upload/controller.js +25 -0
- package/dist/internal/upload/controller.js.map +1 -0
- package/dist/internal/upload/cryptoService.d.ts +29 -0
- package/dist/internal/upload/cryptoService.js +104 -0
- package/dist/internal/upload/cryptoService.js.map +1 -0
- package/dist/internal/upload/digests.d.ts +8 -0
- package/dist/internal/upload/digests.js +22 -0
- package/dist/internal/upload/digests.js.map +1 -0
- package/dist/internal/upload/fileUploader.d.ts +65 -0
- package/dist/internal/upload/fileUploader.js +463 -0
- package/dist/internal/upload/fileUploader.js.map +1 -0
- package/dist/internal/upload/fileUploader.test.d.ts +1 -0
- package/dist/internal/upload/fileUploader.test.js +393 -0
- package/dist/internal/upload/fileUploader.test.js.map +1 -0
- package/dist/internal/upload/index.d.ts +16 -0
- package/dist/internal/upload/index.js +77 -0
- package/dist/internal/upload/index.js.map +1 -0
- package/dist/internal/upload/interface.d.ts +117 -0
- package/dist/internal/upload/interface.js +3 -0
- package/dist/internal/upload/interface.js.map +1 -0
- package/dist/internal/upload/manager.d.ts +31 -0
- package/dist/internal/upload/manager.js +250 -0
- package/dist/internal/upload/manager.js.map +1 -0
- package/dist/internal/upload/manager.test.d.ts +1 -0
- package/dist/internal/upload/manager.test.js +349 -0
- package/dist/internal/upload/manager.test.js.map +1 -0
- package/dist/internal/upload/queue.d.ts +5 -0
- package/dist/internal/upload/queue.js +32 -0
- package/dist/internal/upload/queue.js.map +1 -0
- package/dist/internal/upload/telemetry.d.ts +15 -0
- package/dist/internal/upload/telemetry.js +111 -0
- package/dist/internal/upload/telemetry.js.map +1 -0
- package/dist/internal/upload/telemetry.test.d.ts +1 -0
- package/dist/internal/upload/telemetry.test.js +107 -0
- package/dist/internal/upload/telemetry.test.js.map +1 -0
- package/dist/internal/utils.d.ts +1 -0
- package/dist/internal/utils.js +13 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/internal/wait.d.ts +3 -0
- package/dist/internal/wait.js +28 -0
- package/dist/internal/wait.js.map +1 -0
- package/dist/internal/wait.test.d.ts +1 -0
- package/dist/internal/wait.test.js +21 -0
- package/dist/internal/wait.test.js.map +1 -0
- package/dist/protonDriveClient.d.ts +593 -0
- package/dist/protonDriveClient.js +768 -0
- package/dist/protonDriveClient.js.map +1 -0
- package/dist/protonDrivePhotosClient.d.ts +16 -0
- package/dist/protonDrivePhotosClient.js +46 -0
- package/dist/protonDrivePhotosClient.js.map +1 -0
- package/dist/telemetry.d.ts +187 -0
- package/dist/telemetry.js +297 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tests/logger.d.ts +2 -0
- package/dist/tests/logger.js +12 -0
- package/dist/tests/logger.js.map +1 -0
- package/dist/tests/telemetry.d.ts +2 -0
- package/dist/tests/telemetry.js +11 -0
- package/dist/tests/telemetry.js.map +1 -0
- package/dist/transformers.d.ts +17 -0
- package/dist/transformers.js +77 -0
- package/dist/transformers.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +49 -0
- package/src/cache/index.ts +2 -0
- package/src/cache/interface.ts +104 -0
- package/src/cache/memoryCache.test.ts +150 -0
- package/src/cache/memoryCache.ts +85 -0
- package/src/config.ts +9 -0
- package/src/crypto/driveCrypto.test.ts +45 -0
- package/src/crypto/driveCrypto.ts +696 -0
- package/src/crypto/hmac.ts +46 -0
- package/src/crypto/index.ts +6 -0
- package/src/crypto/interface.ts +230 -0
- package/src/crypto/openPGPCrypto.ts +398 -0
- package/src/crypto/utils.ts +40 -0
- package/src/errors.ts +168 -0
- package/src/index.ts +30 -0
- package/src/interface/account.ts +38 -0
- package/src/interface/author.ts +29 -0
- package/src/interface/devices.ts +21 -0
- package/src/interface/download.ts +32 -0
- package/src/interface/events.ts +30 -0
- package/src/interface/httpClient.ts +42 -0
- package/src/interface/index.ts +46 -0
- package/src/interface/nodes.ts +168 -0
- package/src/interface/result.ts +11 -0
- package/src/interface/sharing.ts +87 -0
- package/src/interface/telemetry.ts +107 -0
- package/src/interface/thumbnail.ts +14 -0
- package/src/interface/upload.ts +19 -0
- package/src/internal/apiService/apiService.test.ts +285 -0
- package/src/internal/apiService/apiService.ts +353 -0
- package/src/internal/apiService/coreTypes.ts +24439 -0
- package/src/internal/apiService/driveTypes.ts +11841 -0
- package/src/internal/apiService/errorCodes.ts +38 -0
- package/src/internal/apiService/errors.test.ts +63 -0
- package/src/internal/apiService/errors.ts +91 -0
- package/src/internal/apiService/index.ts +7 -0
- package/src/internal/apiService/observerStream.ts +10 -0
- package/src/internal/apiService/transformers.ts +45 -0
- package/src/internal/batchLoading.test.ts +58 -0
- package/src/internal/batchLoading.ts +74 -0
- package/src/internal/devices/apiService.ts +142 -0
- package/src/internal/devices/cryptoService.ts +65 -0
- package/src/internal/devices/index.ts +31 -0
- package/src/internal/devices/interface.ts +28 -0
- package/src/internal/devices/manager.test.ts +129 -0
- package/src/internal/devices/manager.ts +113 -0
- package/src/internal/download/apiService.ts +145 -0
- package/src/internal/download/controller.ts +22 -0
- package/src/internal/download/cryptoService.ts +96 -0
- package/src/internal/download/fileDownloader.test.ts +381 -0
- package/src/internal/download/fileDownloader.ts +266 -0
- package/src/internal/download/index.ts +122 -0
- package/src/internal/download/interface.ts +38 -0
- package/src/internal/download/queue.ts +30 -0
- package/src/internal/download/telemetry.test.ts +134 -0
- package/src/internal/download/telemetry.ts +115 -0
- package/src/internal/download/thumbnailDownloader.test.ts +226 -0
- package/src/internal/download/thumbnailDownloader.ts +250 -0
- package/src/internal/errors.test.ts +21 -0
- package/src/internal/errors.ts +28 -0
- package/src/internal/events/apiService.ts +87 -0
- package/src/internal/events/cache.test.ts +47 -0
- package/src/internal/events/cache.ts +80 -0
- package/src/internal/events/coreEventManager.ts +69 -0
- package/src/internal/events/eventManager.test.ts +139 -0
- package/src/internal/events/eventManager.ts +168 -0
- package/src/internal/events/index.ts +131 -0
- package/src/internal/events/interface.ts +51 -0
- package/src/internal/events/volumeEventManager.ts +74 -0
- package/src/internal/nodes/apiService.test.ts +394 -0
- package/src/internal/nodes/apiService.ts +455 -0
- package/src/internal/nodes/cache.test.ts +197 -0
- package/src/internal/nodes/cache.ts +240 -0
- package/src/internal/nodes/cryptoCache.test.ts +92 -0
- package/src/internal/nodes/cryptoCache.ts +47 -0
- package/src/internal/nodes/cryptoService.test.ts +814 -0
- package/src/internal/nodes/cryptoService.ts +550 -0
- package/src/internal/nodes/events.test.ts +383 -0
- package/src/internal/nodes/events.ts +271 -0
- package/src/internal/nodes/extendedAttributes.test.ts +177 -0
- package/src/internal/nodes/extendedAttributes.ts +180 -0
- package/src/internal/nodes/index.test.ts +135 -0
- package/src/internal/nodes/index.ts +52 -0
- package/src/internal/nodes/interface.ts +152 -0
- package/src/internal/nodes/mediaTypes.ts +10 -0
- package/src/internal/nodes/nodesAccess.test.ts +555 -0
- package/src/internal/nodes/nodesAccess.ts +360 -0
- package/src/internal/nodes/nodesManagement.test.ts +221 -0
- package/src/internal/nodes/nodesManagement.ts +272 -0
- package/src/internal/nodes/nodesRevisions.ts +58 -0
- package/src/internal/nodes/validations.ts +26 -0
- package/src/internal/photos/albums.ts +29 -0
- package/src/internal/photos/apiService.ts +16 -0
- package/src/internal/photos/cache.ts +11 -0
- package/src/internal/photos/index.ts +23 -0
- package/src/internal/photos/interface.ts +7 -0
- package/src/internal/photos/photosTimeline.ts +18 -0
- package/src/internal/sdkEvents.test.ts +55 -0
- package/src/internal/sdkEvents.ts +52 -0
- package/src/internal/shares/apiService.ts +176 -0
- package/src/internal/shares/cache.test.ts +58 -0
- package/src/internal/shares/cache.ts +64 -0
- package/src/internal/shares/cryptoCache.test.ts +70 -0
- package/src/internal/shares/cryptoCache.ts +35 -0
- package/src/internal/shares/cryptoService.test.ts +137 -0
- package/src/internal/shares/cryptoService.ts +143 -0
- package/src/internal/shares/index.ts +35 -0
- package/src/internal/shares/interface.ts +104 -0
- package/src/internal/shares/manager.test.ts +210 -0
- package/src/internal/shares/manager.ts +213 -0
- package/src/internal/sharing/apiService.ts +483 -0
- package/src/internal/sharing/cache.test.ts +99 -0
- package/src/internal/sharing/cache.ts +109 -0
- package/src/internal/sharing/cryptoService.ts +378 -0
- package/src/internal/sharing/events.test.ts +268 -0
- package/src/internal/sharing/events.ts +166 -0
- package/src/internal/sharing/index.ts +43 -0
- package/src/internal/sharing/interface.ts +177 -0
- package/src/internal/sharing/sharingAccess.test.ts +102 -0
- package/src/internal/sharing/sharingAccess.ts +133 -0
- package/src/internal/sharing/sharingManagement.test.ts +895 -0
- package/src/internal/sharing/sharingManagement.ts +521 -0
- package/src/internal/uids.ts +83 -0
- package/src/internal/upload/apiService.ts +243 -0
- package/src/internal/upload/blockVerifier.ts +40 -0
- package/src/internal/upload/chunkStreamReader.test.ts +89 -0
- package/src/internal/upload/chunkStreamReader.ts +49 -0
- package/src/internal/upload/controller.ts +25 -0
- package/src/internal/upload/cryptoService.ts +162 -0
- package/src/internal/upload/digests.ts +18 -0
- package/src/internal/upload/fileUploader.test.ts +513 -0
- package/src/internal/upload/fileUploader.ts +576 -0
- package/src/internal/upload/index.ts +126 -0
- package/src/internal/upload/interface.ts +128 -0
- package/src/internal/upload/manager.test.ts +390 -0
- package/src/internal/upload/manager.ts +320 -0
- package/src/internal/upload/queue.ts +31 -0
- package/src/internal/upload/telemetry.test.ts +129 -0
- package/src/internal/upload/telemetry.ts +121 -0
- package/src/internal/utils.ts +9 -0
- package/src/internal/wait.test.ts +21 -0
- package/src/internal/wait.ts +26 -0
- package/src/protonDriveClient.ts +861 -0
- package/src/protonDrivePhotosClient.ts +56 -0
- package/src/telemetry.ts +346 -0
- package/src/tests/logger.ts +10 -0
- package/src/tests/telemetry.ts +9 -0
- package/src/transformers.ts +98 -0
- package/src/version.ts +4 -0
|
@@ -0,0 +1,861 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Logger,
|
|
3
|
+
ProtonDriveClientContructorParameters,
|
|
4
|
+
NodeOrUid,
|
|
5
|
+
MaybeNode,
|
|
6
|
+
MaybeMissingNode,
|
|
7
|
+
NodeResult,
|
|
8
|
+
Revision,
|
|
9
|
+
ShareNodeSettings,
|
|
10
|
+
UnshareNodeSettings,
|
|
11
|
+
ProtonInvitationOrUid,
|
|
12
|
+
NonProtonInvitationOrUid,
|
|
13
|
+
ProtonInvitationWithNode,
|
|
14
|
+
ShareResult,
|
|
15
|
+
Device,
|
|
16
|
+
DeviceType,
|
|
17
|
+
DeviceOrUid,
|
|
18
|
+
UploadMetadata,
|
|
19
|
+
FileDownloader,
|
|
20
|
+
Fileuploader,
|
|
21
|
+
ThumbnailType,
|
|
22
|
+
ThumbnailResult,
|
|
23
|
+
SDKEvent,
|
|
24
|
+
DeviceEventCallback,
|
|
25
|
+
NodeEventCallback,
|
|
26
|
+
} from './interface';
|
|
27
|
+
import { DriveCrypto, SessionKey } from './crypto';
|
|
28
|
+
import { DriveAPIService } from './internal/apiService';
|
|
29
|
+
import { initSharesModule } from './internal/shares';
|
|
30
|
+
import { initNodesModule } from './internal/nodes';
|
|
31
|
+
import { initSharingModule } from './internal/sharing';
|
|
32
|
+
import { initDownloadModule } from './internal/download';
|
|
33
|
+
import { initUploadModule } from './internal/upload';
|
|
34
|
+
import { DriveEventsService } from './internal/events';
|
|
35
|
+
import { SDKEvents } from './internal/sdkEvents';
|
|
36
|
+
import { getConfig } from './config';
|
|
37
|
+
import { getUid, getUids, convertInternalNodePromise, convertInternalNodeIterator, convertInternalMissingNodeIterator, convertInternalNode } from './transformers';
|
|
38
|
+
import { Telemetry } from './telemetry';
|
|
39
|
+
import { initDevicesModule } from './internal/devices';
|
|
40
|
+
import { makeNodeUid, splitNodeUid } from './internal/uids';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* ProtonDriveClient is the main interface for the ProtonDrive SDK.
|
|
44
|
+
*
|
|
45
|
+
* The client provides high-level operations for managing nodes, sharing,
|
|
46
|
+
* and downloading/uploading files. It is the main entry point for using
|
|
47
|
+
* the ProtonDrive SDK.
|
|
48
|
+
*/
|
|
49
|
+
export class ProtonDriveClient {
|
|
50
|
+
private logger: Logger;
|
|
51
|
+
private sdkEvents: SDKEvents;
|
|
52
|
+
private events: DriveEventsService;
|
|
53
|
+
private shares: ReturnType<typeof initSharesModule>;
|
|
54
|
+
private nodes: ReturnType<typeof initNodesModule>;
|
|
55
|
+
private sharing: ReturnType<typeof initSharingModule>;
|
|
56
|
+
private download: ReturnType<typeof initDownloadModule>;
|
|
57
|
+
private upload: ReturnType<typeof initUploadModule>;
|
|
58
|
+
private devices: ReturnType<typeof initDevicesModule>;
|
|
59
|
+
|
|
60
|
+
public experimental: {
|
|
61
|
+
/**
|
|
62
|
+
* Experimental feature to return the URL of the node.
|
|
63
|
+
*
|
|
64
|
+
* Use it when you want to open the node in the ProtonDrive web app.
|
|
65
|
+
*
|
|
66
|
+
* It has hardcoded URLs to open in production client only.
|
|
67
|
+
*/
|
|
68
|
+
getNodeUrl: (nodeUid: NodeOrUid) => Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Experimental feature to get the docs key for a node.
|
|
71
|
+
*
|
|
72
|
+
* This is used by Docs app to encrypt and decrypt document updates.
|
|
73
|
+
*/
|
|
74
|
+
getDocsKey: (nodeUid: NodeOrUid) => Promise<SessionKey>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
constructor({
|
|
78
|
+
httpClient,
|
|
79
|
+
entitiesCache,
|
|
80
|
+
cryptoCache,
|
|
81
|
+
account,
|
|
82
|
+
openPGPCryptoModule,
|
|
83
|
+
srpModule,
|
|
84
|
+
config,
|
|
85
|
+
telemetry,
|
|
86
|
+
}: ProtonDriveClientContructorParameters) {
|
|
87
|
+
if (!telemetry) {
|
|
88
|
+
telemetry = new Telemetry();
|
|
89
|
+
}
|
|
90
|
+
this.logger = telemetry.getLogger('interface');
|
|
91
|
+
|
|
92
|
+
const fullConfig = getConfig(config);
|
|
93
|
+
this.sdkEvents = new SDKEvents(telemetry);
|
|
94
|
+
const cryptoModule = new DriveCrypto(openPGPCryptoModule, srpModule);
|
|
95
|
+
const apiService = new DriveAPIService(telemetry, this.sdkEvents, httpClient, fullConfig.baseUrl, fullConfig.language);
|
|
96
|
+
this.events = new DriveEventsService(telemetry, apiService, entitiesCache);
|
|
97
|
+
this.shares = initSharesModule(telemetry, apiService, entitiesCache, cryptoCache, account, cryptoModule);
|
|
98
|
+
this.nodes = initNodesModule(telemetry, apiService, entitiesCache, cryptoCache, account, cryptoModule, this.events, this.shares);
|
|
99
|
+
this.sharing = initSharingModule(telemetry, apiService, entitiesCache, account, cryptoModule, this.events, this.shares, this.nodes.access, this.nodes.events);
|
|
100
|
+
this.download = initDownloadModule(telemetry, apiService, cryptoModule, account, this.shares, this.nodes.access, this.nodes.revisions);
|
|
101
|
+
this.upload = initUploadModule(telemetry, apiService, cryptoModule, this.shares, this.nodes.access, this.nodes.events);
|
|
102
|
+
this.devices = initDevicesModule(telemetry, apiService, cryptoModule, this.shares, this.nodes.access, this.nodes.management);
|
|
103
|
+
this.experimental = {
|
|
104
|
+
getNodeUrl: async (nodeUid: NodeOrUid) => {
|
|
105
|
+
this.logger.debug(`Getting node URL for ${getUid(nodeUid)}`);
|
|
106
|
+
return this.nodes.access.getNodeUrl(getUid(nodeUid));
|
|
107
|
+
},
|
|
108
|
+
getDocsKey: async (nodeUid: NodeOrUid) => {
|
|
109
|
+
this.logger.debug(`Getting docs keys for ${getUid(nodeUid)}`);
|
|
110
|
+
const keys = await this.nodes.access.getNodeKeys(getUid(nodeUid));
|
|
111
|
+
if (!keys.contentKeyPacketSessionKey) {
|
|
112
|
+
throw new Error('Node does not have a content key packet session key');
|
|
113
|
+
}
|
|
114
|
+
return keys.contentKeyPacketSessionKey;
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Subscribes to the general SDK events.
|
|
121
|
+
*
|
|
122
|
+
* This is not connected to the remote data updates. For that, use
|
|
123
|
+
* and see `subscribeToRemoteDataUpdates`.
|
|
124
|
+
*
|
|
125
|
+
* @param eventName - SDK event name.
|
|
126
|
+
* @param callback - Callback to be called when the event is emitted.
|
|
127
|
+
* @returns Callback to unsubscribe from the event.
|
|
128
|
+
*/
|
|
129
|
+
onMessage(eventName: SDKEvent, callback: () => void): () => void {
|
|
130
|
+
this.logger.debug(`Subscribing to event ${eventName}`);
|
|
131
|
+
return this.sdkEvents.addListener(eventName, callback);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Subscribes to the remote data updates.
|
|
136
|
+
*
|
|
137
|
+
* By default, SDK doesn't subscribe to remote data updates. If you
|
|
138
|
+
* cache the data locally, you need to call this method so the SDK
|
|
139
|
+
* keeps the local cache in sync with the remote data.
|
|
140
|
+
*
|
|
141
|
+
* Only one instance of the SDK should subscribe to remote data updates.
|
|
142
|
+
*
|
|
143
|
+
* Once subscribed, the SDK will poll for events for core user events and
|
|
144
|
+
* for own data at minimum. Updates to nodes from other users are polled
|
|
145
|
+
* with lower frequency depending on the number of subscriptions, and only
|
|
146
|
+
* after accessing them for the first time via `iterateSharedNodesWithMe`.
|
|
147
|
+
*/
|
|
148
|
+
async subscribeToRemoteDataUpdates(): Promise<void> {
|
|
149
|
+
this.logger.debug('Subscribing to remote data updates');
|
|
150
|
+
await this.events.subscribeToRemoteDataUpdates();
|
|
151
|
+
|
|
152
|
+
const { volumeId } = await this.shares.getMyFilesIDs();
|
|
153
|
+
await this.events.listenToVolume(volumeId, true);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Subscribe to updates of the devices.
|
|
158
|
+
*
|
|
159
|
+
* Clients should subscribe to this before beginning to list devices
|
|
160
|
+
* to ensure that updates are reflected once a device is in the cache.
|
|
161
|
+
* Subscribing before listing is also required to ensure that devices
|
|
162
|
+
* that are created during the listing will be recognized.
|
|
163
|
+
*
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const unsubscribe = sdk.subscribeToDevices((event) => {
|
|
166
|
+
* if (event.type === 'update') {
|
|
167
|
+
* // Update the device in the UI
|
|
168
|
+
* } else if (event.type === 'remove') {
|
|
169
|
+
* // Remove the device from the UI
|
|
170
|
+
* }
|
|
171
|
+
* });
|
|
172
|
+
*
|
|
173
|
+
* const devices = await Array.fromAsync(sdk.iterateDevices());
|
|
174
|
+
* // Render the devices in the UI
|
|
175
|
+
*
|
|
176
|
+
* // Unsubscribe from the updates when the component is unmounted
|
|
177
|
+
* unsubscribe();
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @param callback - Callback to be called when the event is emitted.
|
|
181
|
+
* @returns Callback to unsubscribe from the event.
|
|
182
|
+
*/
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
184
|
+
subscribeToDevices(callback: DeviceEventCallback): () => void {
|
|
185
|
+
this.logger.debug('Subscribing to devices');
|
|
186
|
+
throw new Error('Method not implemented');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Subscribe to updates of the children of the given parent node.
|
|
191
|
+
*
|
|
192
|
+
* Clients should subscribe to this before beginning to list children
|
|
193
|
+
* to ensure that updates are reflected once a node is in the cache.
|
|
194
|
+
* Subscribing before listing is also required to ensure that nodes
|
|
195
|
+
* that are created during the listing will be recognized.
|
|
196
|
+
*
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const unsubscribe = sdk.subscribeToChildren(parentNodeUid, (event) => {
|
|
199
|
+
* if (event.type === 'update') {
|
|
200
|
+
* // Update the node in the UI
|
|
201
|
+
* } else if (event.type === 'remove') {
|
|
202
|
+
* // Remove the node from the UI
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* const nodes = await Array.fromAsync(sdk.iterateChildren(parentNodeUid));
|
|
207
|
+
* // Render the nodes in the UI
|
|
208
|
+
*
|
|
209
|
+
* // Unsubscribe from the updates when the component is unmounted
|
|
210
|
+
* unsubscribe();
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @param parentNodeUid - Node entity or its UID string.
|
|
214
|
+
* @param callback - Callback to be called when the event is emitted.
|
|
215
|
+
* @returns Callback to unsubscribe from the event.
|
|
216
|
+
*/
|
|
217
|
+
subscribeToFolder(parentNodeUid: NodeOrUid, callback: NodeEventCallback): () => void {
|
|
218
|
+
this.logger.debug(`Subscribing to children of ${getUid(parentNodeUid)}`);
|
|
219
|
+
return this.nodes.events.subscribeToChildren(getUid(parentNodeUid), callback);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Subscribe to updates of the trashed nodes.
|
|
224
|
+
*
|
|
225
|
+
* Clients should subscribe to this before beginning to list trashed
|
|
226
|
+
* nodes to ensure that updates are reflected once a node is in the cache.
|
|
227
|
+
* Subscribing before listing is also required to ensure that nodes
|
|
228
|
+
* that are trashed during the listing will be recognized.
|
|
229
|
+
*
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const unsubscribe = sdk.subscribeToTrashedNodes((event) => {
|
|
232
|
+
* if (event.type === 'update') {
|
|
233
|
+
* // Update the node in the UI
|
|
234
|
+
* } else if (event.type === 'remove') {
|
|
235
|
+
* // Remove the node from the UI
|
|
236
|
+
* }
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* const nodes = await Array.fromAsync(sdk.iterateTrashedNodes());
|
|
240
|
+
* // Render the nodes in the UI
|
|
241
|
+
*
|
|
242
|
+
* // Unsubscribe from the updates when the component is unmounted
|
|
243
|
+
* unsubscribe();
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @param callback - Callback to be called when the event is emitted.
|
|
247
|
+
* @returns Callback to unsubscribe from the event.
|
|
248
|
+
*/
|
|
249
|
+
subscribeToTrashedNodes(callback: NodeEventCallback): () => void {
|
|
250
|
+
this.logger.debug('Subscribing to trashed nodes');
|
|
251
|
+
return this.nodes.events.subscribeToTrashedNodes(callback);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Subscribe to updates of the nodes shared by the user.
|
|
256
|
+
*
|
|
257
|
+
* Clients should subscribe to this before beginning to list shared
|
|
258
|
+
* nodes to ensure that updates are reflected once a node is in the cache.
|
|
259
|
+
* Subscribing before listing is also required to ensure that nodes
|
|
260
|
+
* that are shared during the listing will be recognized.
|
|
261
|
+
*
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const unsubscribe = sdk.subscribeToSharedNodesByMe((event) => {
|
|
264
|
+
* if (event.type === 'update') {
|
|
265
|
+
* // Update the node in the UI
|
|
266
|
+
* } else if (event.type === 'remove') {
|
|
267
|
+
* // Remove the node from the UI
|
|
268
|
+
* }
|
|
269
|
+
* });
|
|
270
|
+
*
|
|
271
|
+
* const nodes = await Array.fromAsync(sdk.iterateSharedNodes());
|
|
272
|
+
* // Render the nodes in the UI
|
|
273
|
+
*
|
|
274
|
+
* // Unsubscribe from the updates when the component is unmounted
|
|
275
|
+
* unsubscribe();
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @param callback - Callback to be called when the event is emitted.
|
|
279
|
+
* @returns Callback to unsubscribe from the event.
|
|
280
|
+
*/
|
|
281
|
+
subscribeToSharedNodesByMe(callback: NodeEventCallback): () => void {
|
|
282
|
+
this.logger.debug('Subscribing to shared nodes by me');
|
|
283
|
+
return this.sharing.events.subscribeToSharedNodesByMe(callback);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Subscribe to updates of the nodes shared with the user.
|
|
288
|
+
*
|
|
289
|
+
* Clients should subscribe to this before beginning to list shared
|
|
290
|
+
* nodes to ensure that updates are reflected once a node is in the cache.
|
|
291
|
+
* Subscribing before listing is also required to ensure that nodes
|
|
292
|
+
* that are shared during the listing will be recognized.
|
|
293
|
+
*
|
|
294
|
+
* ```typescript
|
|
295
|
+
* const unsubscribe = sdk.subscribeToSharedNodesWithMe((event) => {
|
|
296
|
+
* if (event.type === 'update') {
|
|
297
|
+
* // Update the node in the UI
|
|
298
|
+
* } else if (event.type === 'remove') {
|
|
299
|
+
* // Remove the node from the UI
|
|
300
|
+
* }
|
|
301
|
+
* });
|
|
302
|
+
*
|
|
303
|
+
* const nodes = await Array.fromAsync(sdk.iterateSharedNodesWithMe());
|
|
304
|
+
* // Render the nodes in the UI
|
|
305
|
+
*
|
|
306
|
+
* // Unsubscribe from the updates when the component is unmounted
|
|
307
|
+
* unsubscribe();
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @param callback - Callback to be called when the event is emitted.
|
|
311
|
+
* @returns Callback to unsubscribe from the event.
|
|
312
|
+
*/
|
|
313
|
+
subscribeToSharedNodesWithMe(callback: NodeEventCallback): () => void {
|
|
314
|
+
this.logger.debug('Subscribing to shared nodes with me');
|
|
315
|
+
return this.sharing.events.subscribeToSharedNodesWithMe(callback);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Provides the node UID for the given raw share and node IDs.
|
|
320
|
+
*
|
|
321
|
+
* This is required only for the internal implementation to provide
|
|
322
|
+
* backward compatibility with the old Drive web setup.
|
|
323
|
+
*
|
|
324
|
+
* If you are having volume ID, use `generateNodeUid` instead.
|
|
325
|
+
*
|
|
326
|
+
* @deprecated This method is not part of the public API.
|
|
327
|
+
* @param shareId - Context share of the node.
|
|
328
|
+
* @param nodeId - Node/link ID (not UID).
|
|
329
|
+
* @returns The node UID.
|
|
330
|
+
*/
|
|
331
|
+
async getNodeUid(shareId: string, nodeId: string): Promise<string> {
|
|
332
|
+
this.logger.info(`Getting node UID for share ${shareId} and node ${nodeId}`);
|
|
333
|
+
const share = await this.shares.loadEncryptedShare(shareId);
|
|
334
|
+
return makeNodeUid(share.volumeId, nodeId);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @returns The root folder to My files section of the user.
|
|
339
|
+
*/
|
|
340
|
+
async getMyFilesRootFolder(): Promise<MaybeNode> {
|
|
341
|
+
this.logger.info('Getting my files root folder');
|
|
342
|
+
return convertInternalNodePromise(this.nodes.access.getMyFilesRootFolder());
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Iterates the children of the given parent node.
|
|
347
|
+
*
|
|
348
|
+
* The output is not sorted and the order of the children is not guaranteed.
|
|
349
|
+
*
|
|
350
|
+
* You can listen to updates via `subscribeToChildren`.
|
|
351
|
+
*
|
|
352
|
+
* @param parentNodeUid - Node entity or its UID string.
|
|
353
|
+
* @param signal - Signal to abort the operation.
|
|
354
|
+
* @returns An async generator of the children of the given parent node.
|
|
355
|
+
*/
|
|
356
|
+
async* iterateFolderChildren(parentNodeUid: NodeOrUid, signal?: AbortSignal): AsyncGenerator<MaybeNode> {
|
|
357
|
+
this.logger.info(`Iterating children of ${getUid(parentNodeUid)}`);
|
|
358
|
+
yield* convertInternalNodeIterator(this.nodes.access.iterateFolderChildren(getUid(parentNodeUid), signal));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Iterates the trashed nodes.
|
|
363
|
+
*
|
|
364
|
+
* The list of trashed nodes is not cached and is fetched from the server
|
|
365
|
+
* on each call. The node data itself are served from cached if available.
|
|
366
|
+
*
|
|
367
|
+
* The output is not sorted and the order of the trashed nodes is not guaranteed.
|
|
368
|
+
*
|
|
369
|
+
* You can listen to updates via `subscribeToTrashedNodes`.
|
|
370
|
+
*
|
|
371
|
+
* @param signal - Signal to abort the operation.
|
|
372
|
+
* @returns An async generator of the trashed nodes.
|
|
373
|
+
*/
|
|
374
|
+
async* iterateTrashedNodes(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
|
|
375
|
+
this.logger.info('Iterating trashed nodes');
|
|
376
|
+
yield* convertInternalNodeIterator(this.nodes.access.iterateTrashedNodes(signal));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Iterates the nodes by their UIDs.
|
|
381
|
+
*
|
|
382
|
+
* The output is not sorted and the order of the nodes is not guaranteed.
|
|
383
|
+
*
|
|
384
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
385
|
+
* @param signal - Signal to abort the operation.
|
|
386
|
+
* @returns An async generator of the nodes.
|
|
387
|
+
*/
|
|
388
|
+
async* iterateNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<MaybeMissingNode> {
|
|
389
|
+
this.logger.info(`Iterating ${nodeUids.length} nodes`);
|
|
390
|
+
yield* convertInternalMissingNodeIterator(this.nodes.access.iterateNodes(getUids(nodeUids), signal));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Get the node by its UID.
|
|
395
|
+
*
|
|
396
|
+
* @param nodeUid - Node entity or its UID string.
|
|
397
|
+
* @returns The node entity.
|
|
398
|
+
*/
|
|
399
|
+
async getNode(nodeUid: NodeOrUid): Promise<MaybeNode> {
|
|
400
|
+
this.logger.info(`Getting node ${getUid(nodeUid)}`);
|
|
401
|
+
return convertInternalNodePromise(this.nodes.access.getNode(getUid(nodeUid)));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Rename the node.
|
|
406
|
+
*
|
|
407
|
+
* @param nodeUid - Node entity or its UID string.
|
|
408
|
+
* @returns The updated node entity.
|
|
409
|
+
* @throws {@link ValidationError} If the name is empty, too long, or contains a slash.
|
|
410
|
+
* @throws {@link Error} If another node with the same name already exists.
|
|
411
|
+
*/
|
|
412
|
+
async renameNode(nodeUid: NodeOrUid, newName: string): Promise<MaybeNode> {
|
|
413
|
+
this.logger.info(`Renaming node ${nodeUid} to ${newName}`);
|
|
414
|
+
return convertInternalNodePromise(this.nodes.management.renameNode(getUid(nodeUid), newName));
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Move the nodes to a new parent node.
|
|
419
|
+
*
|
|
420
|
+
* The operation is performed node by node and the results are yielded
|
|
421
|
+
* as they are available. Order of the results is not guaranteed.
|
|
422
|
+
*
|
|
423
|
+
* If one of the nodes fails to move, the operation continues with the
|
|
424
|
+
* rest of the nodes. Use `NodeResult` to check the status of the action.
|
|
425
|
+
*
|
|
426
|
+
* Only move withing the same section is supported at this moment.
|
|
427
|
+
* That means that the new parent node must be in the same section
|
|
428
|
+
* as the nodes being moved. E.g., moving from My files to Shared with
|
|
429
|
+
* me is not supported yet.
|
|
430
|
+
*
|
|
431
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
432
|
+
* @param newParentNodeUid - Node entity or its UID string.
|
|
433
|
+
* @param signal - Signal to abort the operation.
|
|
434
|
+
* @returns An async generator of the results of the move operation
|
|
435
|
+
*/
|
|
436
|
+
async* moveNodes(nodeUids: NodeOrUid[], newParentNodeUid: NodeOrUid, signal?: AbortSignal): AsyncGenerator<NodeResult> {
|
|
437
|
+
this.logger.info(`Moving ${nodeUids.length} nodes to ${newParentNodeUid}`);
|
|
438
|
+
yield* this.nodes.management.moveNodes(getUids(nodeUids), getUid(newParentNodeUid), signal);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Trash the nodes.
|
|
443
|
+
*
|
|
444
|
+
* The operation is performed in batches and the results are yielded
|
|
445
|
+
* as they are available. Order of the results is not guaranteed.
|
|
446
|
+
*
|
|
447
|
+
* If one of the nodes fails to trash, the operation continues with the
|
|
448
|
+
* rest of the nodes. Use `NodeResult` to check the status of the action.
|
|
449
|
+
*
|
|
450
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
451
|
+
* @param signal - Signal to abort the operation.
|
|
452
|
+
* @returns An async generator of the results of the trash operation
|
|
453
|
+
*/
|
|
454
|
+
async* trashNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
|
|
455
|
+
this.logger.info(`Trashing ${nodeUids.length} nodes`);
|
|
456
|
+
yield* this.nodes.management.trashNodes(getUids(nodeUids), signal);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Restore the nodes from the trash to their original place.
|
|
461
|
+
*
|
|
462
|
+
* The operation is performed in batches and the results are yielded
|
|
463
|
+
* as they are available. Order of the results is not guaranteed.
|
|
464
|
+
*
|
|
465
|
+
* If one of the nodes fails to restore, the operation continues with the
|
|
466
|
+
* rest of the nodes. Use `NodeResult` to check the status of the action.
|
|
467
|
+
*
|
|
468
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
469
|
+
* @param signal - Signal to abort the operation.
|
|
470
|
+
* @returns An async generator of the results of the restore operation
|
|
471
|
+
*/
|
|
472
|
+
async* restoreNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
|
|
473
|
+
this.logger.info(`Restoring ${nodeUids.length} nodes`);
|
|
474
|
+
yield* this.nodes.management.restoreNodes(getUids(nodeUids), signal);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Delete the nodes permanently.
|
|
479
|
+
*
|
|
480
|
+
* The operation is performed in batches and the results are yielded
|
|
481
|
+
* as they are available. Order of the results is not guaranteed.
|
|
482
|
+
*
|
|
483
|
+
* If one of the nodes fails to delete, the operation continues with the
|
|
484
|
+
* rest of the nodes. Use `NodeResult` to check the status of the action.
|
|
485
|
+
*
|
|
486
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
487
|
+
* @param signal - Signal to abort the operation.
|
|
488
|
+
* @returns An async generator of the results of the delete operation
|
|
489
|
+
*/
|
|
490
|
+
async* deleteNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<NodeResult> {
|
|
491
|
+
this.logger.info(`Deleting ${nodeUids.length} nodes`);
|
|
492
|
+
yield* this.nodes.management.deleteNodes(getUids(nodeUids), signal);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
async emptyTrash(): Promise<void> {
|
|
496
|
+
this.logger.info('Emptying trash');
|
|
497
|
+
throw new Error('Method not implemented');
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Create a new folder.
|
|
502
|
+
*
|
|
503
|
+
* The folder is created in the given parent node.
|
|
504
|
+
*
|
|
505
|
+
* @param parentNodeUid - Node entity or its UID string of the parent folder.
|
|
506
|
+
* @param name - Name of the new folder.
|
|
507
|
+
* @param modificationTime - Optional modification time of the folder.
|
|
508
|
+
* @returns The created node entity.
|
|
509
|
+
* @throws {@link Error} If the parent node is not a folder.
|
|
510
|
+
* @throws {@link ValidationError} If the name is empty, too long, or contains a slash.
|
|
511
|
+
* @throws {@link Error} If another node with the same name already exists.
|
|
512
|
+
*/
|
|
513
|
+
async createFolder(parentNodeUid: NodeOrUid, name: string, modificationTime?: Date): Promise<MaybeNode> {
|
|
514
|
+
this.logger.info(`Creating folder ${name} in ${getUid(parentNodeUid)}`);
|
|
515
|
+
return convertInternalNodePromise(this.nodes.management.createFolder(getUid(parentNodeUid), name, modificationTime));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Iterates the revisions of given node.
|
|
520
|
+
*
|
|
521
|
+
* The list of node revisions is not cached and is fetched and decrypted
|
|
522
|
+
* from the server on each call.
|
|
523
|
+
*
|
|
524
|
+
* The output is sorted by the revision date in descending order (newest
|
|
525
|
+
* first).
|
|
526
|
+
*
|
|
527
|
+
* @param nodeUid - Node entity or its UID string.
|
|
528
|
+
* @param signal - Signal to abort the operation.
|
|
529
|
+
* @returns An async generator of the node revisions.
|
|
530
|
+
*/
|
|
531
|
+
async* iterateRevisions(nodeUid: NodeOrUid, signal?: AbortSignal): AsyncGenerator<Revision> {
|
|
532
|
+
this.logger.info(`Iterating revisions of ${getUid(nodeUid)}`);
|
|
533
|
+
yield* this.nodes.revisions.iterateRevisions(getUid(nodeUid), signal);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Restore the node to the given revision.
|
|
538
|
+
*
|
|
539
|
+
* Warning: Restoring revisions might be accepted by the server but not
|
|
540
|
+
* applied. If the client re-loads list of revisions quickly after the
|
|
541
|
+
* restore, the change might not be visible. Update the UI optimistically to
|
|
542
|
+
* reflect the change.
|
|
543
|
+
*
|
|
544
|
+
* @param revisionUid - UID of the revision to restore.
|
|
545
|
+
*/
|
|
546
|
+
async restoreRevision(revisionUid: string): Promise<void> {
|
|
547
|
+
this.logger.info(`Restoring revision ${revisionUid}`);
|
|
548
|
+
await this.nodes.revisions.restoreRevision(revisionUid);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Delete the revision.
|
|
553
|
+
*
|
|
554
|
+
* @param revisionUid - UID of the revision to delete.
|
|
555
|
+
*/
|
|
556
|
+
async deleteRevision(revisionUid: string): Promise<void> {
|
|
557
|
+
this.logger.info(`Deleting revision ${revisionUid}`);
|
|
558
|
+
await this.nodes.revisions.deleteRevision(revisionUid);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Iterates the nodes shared by the user.
|
|
563
|
+
*
|
|
564
|
+
* The output is not sorted and the order of the shared nodes is not guaranteed.
|
|
565
|
+
*
|
|
566
|
+
* You can listen to updates via `subscribeToSharedNodesByMe`.
|
|
567
|
+
*
|
|
568
|
+
* @param signal - Signal to abort the operation.
|
|
569
|
+
* @returns An async generator of the shared nodes.
|
|
570
|
+
*/
|
|
571
|
+
async* iterateSharedNodes(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
|
|
572
|
+
this.logger.info('Iterating shared nodes by me');
|
|
573
|
+
yield* convertInternalNodeIterator(this.sharing.access.iterateSharedNodes(signal));
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Iterates the nodes shared with the user.
|
|
578
|
+
*
|
|
579
|
+
* The output is not sorted and the order of the shared nodes is not guaranteed.
|
|
580
|
+
*
|
|
581
|
+
* At the end of the iteration, if `subscribeToRemoteDataUpdates` was called,
|
|
582
|
+
* the SDK will listen to updates for the shared nodes to keep the local cache
|
|
583
|
+
* in sync with the remote data.
|
|
584
|
+
*
|
|
585
|
+
* You can listen to updates via `subscribeToSharedNodesWithMe`.
|
|
586
|
+
*
|
|
587
|
+
* @param signal - Signal to abort the operation.
|
|
588
|
+
* @returns An async generator of the shared nodes.
|
|
589
|
+
*/
|
|
590
|
+
async* iterateSharedNodesWithMe(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
|
|
591
|
+
this.logger.info('Iterating shared nodes with me');
|
|
592
|
+
|
|
593
|
+
const uniqueVolumeIds = new Set<string>();
|
|
594
|
+
for await (const node of this.sharing.access.iterateSharedNodesWithMe(signal)) {
|
|
595
|
+
yield convertInternalNode(node);
|
|
596
|
+
const { volumeId } = splitNodeUid(node.uid);
|
|
597
|
+
uniqueVolumeIds.add(volumeId);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
for (const volumeId of uniqueVolumeIds) {
|
|
601
|
+
await this.events.listenToVolume(volumeId, false);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Leave shared node that was previously shared with the user.
|
|
607
|
+
*
|
|
608
|
+
* @param nodeUid - Node entity or its UID string.
|
|
609
|
+
*/
|
|
610
|
+
async leaveSharedNode(nodeUid: NodeOrUid): Promise<void> {
|
|
611
|
+
this.logger.info(`Leaving shared node with me ${getUid(nodeUid)}`);
|
|
612
|
+
await this.sharing.access.removeSharedNodeWithMe(getUid(nodeUid));
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Iterates the invitations to shared nodes.
|
|
617
|
+
*
|
|
618
|
+
* The output is not sorted and the order of the invitations is not guaranteed.
|
|
619
|
+
*
|
|
620
|
+
* @param signal - Signal to abort the operation.
|
|
621
|
+
* @returns An async generator of the invitations.
|
|
622
|
+
*/
|
|
623
|
+
async* iterateInvitations(signal?: AbortSignal): AsyncGenerator<ProtonInvitationWithNode> {
|
|
624
|
+
this.logger.info('Iterating invitations');
|
|
625
|
+
yield* this.sharing.access.iterateInvitations(signal);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Accept the invitation to the shared node.
|
|
630
|
+
*
|
|
631
|
+
* @param invitationId - Invitation entity or its UID string.
|
|
632
|
+
*/
|
|
633
|
+
async acceptInvitation(invitationId: string): Promise<void> {
|
|
634
|
+
this.logger.info(`Accepting invitation ${invitationId}`);
|
|
635
|
+
await this.sharing.access.acceptInvitation(invitationId);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Reject the invitation to the shared node.
|
|
640
|
+
*
|
|
641
|
+
* @param invitationId - Invitation entity or its UID string.
|
|
642
|
+
*/
|
|
643
|
+
async rejectInvitation(invitationId: string): Promise<void> {
|
|
644
|
+
this.logger.info(`Rejecting invitation ${invitationId}`);
|
|
645
|
+
await this.sharing.access.rejectInvitation(invitationId);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Get sharing info of the node.
|
|
650
|
+
*
|
|
651
|
+
* The sharing info contains the list of invitations, members,
|
|
652
|
+
* public link and permission for each.
|
|
653
|
+
*
|
|
654
|
+
* The sharing info is not cached and is fetched from the server
|
|
655
|
+
* on each call.
|
|
656
|
+
*
|
|
657
|
+
* @param nodeUid - Node entity or its UID string.
|
|
658
|
+
* @returns The sharing info of the node. Undefined if not shared.
|
|
659
|
+
*/
|
|
660
|
+
async getSharingInfo(nodeUid: NodeOrUid): Promise<ShareResult | undefined> {
|
|
661
|
+
this.logger.info(`Getting sharing info for ${getUid(nodeUid)}`);
|
|
662
|
+
return this.sharing.management.getSharingInfo(getUid(nodeUid));
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Share or update sharing of the node.
|
|
667
|
+
*
|
|
668
|
+
* If the node is already shared, the sharing settings are updated.
|
|
669
|
+
* If the member is already present but with different role, the role
|
|
670
|
+
* is updated. If the sharing settings is identical, the sharing info
|
|
671
|
+
* is returned without any change.
|
|
672
|
+
*
|
|
673
|
+
* @param nodeUid - Node entity or its UID string.
|
|
674
|
+
* @param settings - Settings for sharing the node.
|
|
675
|
+
* @returns The updated sharing info of the node.
|
|
676
|
+
*/
|
|
677
|
+
async shareNode(nodeUid: NodeOrUid, settings: ShareNodeSettings): Promise<ShareResult> {
|
|
678
|
+
this.logger.info(`Sharing node ${getUid(nodeUid)}`);
|
|
679
|
+
return this.sharing.management.shareNode(getUid(nodeUid), settings);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Unshare the node, completely or partially.
|
|
684
|
+
*
|
|
685
|
+
* @param nodeUid - Node entity or its UID string.
|
|
686
|
+
* @param settings - Settings for unsharing the node. If not provided, the node
|
|
687
|
+
* is unshared completely.
|
|
688
|
+
* @returns The updated sharing info of the node. Undefined if unshared completely.
|
|
689
|
+
*/
|
|
690
|
+
async unshareNode(nodeUid: NodeOrUid, settings?: UnshareNodeSettings): Promise<ShareResult | undefined> {
|
|
691
|
+
if (!settings) {
|
|
692
|
+
this.logger.info(`Unsharing node ${getUid(nodeUid)}`);
|
|
693
|
+
} else {
|
|
694
|
+
this.logger.info(`Partially unsharing ${getUid(nodeUid)}`);
|
|
695
|
+
}
|
|
696
|
+
return this.sharing.management.unshareNode(getUid(nodeUid), settings);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
async resendInvitation(nodeUid: NodeOrUid, invitationUid: ProtonInvitationOrUid | NonProtonInvitationOrUid): Promise<void> {
|
|
700
|
+
this.logger.info(`Resending invitation ${getUid(invitationUid)}`);
|
|
701
|
+
return this.sharing.management.resendInvitationEmail(getUid(nodeUid), getUid(invitationUid))
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Get the file downloader to download the node content of the active
|
|
706
|
+
* revision. For downloading specific revision of the file, use
|
|
707
|
+
* `getFileRevisionDownloader`.
|
|
708
|
+
*
|
|
709
|
+
* The number of ongoing downloads is limited. If the limit is reached,
|
|
710
|
+
* the download is queued and started when the slot is available. It is
|
|
711
|
+
* recommended to not start too many downloads at once to avoid having
|
|
712
|
+
* many open promises.
|
|
713
|
+
*
|
|
714
|
+
* The file downloader is not reusable. If the download is interrupted,
|
|
715
|
+
* a new file downloader must be created.
|
|
716
|
+
*
|
|
717
|
+
* Before download, the authorship of the node should be checked and
|
|
718
|
+
* reported to the user if there is any signature issue, notably on the
|
|
719
|
+
* content author on the revision.
|
|
720
|
+
*
|
|
721
|
+
* Client should not automatically retry the download if it fails. The
|
|
722
|
+
* download should be initiated by the user again. The downloader does
|
|
723
|
+
* automatically retry the download if it fails due to network issues,
|
|
724
|
+
* or if the server is temporarily unavailable.
|
|
725
|
+
*
|
|
726
|
+
* Once download is initiated, the download can fail, besides network
|
|
727
|
+
* issues etc., only when there is integrity error. It should be considered
|
|
728
|
+
* a bug and reported to the Drive developers. The SDK provides option
|
|
729
|
+
* to bypass integrity checks, but that should be used only for debugging
|
|
730
|
+
* purposes, not available to the end users.
|
|
731
|
+
*
|
|
732
|
+
* Example usage:
|
|
733
|
+
*
|
|
734
|
+
* ```typescript
|
|
735
|
+
* const downloader = await client.getFileDownloader(nodeUid, signal);
|
|
736
|
+
* const claimedSize = fileDownloader.getClaimedSizeInBytes();
|
|
737
|
+
* const downloadController = fileDownloader.writeToStream(stream, (downloadedBytes) => { ... });
|
|
738
|
+
*
|
|
739
|
+
* signalController.abort(); // to cancel
|
|
740
|
+
* downloadController.pause(); // to pause
|
|
741
|
+
* downloadController.resume(); // to resume
|
|
742
|
+
* await downloadController.completion(); // to await completion
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
async getFileDownloader(nodeUid: NodeOrUid, signal?: AbortSignal): Promise<FileDownloader> {
|
|
746
|
+
this.logger.info(`Getting file downloader for ${getUid(nodeUid)}`);
|
|
747
|
+
return this.download.getFileDownloader(getUid(nodeUid), signal);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Same as `getFileDownloader`, but for a specific revision of the file.
|
|
752
|
+
*/
|
|
753
|
+
async getFileRevisionDownloader(nodeRevisionUid: string, signal?: AbortSignal): Promise<FileDownloader> {
|
|
754
|
+
this.logger.info(`Getting file revision downloader for ${getUid(nodeRevisionUid)}`);
|
|
755
|
+
return this.download.getFileRevisionDownloader(nodeRevisionUid, signal);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Iterates the thumbnails of the given nodes.
|
|
760
|
+
*
|
|
761
|
+
* The output is not sorted and the order of the nodes is not guaranteed.
|
|
762
|
+
*
|
|
763
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
764
|
+
* @param thumbnailType - Type of the thumbnail to download.
|
|
765
|
+
* @returns An async generator of the results of the restore operation
|
|
766
|
+
*/
|
|
767
|
+
async *iterateThumbnails(nodeUids: NodeOrUid[], thumbnailType?: ThumbnailType, signal?: AbortSignal): AsyncGenerator<ThumbnailResult> {
|
|
768
|
+
this.logger.info(`Iterating ${nodeUids.length} thumbnails`);
|
|
769
|
+
yield* this.download.iterateThumbnails(getUids(nodeUids), thumbnailType, signal);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Get the file uploader to upload a new file. For uploading a new
|
|
774
|
+
* revision, use `getFileRevisionUploader` instead.
|
|
775
|
+
*
|
|
776
|
+
* The number of ongoing uploads is limited. If the limit is reached,
|
|
777
|
+
* the upload is queued and started when the slot is available. It is
|
|
778
|
+
* recommended to not start too many uploads at once to avoid having
|
|
779
|
+
* many open promises.
|
|
780
|
+
*
|
|
781
|
+
* The file uploader is not reusable. If the upload is interrupted,
|
|
782
|
+
* a new file uploader must be created.
|
|
783
|
+
*
|
|
784
|
+
* Client should not automatically retry the upload if it fails. The
|
|
785
|
+
* upload should be initiated by the user again. The uploader does
|
|
786
|
+
* automatically retry the upload if it fails due to network issues,
|
|
787
|
+
* or if the server is temporarily unavailable.
|
|
788
|
+
*
|
|
789
|
+
* Example usage:
|
|
790
|
+
*
|
|
791
|
+
* ```typescript
|
|
792
|
+
* const uploader = await client.getFileUploader(parentFolderUid, name, metadata, signal);
|
|
793
|
+
* const uploadController = uploader.writeStream(stream, thumbnails, (uploadedBytes) => { ... });
|
|
794
|
+
*
|
|
795
|
+
* signalController.abort(); // to cancel
|
|
796
|
+
* uploadController.pause(); // to pause
|
|
797
|
+
* uploadController.resume(); // to resume
|
|
798
|
+
* const nodeUid = await uploadController.completion(); // to await completion
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
async getFileUploader(parentFolderUid: NodeOrUid, name: string, metadata: UploadMetadata, signal?: AbortSignal): Promise<Fileuploader> {
|
|
802
|
+
this.logger.info(`Getting file uploader for parent ${getUid(parentFolderUid)}`);
|
|
803
|
+
return this.upload.getFileUploader(getUid(parentFolderUid), name, metadata, signal);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Same as `getFileUploader`, but for a uploading new revision of the file.
|
|
808
|
+
*/
|
|
809
|
+
async getFileRevisionUploader(nodeUid: NodeOrUid, metadata: UploadMetadata, signal?: AbortSignal): Promise<Fileuploader> {
|
|
810
|
+
this.logger.info(`Getting file revision uploader for ${getUid(nodeUid)}`);
|
|
811
|
+
return this.upload.getFileRevisionUploader(getUid(nodeUid), metadata, signal);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Iterates the devices of the user.
|
|
816
|
+
*
|
|
817
|
+
* The output is not sorted and the order of the devices is not guaranteed.
|
|
818
|
+
*
|
|
819
|
+
* You can listen to updates via `subscribeToDevices`.
|
|
820
|
+
*
|
|
821
|
+
* @returns An async generator of devices.
|
|
822
|
+
*/
|
|
823
|
+
async* iterateDevices(signal?: AbortSignal): AsyncGenerator<Device> {
|
|
824
|
+
this.logger.info('Iterating devices');
|
|
825
|
+
yield* this.devices.iterateDevices(signal);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Creates a new device.
|
|
830
|
+
*
|
|
831
|
+
* @param nodeUid - Device entity or its UID string.
|
|
832
|
+
* @returns The created device entity.
|
|
833
|
+
* @throws {@link ValidationError} If the name is empty, too long, or contains a slash.
|
|
834
|
+
*/
|
|
835
|
+
async createDevice(name: string, deviceType: DeviceType): Promise<Device> {
|
|
836
|
+
this.logger.info(`Creating device of type ${deviceType}`);
|
|
837
|
+
return this.devices.createDevice(name, deviceType);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Renames a device.
|
|
842
|
+
*
|
|
843
|
+
* @param deviceOrUid - Device entity or its UID string.
|
|
844
|
+
* @returns The updated device entity.
|
|
845
|
+
* @throws {@link ValidationError} If the name is empty, too long, or contains a slash.
|
|
846
|
+
*/
|
|
847
|
+
async renameDevice(deviceOrUid: DeviceOrUid, name: string): Promise<Device> {
|
|
848
|
+
this.logger.info(`Renaming device ${getUid(deviceOrUid)}`);
|
|
849
|
+
return this.devices.renameDevice(getUid(deviceOrUid), name);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Deletes a device.
|
|
854
|
+
*
|
|
855
|
+
* @param deviceOrUid - Device entity or its UID string.
|
|
856
|
+
*/
|
|
857
|
+
async deleteDevice(deviceOrUid: DeviceOrUid): Promise<void> {
|
|
858
|
+
this.logger.info(`Deleting device ${getUid(deviceOrUid)}`);
|
|
859
|
+
await this.devices.deleteDevice(getUid(deviceOrUid));
|
|
860
|
+
}
|
|
861
|
+
}
|