@protontech/drive-sdk 0.0.13 → 0.1.1

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