@secrecy/lib 1.0.0-dev.25 → 1.0.0-dev.28

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 (155) hide show
  1. package/dist/BaseClient.d.ts +274 -0
  2. package/dist/BaseClient.js +2227 -0
  3. package/dist/PopupTools.d.ts +17 -0
  4. package/dist/PopupTools.js +213 -0
  5. package/dist/ZeusThunder.d.ts +2 -0
  6. package/dist/ZeusThunder.js +113 -0
  7. package/dist/cache.d.ts +7 -0
  8. package/dist/cache.js +5 -0
  9. package/dist/client/admin/index.d.ts +11 -0
  10. package/dist/client/admin/index.js +198 -0
  11. package/dist/client/convert/file.d.ts +5 -0
  12. package/dist/client/convert/file.js +39 -0
  13. package/dist/client/convert/folder.d.ts +8 -0
  14. package/dist/client/convert/folder.js +264 -0
  15. package/dist/client/convert/mail.d.ts +3 -0
  16. package/dist/client/convert/mail.js +46 -0
  17. package/dist/client/convert/vFile.d.ts +5 -0
  18. package/dist/client/convert/vFile.js +164 -0
  19. package/dist/client/helpers.d.ts +23 -0
  20. package/dist/client/helpers.js +114 -0
  21. package/dist/client/index.d.ts +172 -0
  22. package/dist/client/index.js +6169 -0
  23. package/dist/client/storage.d.ts +7 -0
  24. package/dist/client/storage.js +12 -0
  25. package/dist/client/types/File.d.ts +21 -0
  26. package/dist/client/types/File.js +3 -0
  27. package/dist/client/types/FilesOnUsersOnApplications.d.ts +9 -0
  28. package/dist/client/types/FilesOnUsersOnApplications.js +3 -0
  29. package/dist/client/types/Folder.d.ts +68 -0
  30. package/dist/client/types/Folder.js +7 -0
  31. package/dist/client/types/Inputs.d.ts +21 -0
  32. package/dist/client/types/Inputs.js +3 -0
  33. package/dist/client/types/UserAppNotifications.d.ts +6 -0
  34. package/dist/client/types/UserAppNotifications.js +3 -0
  35. package/dist/client/types/UserAppSettings.d.ts +7 -0
  36. package/dist/client/types/UserAppSettings.js +3 -0
  37. package/dist/client/types/VFile.d.ts +62 -0
  38. package/dist/client/types/VFile.js +4 -0
  39. package/dist/client/types/index.d.ts +154 -0
  40. package/dist/client/types/index.js +10 -0
  41. package/dist/client/types/queries.d.ts +535 -0
  42. package/dist/client/types/queries.js +192 -0
  43. package/dist/crypto/file.d.ts +14 -0
  44. package/dist/crypto/file.js +291 -0
  45. package/dist/crypto/index.d.ts +12 -0
  46. package/dist/crypto/index.js +45 -0
  47. package/dist/error.d.ts +30 -0
  48. package/dist/error.js +3 -0
  49. package/dist/index.d.ts +13 -3857
  50. package/dist/index.js +42 -255
  51. package/dist/minify/index.d.ts +2 -0
  52. package/dist/minify/index.js +28 -0
  53. package/dist/minify/lz4.d.ts +5 -0
  54. package/dist/minify/lz4.js +633 -0
  55. package/dist/sodium.d.ts +3 -0
  56. package/dist/sodium.js +28 -0
  57. package/dist/utils/store-buddy.d.ts +14 -0
  58. package/dist/utils/store-buddy.js +69 -0
  59. package/dist/utils/time.d.ts +10 -0
  60. package/dist/utils/time.js +22 -0
  61. package/dist/utils.d.ts +4 -0
  62. package/dist/utils.js +188 -0
  63. package/dist/worker/__mock__/sodium.worker.d.ts +19 -0
  64. package/dist/worker/__mock__/sodium.worker.js +46 -0
  65. package/dist/worker/md5.d.ts +1 -0
  66. package/dist/worker/md5.js +43 -0
  67. package/dist/worker/sodium.d.ts +3 -0
  68. package/dist/worker/sodium.js +155 -0
  69. package/dist/worker/workerCodes.d.ts +2 -0
  70. package/dist/worker/workerCodes.js +3 -0
  71. package/dist/zeus/const.d.ts +2 -0
  72. package/dist/zeus/const.js +2267 -0
  73. package/dist/zeus/index.d.ts +4043 -0
  74. package/dist/zeus/index.js +549 -0
  75. package/package.json +24 -16
  76. package/CHANGELOG.md +0 -178
  77. package/__tests__/client/client.test.ts +0 -81
  78. package/__tests__/client/folder.test.ts +0 -302
  79. package/__tests__/client/mail.test.ts +0 -476
  80. package/__tests__/client/timing.test.ts +0 -35
  81. package/__tests__/client/utils.ts +0 -41
  82. package/__tests__/client/vFile.test.ts +0 -207
  83. package/__tests__/index.test.ts +0 -171
  84. package/commitlint.config.cjs +0 -3
  85. package/dist/index.js.map +0 -1
  86. package/dist/index.mjs +0 -255
  87. package/dist/index.mjs.map +0 -1
  88. package/docs/assets/css/main.css +0 -2660
  89. package/docs/assets/images/icons.png +0 -0
  90. package/docs/assets/images/icons@2x.png +0 -0
  91. package/docs/assets/images/widgets.png +0 -0
  92. package/docs/assets/images/widgets@2x.png +0 -0
  93. package/docs/assets/js/main.js +0 -248
  94. package/docs/assets/js/search.js +0 -1
  95. package/docs/classes/baseclient.baseclient-1.html +0 -1165
  96. package/docs/classes/client.secrecyclient.html +0 -2527
  97. package/docs/enums/index.sodium.base64_variants.html +0 -205
  98. package/docs/index.html +0 -198
  99. package/docs/interfaces/client_types.draftmail.html +0 -335
  100. package/docs/interfaces/client_types.filecontentbase.html +0 -231
  101. package/docs/interfaces/client_types.filecontentcloud.html +0 -244
  102. package/docs/interfaces/client_types.filecontentreceivedmail.html +0 -244
  103. package/docs/interfaces/client_types.filecontentsentmail.html +0 -230
  104. package/docs/interfaces/client_types.receivedmail.html +0 -363
  105. package/docs/interfaces/client_types.sentmail.html +0 -335
  106. package/docs/interfaces/crypto.keypair.html +0 -202
  107. package/docs/interfaces/index.sodium.cryptobox.html +0 -185
  108. package/docs/interfaces/index.sodium.cryptokx.html +0 -185
  109. package/docs/interfaces/index.sodium.keypair.html +0 -199
  110. package/docs/interfaces/index.sodium.messagetag.html +0 -185
  111. package/docs/interfaces/index.sodium.secretbox.html +0 -185
  112. package/docs/interfaces/index.sodium.stateaddress.html +0 -171
  113. package/docs/interfaces/index.sodium.stringcryptobox.html +0 -185
  114. package/docs/interfaces/index.sodium.stringcryptokx.html +0 -185
  115. package/docs/interfaces/index.sodium.stringkeypair.html +0 -199
  116. package/docs/interfaces/index.sodium.stringmessagetag.html +0 -185
  117. package/docs/interfaces/index.sodium.stringsecretbox.html +0 -185
  118. package/docs/interfaces/utils_store_buddy.storebuddy.html +0 -333
  119. package/docs/modules/baseclient.html +0 -929
  120. package/docs/modules/cache.html +0 -185
  121. package/docs/modules/client.html +0 -207
  122. package/docs/modules/client_convert_file.html +0 -216
  123. package/docs/modules/client_convert_folder.html +0 -303
  124. package/docs/modules/client_convert_vfile.html +0 -216
  125. package/docs/modules/client_helpers.html +0 -311
  126. package/docs/modules/client_storage.html +0 -167
  127. package/docs/modules/client_types.html +0 -1227
  128. package/docs/modules/client_types_file.html +0 -233
  129. package/docs/modules/client_types_filesonusersonapplications.html +0 -168
  130. package/docs/modules/client_types_folder.html +0 -383
  131. package/docs/modules/client_types_inputs.html +0 -263
  132. package/docs/modules/client_types_mail.html +0 -181
  133. package/docs/modules/client_types_queries.html +0 -199
  134. package/docs/modules/client_types_userappsettings.html +0 -163
  135. package/docs/modules/client_types_vfile.html +0 -364
  136. package/docs/modules/crypto.html +0 -366
  137. package/docs/modules/crypto_file.html +0 -344
  138. package/docs/modules/index.html +0 -779
  139. package/docs/modules/index.sodium.html +0 -6039
  140. package/docs/modules/minify.html +0 -183
  141. package/docs/modules/minify_lz4.html +0 -279
  142. package/docs/modules/popuptools.html +0 -259
  143. package/docs/modules/sodium.html +0 -167
  144. package/docs/modules/utils.html +0 -219
  145. package/docs/modules/utils_store_buddy.html +0 -208
  146. package/docs/modules/utils_time.html +0 -330
  147. package/docs/modules/worker_md5.html +0 -156
  148. package/docs/modules/worker_sodium.html +0 -231
  149. package/docs/modules/worker_workercodes.html +0 -157
  150. package/docs/modules.html +0 -235
  151. package/index.html +0 -21
  152. package/jest.config.ts +0 -27
  153. package/jest.setup.ts +0 -6
  154. package/release.config.cjs +0 -15
  155. package/tsup.config.ts +0 -23
package/dist/index.mjs DELETED
@@ -1,255 +0,0 @@
1
- var Le=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var c=(t,e,r)=>(Le(t,e,"read from private field"),r?r.call(t):e.get(t)),Ue=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Ie=(t,e,r,s)=>(Le(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r);import Qr from"ky";import Gr from"axios";import{serialize as Er}from"bson";import{getLink as Ar}from"@secrecy/lib-utils";var U=new Map,I=new Map,x=new Map,K=new Map;function O(t,e=!1){return{init(r){let s=e?sessionStorage:localStorage;return s.getItem(t)||s.setItem(t,JSON.stringify(r)),{load(){let n=s.getItem(t);if(!n)throw new Error("store-buddy: data has not been set or cannot be recognised");return JSON.parse(n)},save:n=>s.setItem(t,JSON.stringify(n)),reset:()=>s.setItem(t,JSON.stringify(r)),clear:()=>s.removeItem(t)}}}}function k(t){let e=O("secrecy.user_app_session",t).init(null),r=O("secrecy.user_app_keys",t).init(null),s=O("secrecy.jwt",t).init(null);return{userAppKeys:r,userAppSession:e,jwt:s}}var ae={BigInt:"String",Bytes:"String",DateTime:"String",Decimal:"String",Json:"String",Lang:"enum",PlanKind:"enum",UserRole:"enum",MailType:"enum",Rights:"enum",FileContentType:"enum",MailFileInput:{id:{type:"String",array:!1,arrayRequired:!1,required:!0},name:{type:"String",array:!1,arrayRequired:!1,required:!0},fileKey:{type:"String",array:!1,arrayRequired:!1,required:!0}},MailRecipientInput:{body:{type:"String",array:!1,arrayRequired:!1,required:!0},subject:{type:"String",array:!1,arrayRequired:!1,required:!0},recipientId:{type:"String",array:!1,arrayRequired:!1,required:!0},files:{type:"MailFileInput",array:!0,arrayRequired:!0,required:!0}},NameKeyInput:{id:{type:"String",array:!1,arrayRequired:!1,required:!0},nameKey:{type:"String",array:!1,arrayRequired:!1,required:!0},files:{type:"ShareFileKeyInput",array:!0,arrayRequired:!0,required:!0}},NameKeyInputFolders:{id:{type:"String",array:!1,arrayRequired:!1,required:!0},nameKey:{type:"String",array:!1,arrayRequired:!1,required:!0}},PayInput:{type:{type:"PayInputType",array:!1,arrayRequired:!1,required:!0},token:{type:"String",array:!1,arrayRequired:!1,required:!0},firstName:{type:"String",array:!1,arrayRequired:!1,required:!0},lastName:{type:"String",array:!1,arrayRequired:!1,required:!0},street:{type:"String",array:!1,arrayRequired:!1,required:!0},postalCode:{type:"String",array:!1,arrayRequired:!1,required:!0},city:{type:"String",array:!1,arrayRequired:!1,required:!0},country:{type:"String",array:!1,arrayRequired:!1,required:!0},number:{type:"String",array:!1,arrayRequired:!1,required:!0},month:{type:"String",array:!1,arrayRequired:!1,required:!0},year:{type:"String",array:!1,arrayRequired:!1,required:!0},cvv:{type:"String",array:!1,arrayRequired:!1,required:!0}},PayInputType:"enum",ShareFileInHistoryInput:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0},users:{type:"ShareFileKeyInput",array:!0,arrayRequired:!0,required:!0}},ShareFileKeyInput:{id:{type:"String",array:!1,arrayRequired:!1,required:!0},key:{type:"String",array:!1,arrayRequired:!1,required:!0}},ShareFoldersInput:{folders:{type:"NameKeyInputFolders",array:!0,arrayRequired:!0,required:!0},vFiles:{type:"NameKeyInput",array:!0,arrayRequired:!0,required:!0}},Query:{blog:{lang:{type:"Lang",array:!1,arrayRequired:!1,required:!1}},dbConfig:{appCode:{type:"String",array:!1,arrayRequired:!1,required:!0}},dbGet:{field:{type:"String",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!1}},dbSearch:{search:{type:"String",array:!1,arrayRequired:!1,required:!0},field:{type:"String",array:!1,arrayRequired:!1,required:!0}},deletedMails:{mailType:{type:"MailType",array:!1,arrayRequired:!1,required:!0}},faq:{lang:{type:"Lang",array:!1,arrayRequired:!1,required:!1}},file:{id:{type:"String",array:!1,arrayRequired:!1,required:!0}},fileContent:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},filesSharedWithMe:{accepted:{type:"Boolean",array:!1,arrayRequired:!1,required:!1}},folder:{id:{type:"String",array:!1,arrayRequired:!1,required:!1},deleted:{type:"Boolean",array:!1,arrayRequired:!1,required:!1}},folderSize:{folderId:{type:"String",array:!1,arrayRequired:!1,required:!1}},mail:{id:{type:"String",array:!1,arrayRequired:!1,required:!0}},user:{userId:{type:"String",array:!1,arrayRequired:!1,required:!1}},vFile:{id:{type:"String",array:!1,arrayRequired:!1,required:!0}},userList:{search:{type:"String",array:!1,arrayRequired:!1,required:!1}}},Mutation:{addFileToHistory:{vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0},fileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},createApplication:{name:{type:"String",array:!1,arrayRequired:!1,required:!0},origin:{type:"String",array:!1,arrayRequired:!1,required:!0},developerId:{type:"String",array:!1,arrayRequired:!1,required:!0}},createDraftMail:{hash:{type:"String",array:!1,arrayRequired:!1,required:!0},hashKey:{type:"String",array:!1,arrayRequired:!1,required:!0},body:{type:"String",array:!1,arrayRequired:!1,required:!0},subject:{type:"String",array:!1,arrayRequired:!1,required:!0},replyTo:{type:"String",array:!1,arrayRequired:!1,required:!1},senderFiles:{type:"MailFileInput",array:!0,arrayRequired:!0,required:!0},recipients:{type:"String",array:!0,arrayRequired:!0,required:!0}},createFolder:{name:{type:"String",array:!1,arrayRequired:!1,required:!0},key:{type:"String",array:!1,arrayRequired:!1,required:!0},parentFolderId:{type:"String",array:!1,arrayRequired:!1,required:!1}},dbConfigMutation:{appCode:{type:"String",array:!1,arrayRequired:!1,required:!0},config:{type:"String",array:!1,arrayRequired:!1,required:!0}},dbSet:{value:{type:"String",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!1}},deleteDraftMail:{draftId:{type:"String",array:!1,arrayRequired:!1,required:!0}},deleteFile:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0},vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},deleteFolder:{id:{type:"String",array:!1,arrayRequired:!1,required:!0}},deleteFolderCloudTrash:{ids:{type:"String",array:!0,arrayRequired:!0,required:!0}},deleteFolderSharing:{folderId:{type:"String",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!0}},deleteMail:{mailId:{type:"String",array:!1,arrayRequired:!1,required:!0}},deleteMailTrash:{ids:{type:"String",array:!0,arrayRequired:!0,required:!0}},deleteUser:{userId:{type:"String",array:!1,arrayRequired:!1,required:!1}},deleteVFile:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},deleteVFileCloudTrash:{ids:{type:"String",array:!0,arrayRequired:!0,required:!0}},deleteVFileSharing:{vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!0}},duplicateVFile:{vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0},folderId:{type:"String",array:!1,arrayRequired:!1,required:!1},customName:{type:"String",array:!1,arrayRequired:!1,required:!1}},logout:{sessionId:{type:"String",array:!1,arrayRequired:!1,required:!1}},moveFiles:{filesId:{type:"String",array:!0,arrayRequired:!0,required:!0},parentFolderId:{type:"String",array:!1,arrayRequired:!1,required:!1}},moveFolders:{foldersId:{type:"String",array:!0,arrayRequired:!0,required:!0},parentFolderId:{type:"String",array:!1,arrayRequired:!1,required:!1}},pay:{planCode:{type:"String",array:!1,arrayRequired:!1,required:!0},input:{type:"PayInput",array:!1,arrayRequired:!1,required:!0},autoRenew:{type:"Boolean",array:!1,arrayRequired:!1,required:!1}},readMail:{mailId:{type:"String",array:!1,arrayRequired:!1,required:!0}},recoverFolder:{id:{type:"String",array:!1,arrayRequired:!1,required:!0}},recoverMail:{mailId:{type:"String",array:!1,arrayRequired:!1,required:!0}},recoverVFile:{vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},saveInCloud:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0},key:{type:"String",array:!1,arrayRequired:!1,required:!0},folderId:{type:"String",array:!1,arrayRequired:!1,required:!1},filename:{type:"String",array:!1,arrayRequired:!1,required:!0},nameKey:{type:"String",array:!1,arrayRequired:!1,required:!0}},sendDraftMail:{draftMailId:{type:"String",array:!1,arrayRequired:!1,required:!0},temporaryRecipients:{type:"String",array:!0,arrayRequired:!0,required:!0},recipients:{type:"MailRecipientInput",array:!0,arrayRequired:!0,required:!0},customMessage:{type:"String",array:!1,arrayRequired:!1,required:!1}},sendOneMail:{mailIntegrityId:{type:"String",array:!1,arrayRequired:!1,required:!0},recipient:{type:"MailRecipientInput",array:!1,arrayRequired:!1,required:!0}},sendReport:{reportedUserId:{type:"String",array:!1,arrayRequired:!1,required:!0},customMessage:{type:"String",array:!1,arrayRequired:!1,required:!1}},shareFileInHistory:{input:{type:"ShareFileInHistoryInput",array:!1,arrayRequired:!1,required:!0},vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},shareFolder:{folderId:{type:"String",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!0}},shareFolderFinish:{shareFolders:{type:"ShareFoldersInput",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!0},rights:{type:"Rights",array:!1,arrayRequired:!1,required:!0}},shareVFile:{vFileId:{type:"String",array:!1,arrayRequired:!1,required:!0},userId:{type:"String",array:!1,arrayRequired:!1,required:!0},nameKey:{type:"String",array:!1,arrayRequired:!1,required:!0},rights:{type:"Rights",array:!1,arrayRequired:!1,required:!0},history:{type:"ShareFileKeyInput",array:!0,arrayRequired:!0,required:!0}},unreadMail:{mailId:{type:"String",array:!1,arrayRequired:!1,required:!0}},updateAppNotifications:{enableAll:{type:"Boolean",array:!1,arrayRequired:!1,required:!1},mail:{type:"Boolean",array:!1,arrayRequired:!1,required:!1},cloud:{type:"Boolean",array:!1,arrayRequired:!1,required:!1},disableAllUntil:{type:"DateTime",array:!1,arrayRequired:!1,required:!1}},updateAppSettings:{cloudFileDaysForDelete:{type:"Int",array:!1,arrayRequired:!1,required:!1},cloudFolderDaysForDelete:{type:"Int",array:!1,arrayRequired:!1,required:!1},historyFileDaysForDelete:{type:"Int",array:!1,arrayRequired:!1,required:!1},historyMaxFileCount:{type:"Int",array:!1,arrayRequired:!1,required:!1},autoDisconnectDelay:{type:"Int",array:!1,arrayRequired:!1,required:!1}},updateDraftMail:{draftId:{type:"String",array:!1,arrayRequired:!1,required:!0},hash:{type:"String",array:!1,arrayRequired:!1,required:!1},hashKey:{type:"String",array:!1,arrayRequired:!1,required:!1},body:{type:"String",array:!1,arrayRequired:!1,required:!1},subject:{type:"String",array:!1,arrayRequired:!1,required:!1},replyTo:{type:"String",array:!1,arrayRequired:!1,required:!1},senderFiles:{type:"MailFileInput",array:!0,arrayRequired:!1,required:!0},recipients:{type:"String",array:!0,arrayRequired:!1,required:!0}},updateFile:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0},isFavorite:{type:"Boolean",array:!1,arrayRequired:!1,required:!1},filename:{type:"String",array:!1,arrayRequired:!1,required:!1},deletedAt:{type:"DateTime",array:!1,arrayRequired:!1,required:!1}},updateFolder:{folderId:{type:"String",array:!1,arrayRequired:!1,required:!0},name:{type:"String",array:!1,arrayRequired:!1,required:!1},isFavorite:{type:"Boolean",array:!1,arrayRequired:!1,required:!1},deletedAt:{type:"DateTime",array:!1,arrayRequired:!1,required:!1}},updateProfile:{firstname:{type:"String",array:!1,arrayRequired:!1,required:!1},lastname:{type:"String",array:!1,arrayRequired:!1,required:!1},lang:{type:"Lang",array:!1,arrayRequired:!1,required:!1}},uploadAnonymous:{fileName:{type:"String",array:!1,arrayRequired:!1,required:!0},fileSize:{type:"Int",array:!1,arrayRequired:!1,required:!0},fileSizeBefore:{type:"Int",array:!1,arrayRequired:!1,required:!0},message:{type:"String",array:!1,arrayRequired:!1,required:!1},pubKey:{type:"String",array:!1,arrayRequired:!1,required:!0},token:{type:"String",array:!1,arrayRequired:!1,required:!0}},uploadFile:{fileSize:{type:"BigInt",array:!1,arrayRequired:!1,required:!0},fileSizeBefore:{type:"BigInt",array:!1,arrayRequired:!1,required:!0},fileKey:{type:"String",array:!1,arrayRequired:!1,required:!0},md5:{type:"String",array:!1,arrayRequired:!1,required:!0},md5Encrypted:{type:"String",array:!1,arrayRequired:!1,required:!0}},uploadFileEnd:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0}},uploadFilePartEnd:{fileId:{type:"String",array:!1,arrayRequired:!1,required:!0},md5:{type:"String",array:!1,arrayRequired:!1,required:!0},order:{type:"Int",array:!1,arrayRequired:!1,required:!0}},changeUserPlan:{userId:{type:"String",array:!1,arrayRequired:!1,required:!0},plan:{type:"PlanKind",array:!1,arrayRequired:!1,required:!0}}}},he={AppNotificationsResult:{"...on UserAppNotifications":"UserAppNotifications","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},BlogResult:{"...on BlogResponse":"BlogResponse","...on ErrorLangNotExist":"ErrorLangNotExist"},DbConfigResult:{"...on DbConfigResponse":"DbConfigResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist","...on ErrorNotFound":"ErrorNotFound"},DbGetResult:{"...on DbGetResponse":"DbGetResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound","...on ErrorNotExist":"ErrorNotExist"},DbSearchResult:{"...on DbSearchResponse":"DbSearchResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist","...on ErrorBasic":"ErrorBasic"},DeletedFoldersResult:{"...on DeletedFoldersResponse":"DeletedFoldersResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeletedMailsResult:{"...on DeletedMailsResponse":"DeletedMailsResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeletedVFilesResult:{"...on DeletedVFilesResponse":"DeletedVFilesResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},FaqResult:{"...on FaqResponse":"FaqResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},FileResult:{"...on FileQueryResponse":"FileQueryResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},FileContentResult:{"...on FileContentResponse":"FileContentResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},FolderResult:{"...on FolderResponse":"FolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},FolderSizeResult:{"...on FolderSizeResponse":"FolderSizeResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},FoldersSharedWithMeResult:{"...on FolderSharedWithMeResponse":"FolderSharedWithMeResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},LimitsResult:{"...on QueryLimits":"QueryLimits","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound","...on ErrorNotExist":"ErrorNotExist","...on ErrorLimit":"ErrorLimit"},MailResult:{"...on QueryMailResponse":"QueryMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},PaymentInfosResult:{"...on PaymentInfosResponse":"PaymentInfosResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},PlansResult:{"...on PlanResponse":"PlanResponse"},SharedFoldersResult:{"...on SharedFoldersResponse":"SharedFoldersResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},SharedVFilesResult:{"...on SharedVFilesResponse":"SharedVFilesResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},UnreadReceivedMailsCountResult:{"...on UnreadReceivedMailsCountResponse":"UnreadReceivedMailsCountResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},UserResult:{"...on UserResponse":"UserResponse","...on ErrorNotFound":"ErrorNotFound"},VFileResult:{"...on VFileResponse":"VFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},VFilesSharedWithMeResult:{"...on VFilesSharedWithMeResponse":"VFilesSharedWithMeResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},UserListResult:{"...on UserListResponse":"UserListResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},AddFileToHistoryResult:{"...on AddFileToHistoryResponse":"AddFileToHistoryResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},CancelPaymentResult:{"...on CancelPaymentResponse":"CancelPaymentResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},CreateApplicationResult:{"...on CreateApplicationResponse":"CreateApplicationResponse","...on ErrorNotExist":"ErrorNotExist"},CreateDraftMailResult:{"...on CreateDraftMailResponse":"CreateDraftMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},CreateFolderResult:{"...on CreateFolderResponse":"CreateFolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},DbConfigMutationResult:{"...on DbConfigMutationResponse":"DbConfigMutationResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DbSetResult:{"...on DbSetResponse":"DbSetResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},DeleteDraftMailResult:{"...on DeleteDraftMailResponse":"DeleteDraftMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteFileResult:{"...on DeleteFileResponse":"DeleteFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},DeleteFolderResult:{"...on DeleteFolderResponse":"DeleteFolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},DeleteFolderCloudTrashResult:{"...on DeleteFolderCloudTrashResponse":"DeleteFolderCloudTrashResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteFolderSharingResult:{"...on DeleteFolderSharingResponse":"DeleteFolderSharingResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteMailResult:{"...on DeleteMailResponse":"DeleteMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteMailTrashResult:{"...on DeleteMailTrashResponse":"DeleteMailTrashResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteUserResult:{"...on DeleteUserResponse":"DeleteUserResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteVFileResult:{"...on DeleteVFileResponse":"DeleteVFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},DeleteVFileCloudTrashResult:{"...on DeleteVFileCloudTrashResponse":"DeleteVFileCloudTrashResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},DeleteVFileSharingResult:{"...on DeleteVFileSharingResponse":"DeleteVFileSharingResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},DuplicateVFileResult:{"...on DuplicateVFileResponse":"DuplicateVFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},EmptyCloudTrashResult:{"...on DeleteMailResponse":"DeleteMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},EmptyMailTrashResult:{"...on EmptyMailTrashResponse":"EmptyMailTrashResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},LogoutResult:{"...on LogoutResponse":"LogoutResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},MoveFilesResult:{"...on MoveFilesResponse":"MoveFilesResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},MoveFoldersResult:{"...on MoveFoldersResponse":"MoveFoldersResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},PayResult:{"...on PayResponse":"PayResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},ReadMailResult:{"...on ReadMailResponse":"ReadMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic","...on ErrorNotFound":"ErrorNotFound"},RecoverFolderResult:{"...on RecoverFolderResponse":"RecoverFolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},RecoverMailResult:{"...on RecoverMailResponse":"RecoverMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},RecoverVFileResult:{"...on RecoverVFileResponse":"RecoverVFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},SaveInCloudResult:{"...on SaveInCloudResponse":"SaveInCloudResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist","...on ErrorBasic":"ErrorBasic"},SendDraftMailResult:{"...on SendDraftMailResponse":"SendDraftMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},SendOneMailResult:{"...on RecoverFolderResponse":"RecoverFolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},SendReportResult:{"...on SendReportResponse":"SendReportResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},ShareFileInHistoryResult:{"...on ShareFileInHistoryResponse":"ShareFileInHistoryResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},ShareFolderResult:{"...on ShareFolderResponse":"ShareFolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},ShareFolderFinishResult:{"...on ShareFolderFinishResponse":"ShareFolderFinishResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},ShareVFileResult:{"...on ShareVFileResponse":"ShareVFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist","...on ErrorNotFound":"ErrorNotFound"},UnreadMailResult:{"...on UnreadMailResponse":"UnreadMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound","...on ErrorBasic":"ErrorBasic"},UpdateAppNotificationsResult:{"...on UpdateAppNotificationsResponse":"UpdateAppNotificationsResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},UpdateAppSettingsResult:{"...on UpdateAppSettingsResponse":"UpdateAppSettingsResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},UpdateDraftMailResult:{"...on UpdateDraftMailResponse":"UpdateDraftMailResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic"},UpdateFileResult:{"...on UpdateFileResponse":"UpdateFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist","...on ErrorBasic":"ErrorBasic"},UpdateFolderResult:{"...on UpdateFolderResponse":"UpdateFolderResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotExist":"ErrorNotExist"},UpdateProfileResult:{"...on UpdateProfileResponse":"UpdateProfileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},UploadFileResult:{"...on UploadFileResponse":"UploadFileResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound","...on ErrorLimit":"ErrorLimit"},UploadFileEndResult:{"...on UploadFileEndResponse":"UploadFileEndResponse","...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound"},UploadFilePartEndResult:{"...on UploadFilePartEndResponse":"UploadFilePartEndResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},ChangeUserPlanResult:{"...on ChangeUserPlanResponse":"ChangeUserPlanResponse","...on ErrorAccessDenied":"ErrorAccessDenied"},AppKeyPair:{pub:"String"},AppSession:{id:"ID",lastActivity:"DateTime",userAgent:"String",ip:"String",city:"String",country:"String",userSession:"UserSession",userApp:"ApplicationsOnUsers",createdAt:"DateTime"},Application:{id:"ID",name:"String"},ApplicationsOnUsers:{fakeUserId:"String",keyPair:"AppKeyPair",sessions:"AppSession",app:"Application",user:"User",folders:"FoldersOnUsersOnApplications",settings:"UserAppSettings"},Blog:{id:"ID",order:"Int",entries:"BlogEntry"},BlogEntry:{id:"ID",lang:"Lang",author:"String",body:"String",date:"DateTime",image:"String",summary:"String",title:"String"},BlogItem:{id:"String",blogId:"String",order:"Int",title:"String",body:"String",author:"String",image:"String",imageAlt:"String",summary:"String",date:"DateTime"},CloudLimits:{size:"BigInt",maxSize:"BigInt",count:"BigInt",maxCount:"BigInt"},Error:{"...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorNotFound":"ErrorNotFound","...on ErrorUpgradePlan":"ErrorUpgradePlan","...on ErrorLangNotExist":"ErrorLangNotExist","...on ErrorNotExist":"ErrorNotExist","...on ErrorLimit":"ErrorLimit","...on ErrorBasic":"ErrorBasic"},ErrorAccessDenied:{message:"String"},ErrorBase:{"...on ErrorAccessDenied":"ErrorAccessDenied","...on ErrorBasic":"ErrorBasic","...on ErrorLangNotExist":"ErrorLangNotExist","...on ErrorLimit":"ErrorLimit","...on ErrorNotExist":"ErrorNotExist","...on ErrorNotFound":"ErrorNotFound","...on ErrorUpgradePlan":"ErrorUpgradePlan",message:"String"},ErrorBasic:{message:"String"},ErrorLangNotExist:{message:"String"},ErrorLimit:{message:"String",field:"String"},ErrorNotExist:{message:"String",field:"String"},ErrorNotFound:{message:"String",field:"String"},ErrorUpgradePlan:{message:"String"},Faq:{id:"ID",order:"Int",entries:"FaqEntry"},FaqEntry:{id:"ID",lang:"Lang",question:"String",answer:"String",faq:"Faq"},FaqItem:{order:"Int",question:"String",answer:"String"},File:{id:"ID",size:"BigInt",sizeBefore:"BigInt",createdAt:"DateTime",vFiles:"VFile",vFilesCurrent:"VFile",users:"FilesOnUsersOnApplications",md5:"String",md5Encrypted:"String",deletedAt:"DateTime",userApp:"ApplicationsOnUsers",mails:"FilesOnMails",validatedAt:"DateTime",user:"FilesOnUsersOnApplications"},FileContent:{"...on FileContentCloud":"FileContentCloud","...on FileContentReceivedMail":"FileContentReceivedMail","...on FileContentSentMail":"FileContentSentMail"},FileContentBase:{"...on FileContentCloud":"FileContentCloud","...on FileContentReceivedMail":"FileContentReceivedMail","...on FileContentSentMail":"FileContentSentMail",parts:"FileContentPart",key:"String",md5:"String",md5Encrypted:"String",totalSize:"BigInt",type:"FileContentType"},FileContentCloud:{parts:"FileContentPart",key:"String",md5:"String",md5Encrypted:"String",totalSize:"BigInt",type:"FileContentType",publicKey:"String"},FileContentPart:{contentUrl:"String",order:"Int",md5:"String"},FileContentReceivedMail:{parts:"FileContentPart",key:"String",md5:"String",md5Encrypted:"String",totalSize:"BigInt",type:"FileContentType",senderPublicKey:"String"},FileContentSentMail:{parts:"FileContentPart",key:"String",md5:"String",md5Encrypted:"String",totalSize:"BigInt",type:"FileContentType"},FilePart:{id:"ID",file:"File",fileId:"String",size:"BigInt",order:"Int",md5:"String",validatedAt:"DateTime"},FilePartResponse:{fields:"Json",url:"String",order:"Int"},FileResponse:{fileId:"String",parts:"FilePartResponse",filePartSize:"BigInt"},FileShared:{userId:"String",message:"String",appId:"String",id:"String",filename:"String",size:"Int",sizeBefore:"Int"},FileSharedContent:{ownerId:"String",pubKey:"String",message:"String",appId:"String",id:"String",type:"String",filename:"String",contentUrl:"String",key:"String",size:"Int",sizeBefore:"Int"},FilesOnMails:{file:"File",fileKey:"String",filename:"String",mail:"Mail"},FilesOnUsersOnApplications:{file:"File",userApp:"ApplicationsOnUsers",key:"String"},Folder:{id:"ID",isFavorite:"Boolean",createdAt:"DateTime",deletedAt:"DateTime",updatedAt:"DateTime",createdBy:"ApplicationsOnUsers",userApps:"FoldersOnUsersOnApplications",userApp:"FoldersOnUsersOnApplications",name:"String",parentFolder:"Folder",subfolders:"Folder",vFiles:"VFile",breadcrumb:"FolderBreadcrumbItem"},FolderBreadcrumbItem:{id:"String",name:"String",pubKey:"String",nameKey:"String"},FolderSize:{size:"BigInt",sizeBefore:"BigInt"},FoldersOnUsersOnApplications:{folder:"Folder",userApp:"ApplicationsOnUsers",rights:"Rights",nameKey:"String",isRoot:"Boolean"},Limits:{downloadBandwidth:"BigInt",downloadCount:"BigInt",hardFileCount:"BigInt",hardFileSize:"BigInt",perFileSize:"BigInt",receivedMails:"MailLimits",sentMails:"MailLimits",uploadBandwidth:"BigInt",uploadCount:"BigInt"},MailLimits:{count:"BigInt",fileCount:"BigInt",fileSize:"BigInt",hardCount:"BigInt",hardFileCount:"BigInt",hardFileSize:"BigInt",perFileSize:"BigInt"},MailLimitsValues:{count:"BigInt",maxCount:"BigInt",fileCount:"BigInt",maxFileCount:"BigInt",fileSize:"BigInt",maxFileSize:"BigInt"},QueryLimits:{cloud:"CloudLimits",mail:"UserMailLimits"},UserMailLimits:{sent:"MailLimitsValues",received:"MailLimitsValues"},Mail:{id:"ID",app:"Application",body:"String",createdAt:"DateTime",deletedAt:"DateTime",files:"FilesOnMails",mailIntegrity:"MailIntegrity",mailIntegrityDraft:"MailIntegrityDraft",openedAt:"DateTime",recipient:"User",sender:"User",subject:"String",type:"MailType",recipients:"User"},MailIntegrity:{id:"ID",hash:"String",hashKey:"String",answers:"MailIntegrity",app:"Application",mails:"Mail",recipients:"User",temporaryRecipients:"TemporaryUser",replyTo:"MailIntegrity"},MailIntegrityDraft:{id:"ID",hash:"String",hashKey:"String",app:"Application",mail:"Mail",recipients:"User",temporaryRecipients:"TemporaryUser",replyTo:"MailIntegrity"},Plan:{id:"ID",kind:"PlanKind",codes:"String",limits:"Limits"},Report:{id:"ID",user:"User",reportedUser:"User",customMessage:"String"},AddFileToHistoryResponse:{addFileToHistory:"VFile"},CancelPaymentResponse:{cancelPayment:"Boolean"},ChangeUserPlanResponse:{changeUserPlan:"User"},CreateApplicationResponse:{createApplication:"String"},CreateDraftMailResponse:{createDraftMail:"Mail"},CreateFolderResponse:{createFolder:"Folder"},DbConfigMutationResponse:{dbConfigMutation:"Json"},DbSetResponse:{dbSet:"Json"},DeleteDraftMailResponse:{deleteDraftMail:"Boolean"},DeleteFileResponse:{deleteFile:"Boolean"},DeleteFolderResponse:{deleteFolder:"Boolean"},DeleteFolderCloudTrashResponse:{deleteFolderCloudTrash:"Boolean"},DeleteFolderSharingResponse:{deleteFolderSharing:"Boolean"},DeleteMailResponse:{deleteMail:"Boolean"},DeleteMailTrashResponse:{deleteMailTrash:"Boolean"},DeleteUserResponse:{deleteUser:"Boolean"},DeleteVFileResponse:{deleteVFile:"Boolean"},DeleteVFileCloudTrashResponse:{deleteVFileCloudTrash:"Boolean"},DeleteVFileSharingResponse:{deleteVFileSharing:"Boolean"},DuplicateVFileResponse:{duplicateVFile:"Boolean"},EmptyCloudTrashResponse:{emptyCloudTrash:"Boolean"},EmptyMailTrashResponse:{emptyMailTrash:"Boolean"},LogoutResponse:{logout:"Boolean"},MoveFilesResponse:{moveFiles:"Boolean"},MoveFoldersResponse:{moveFolders:"Boolean"},PayResponse:{pay:"Boolean"},ReadMailResponse:{readMail:"Boolean"},RecoverFolderResponse:{recoverFolder:"Boolean"},RecoverMailResponse:{recoverMail:"Boolean"},RecoverVFileResponse:{recoverVFile:"Boolean"},SaveInCloudResponse:{saveInCloud:"VFile"},SendDraftMailResponse:{sendDraftMail:"Boolean"},SendOneMailResponse:{sendOneMail:"Boolean"},SendReportResponse:{sendReport:"Report"},ShareFileInHistoryResponse:{shareFileInHistory:"Boolean"},ShareFolderFinishResponse:{shareFolderFinish:"Boolean"},ShareVFileResponse:{shareVFile:"Boolean"},UnreadMailResponse:{unreadMail:"Boolean"},UpdateAppNotificationsResponse:{updateAppNotifications:"UserAppNotifications"},UpdateAppSettingsResponse:{updateAppSettings:"UserAppSettings"},UpdateDraftMailResponse:{updateDraftMail:"Mail"},UpdateFileResponse:{updateFile:"VFile"},UpdateFolderResponse:{updateFolder:"Folder"},UpdateProfileResponse:{updateProfile:"User"},UploadAnonymousResponse:{uploadAnonymous:"FileResponse"},UploadFileResponse:{uploadFile:"FileResponse"},UploadFileEndResponse:{uploadFileEnd:"String"},UploadFilePartEndResponse:{uploadFilePartEnd:"Boolean"},BlogResponse:{blogItems:"BlogItem"},DbConfigResponse:{json:"Json"},DbGetResponse:{json:"Json"},DbSearchResponse:{json:"Json"},DeletedFoldersResponse:{deletedFolders:"Folder"},DeletedMailsResponse:{deletedMails:"Mail"},DeletedVFilesResponse:{deletedVFiles:"VFile"},FaqResponse:{faq:"FaqItem"},FileQueryResponse:{file:"File"},FileContentResponse:{file:"FileContent"},FolderResponse:{folder:"Folder"},FolderSharedWithMeResponse:{foldersSharedWithMe:"Folder"},FolderSizeResponse:{size:"BigInt",sizeBefore:"BigInt"},QueryMailResponse:{mail:"Mail"},PaymentInfosResponse:{paymentInfos:"PaymentInfos"},PlanResponse:{plan:"Plan"},SharedFoldersResponse:{sharedFolders:"Folder"},SharedVFilesResponse:{sharedVFiles:"VFile"},UnreadReceivedMailsCountResponse:{count:"Int"},UserResponse:{user:"User"},UserListResponse:{userList:"User"},VFileResponse:{vFile:"VFile"},VFilesSharedWithMeResponse:{vFilesSharedWithMe:"VFile"},TemporaryUser:{id:"ID",mails:"MailIntegrity",draftMails:"MailIntegrityDraft",email:"String"},User:{id:"ID",deletedAt:"DateTime",lang:"Lang",reportSent:"Report",godFather:"User",godChildren:"User",firstname:"String",lastname:"String",email:"String",phone:"String",lastLogin:"DateTime",role:"UserRole",sessions:"UserSession",createdAt:"DateTime",receivedMails:"Mail",waitingReceivedMails:"WaitingReceivedMail",sentMails:"Mail",draftMails:"Mail",appSettings:"UserAppSettings",applications:"ApplicationsOnUsers",publicKey:"String"},UserAppNotifications:{id:"ID",enableAll:"Boolean",mail:"Boolean",cloud:"Boolean",disableAllUntil:"DateTime"},UserAppSettings:{id:"ID",cloudFileDaysForDelete:"Int",cloudFolderDaysForDelete:"Int",historyFileDaysForDelete:"Int",historyMaxFileCount:"Int",autoDisconnectDelay:"Int"},UserSession:{id:"ID",appSessions:"AppSession",lastActivity:"DateTime",userAgent:"String",ip:"String",city:"String",country:"String",createdAt:"DateTime"},VFile:{id:"ID",isFavorite:"Boolean",createdAt:"DateTime",deletedAt:"DateTime",filename:"String",userApps:"VFilesOnUsersOnApplications",createdBy:"ApplicationsOnUsers",userApp:"VFilesOnUsersOnApplications",folder:"Folder",history:"File",current:"File",updatedAt:"DateTime"},VFilesOnUsersOnApplications:{vFile:"VFile",userApp:"ApplicationsOnUsers",rights:"Rights",nameKey:"String",isRoot:"Boolean"},WaitingReceivedMail:{sender:"User",date:"DateTime",recipients:"User",temporaryRecipients:"TemporaryUser",attachmentsCount:"Int"},PaymentInfos:{hostedUrl:"String",currentSubscription:"RecurlySubscription",invoices:"RecurlyInvoices"},RecurlyInvoices:{pdf:"String",date:"DateTime",due:"DateTime",status:"String",total:"Int",name:"String",currency:"String"},RecurlySubscription:{autorenew:"Boolean",activatedAt:"DateTime",currentPeriodEndsAt:"DateTime",currentPeriodStartedAt:"DateTime",canceledAt:"DateTime",createdAt:"DateTime",expiresAt:"DateTime",pausedAt:"DateTime",trialEndsAt:"DateTime",trialStartedAt:"DateTime",updatedAt:"DateTime",state:"String",collectionMethod:"String",plan:"String",planCode:"String",total:"Int"},ShareFolderResponse:{folders:"String",vFiles:"String"},Query:{appNotifications:"AppNotificationsResult",blog:"BlogResult",dbConfig:"DbConfigResult",dbGet:"DbGetResult",dbSearch:"DbSearchResult",deletedFolders:"DeletedFoldersResult",deletedMails:"DeletedMailsResult",deletedVFiles:"DeletedVFilesResult",faq:"FaqResult",file:"FileResult",fileContent:"FileContentResult",filesSharedWithMe:"FileSharedContent",folder:"FolderResult",folderSize:"FolderSizeResult",foldersSharedWithMe:"FoldersSharedWithMeResult",limits:"LimitsResult",mail:"MailResult",paymentInfos:"PaymentInfosResult",plans:"PlansResult",sharedFolders:"SharedFoldersResult",sharedVFiles:"SharedVFilesResult",test:"Boolean",unreadReceivedMailsCount:"UnreadReceivedMailsCountResult",user:"UserResult",vFile:"VFileResult",vFilesSharedWithMe:"VFilesSharedWithMeResult",userList:"UserListResult"},Mutation:{addFileToHistory:"AddFileToHistoryResult",cancelPayment:"CancelPaymentResult",createApplication:"CreateApplicationResult",createDraftMail:"CreateDraftMailResult",createFolder:"CreateFolderResult",dbConfigMutation:"DbConfigMutationResult",dbSet:"DbSetResult",deleteDraftMail:"DeleteDraftMailResult",deleteFile:"DeleteFileResult",deleteFolder:"DeleteFolderResult",deleteFolderCloudTrash:"DeleteFolderCloudTrashResult",deleteFolderSharing:"DeleteFolderSharingResult",deleteMail:"DeleteMailResult",deleteMailTrash:"DeleteMailTrashResult",deleteUser:"DeleteUserResult",deleteVFile:"DeleteVFileResult",deleteVFileCloudTrash:"DeleteVFileCloudTrashResult",deleteVFileSharing:"DeleteVFileSharingResult",duplicateVFile:"DuplicateVFileResult",emptyCloudTrash:"EmptyCloudTrashResult",emptyMailTrash:"EmptyMailTrashResult",logout:"LogoutResult",moveFiles:"MoveFilesResult",moveFolders:"MoveFoldersResult",pay:"PayResult",readMail:"ReadMailResult",recoverFolder:"RecoverFolderResult",recoverMail:"RecoverMailResult",recoverVFile:"RecoverVFileResult",saveInCloud:"SaveInCloudResult",sendDraftMail:"SendDraftMailResult",sendOneMail:"SendOneMailResult",sendReport:"SendReportResult",shareFileInHistory:"ShareFileInHistoryResult",shareFolder:"ShareFolderResult",shareFolderFinish:"ShareFolderFinishResult",shareVFile:"ShareVFileResult",unreadMail:"UnreadMailResult",updateAppNotifications:"UpdateAppNotificationsResult",updateAppSettings:"UpdateAppSettingsResult",updateDraftMail:"UpdateDraftMailResult",updateFile:"UpdateFileResult",updateFolder:"UpdateFolderResult",updateProfile:"UpdateProfileResult",uploadAnonymous:"FileResponse",uploadFile:"UploadFileResult",uploadFileEnd:"UploadFileEndResult",uploadFilePartEnd:"UploadFilePartEndResult",changeUserPlan:"ChangeUserPlanResult"},Subscription:{test:"Boolean"}};var Pe=(R=>(R.fr="fr",R.en="en",R.it="it",R.de="de",R.pt="pt",R.ja="ja",R.es="es",R.nl="nl",R.pl="pl",R.ru="ru",R.zh="zh",R.ar="ar",R.he="he",R.hi="hi",R.ko="ko",R))(Pe||{}),ve=(n=>(n.free="free",n.basic="basic",n.advanced="advanced",n.pro="pro",n))(ve||{}),Qe=(r=>(r.user="user",r.admin="admin",r))(Qe||{}),Ge=(r=>(r.sent="sent",r.received="received",r))(Ge||{}),Ne=(s=>(s.admin="admin",s.write="write",s.read="read",s))(Ne||{}),Be=(s=>(s.cloud="cloud",s.sent_mail="sent_mail",s.received_mail="received_mail",s))(Be||{}),we=(r=>(r.secure="secure",r.classic="classic",r))(we||{}),z=class extends Error{constructor(e){super("");this.response=e;console.error(e)}toString(){return"GraphQL Response Error"}},ur=()=>t=>t,xe=(t,e)=>{switch(t){case"String":return`${JSON.stringify(e)}`;case"Int":return`${e}`;case"Float":return`${e}`;case"Boolean":return`${e}`;case"ID":return`"${e}"`;case"enum":return`${e}`;case"scalar":return`${e}`;default:return!1}},le=({value:t,type:e,name:r,key:s,blockArrays:n})=>{if(t===null)return"null";let o=ae[e][r];if(s&&(o=o[s]),!o)throw new Error(`Cannot resolve ${e} ${r}${s?` ${s}`:""}`);let i=o.type,a=o.array,p=o.arrayRequired;if(typeof t=="string"&&t.startsWith("ZEUS_VAR$")){let F=o.required?"!":"",m=`${i}`;return a?(F&&(m=`${m}!`),m=`[${m}]`,p&&(m=`${m}!`)):F&&(m=`${m}!`),`$${t.split("ZEUS_VAR$")[1]}__ZEUS_VAR__${m}`}if(a&&!n)return`[${t.map(F=>le({value:F,type:e,name:r,key:s,blockArrays:!0})).join(",")}]`;let d=xe(i,t);if(!d){let F=ae[i];return typeof F=="object"?`{${Object.keys(F).filter(u=>t[u]!==void 0).map(u=>`${u}:${le({value:t[u],type:i,name:u})}`)}}`:xe(ae[i],t)}return d},yr=(t,e)=>{let[r,s]=e,[n,o,...i]=t,a=Object.keys(r).filter(m=>typeof r[m]<"u");if(!i.length)return a.length>0?`(${a.map(m=>`${m}:${le({value:r[m],type:n,name:o,key:m})}`).join(",")})${s?w(t,s):""}`:w(t,s);let[p]=i.splice(i.length-1,1),d=he[n][o];for(let m of i)d=he[d][m];return a.length>0?`(${a.map(m=>`${m}:${le({value:r[m],type:d,name:p,key:m})}`).join(",")})${s?w(t,s):""}`:w(t,s)},cr=(t,e)=>typeof e=="boolean"?t:typeof e=="object"?`${t}{${qe(e)}}`:`${t}${e}`,qe=t=>`{${Object.keys(t).map(e=>`${cr(e,t[e])}`).join(" ")}}`,w=(t,e)=>{if(!e||Object.keys(e).length===0)return"";let r={};if(Array.isArray(e))return yr([...t],e);if(typeof e=="object")Object.keys(e).filter(s=>typeof e[s]<"u").forEach(s=>{s==="__alias"?Object.keys(e[s]).forEach(n=>{let o=e[s][n],i=Object.keys(o)[0],a=o[i];r[`${i}__alias__${n}: ${i}`]=w([...t,i],a)}):r[s]=w([...t,s],e[s])});else return"";return qe(r)},mr=(t,e)=>w([t],e),fr=t=>{let e=/\$\b\w*__ZEUS_VAR__\[?[^!^\]^\s^,^\)^\}]*[!]?[\]]?[!]?/g,r,s=[];for(;r=e.exec(t);)s.includes(r[0])||s.push(r[0]);if(!s.length)return t;let n=t;return s.forEach(o=>{for(;n.includes(o);)n=n.replace(o,o.split("__ZEUS_VAR__")[0])}),`(${s.map(o=>o.split("__ZEUS_VAR__")).map(([o,i])=>`${o}:${i}`).join(", ")})${n}`},Fr=(t,e,r)=>s=>`${t.toLowerCase()}${r?" "+r:""}${fr(mr(e,s))}`,Rr=t=>(e,r)=>(s,n)=>t(Fr(e,r,n?.operationName)(s),n?.variables).then(o=>(_e(o),o));var _e=t=>{let e=r=>{Array.isArray(r)?r.forEach(_e):typeof r=="object"&&_e(r)};if(typeof t=="object"&&t){let r=Object.keys(t);if(r.length<1)return;r.forEach(s=>{let n=t[s];if(s.indexOf("__alias__")!==-1){let[o,i]=s.split("__alias__");t[i]={[o]:n},delete t[s]}e(n)})}};var Ce=t=>t.ok?t.json():new Promise((e,r)=>{t.text().then(s=>{try{r(JSON.parse(s))}catch{r(s)}}).catch(r)}),hr=t=>(e,r={})=>{let s=fetch,n=e,o=t[1]||{};return o.method&&o.method==="GET"?(n=encodeURIComponent(e),s(`${t[0]}?query=${n}`,o).then(Ce).then(i=>{if(i.errors)throw new z(i);return i.data})):s(`${t[0]}`,{body:JSON.stringify({query:n,variables:r}),method:"POST",headers:{"Content-Type":"application/json"},...o}).then(Ce).then(i=>{if(i.errors)throw new z(i);return i.data})};var _r={query:"Query",mutation:"Mutation",subscription:"Subscription"},Te=t=>e=>(r,s)=>Rr(t)(e,_r[e])(r,s),Tr=(...t)=>Te(hr(t));var Ke=t=>ur(),es=Tr("http://localhost:4000/graphql");var Oe=t=>t.ok?t.json():new Promise((e,r)=>{t.text().then(s=>{try{r(JSON.parse(s))}catch{r(s)}}).catch(r)}),gr=(t,e)=>async(r,s={})=>{let n=fetch,o=r,i=t[1]||{};if(i.method&&i.method==="GET")return o=encodeURIComponent(r),n(`${t[0]}?query=${o}`,i).then(Oe).then(m=>{if(m.errors)throw new z(m);return m.data});let a={"content-type":"application/json","accept-language":navigator.language};e&&(a["secrecy-session"]=e);let p=new AbortController,d=setTimeout(()=>p.abort(),2e4),F=await n(`${t[0]}`,{body:JSON.stringify({query:o,variables:s}),method:"POST",headers:a,signal:p.signal,...i}).then(Oe).then(m=>{if(m.errors)throw new z(m);return m.data});return clearTimeout(d),F},ke=(t,e)=>Te(gr([t,{mode:"cors",credentials:"same-origin"}],e));function Dr(t){return{...t,currentSubscription:{...t.currentSubscription,state:t.currentSubscription.state,collectionMethod:t.currentSubscription.collectionMethod,activatedAt:t.currentSubscription.activatedAt?new Date(t.currentSubscription.activatedAt):null,createdAt:t.currentSubscription.createdAt?new Date(t.currentSubscription.createdAt):null,updatedAt:t.currentSubscription.updatedAt?new Date(t.currentSubscription.updatedAt):null,trialEndsAt:t.currentSubscription.trialEndsAt?new Date(t.currentSubscription.trialEndsAt):null,trialStartedAt:t.currentSubscription.trialStartedAt?new Date(t.currentSubscription.trialStartedAt):null,pausedAt:t.currentSubscription.pausedAt?new Date(t.currentSubscription.pausedAt):null,currentPeriodEndsAt:t.currentSubscription.currentPeriodEndsAt?new Date(t.currentSubscription.currentPeriodEndsAt):null,currentPeriodStartedAt:t.currentSubscription.currentPeriodStartedAt?new Date(t.currentSubscription.currentPeriodStartedAt):null,canceledAt:t.currentSubscription.canceledAt?new Date(t.currentSubscription.canceledAt):null,expiresAt:t.currentSubscription.expiresAt?new Date(t.currentSubscription.expiresAt):null},invoices:t.invoices.map(e=>({...e,date:new Date(e.date),due:new Date(e.due),status:e.status}))}}var Mr=["basic_month","advanced_month","pro_month","basic_year","advanced_year","pro_year"];function Sr(t){return Mr.includes(t)}var br=(t,e)=>{let{user:r}=Ke("Query")({user:[{userId:t},{"...on ErrorNotFound":{__typename:!0,message:!0,field:!0},"...on UserResponse":{__typename:!0,user:{id:!0,firstname:!0,lastname:!0,lang:!0,publicKey:e?!0:void 0,email:!0,phone:!0,role:!0,deletedAt:!0,lastLogin:!0}}}]});return r};async function ze(t){let e=br(t.userId,t.withPublicKey),{user:r}=await t.client("query")({user:e});return r?r.__typename==="ErrorNotFound"?r:r.user?{__typename:"SuccessResponse",data:{...r.user,lastLogin:new Date(r.user.lastLogin),deletedAt:r.user.deletedAt?new Date(r.user.deletedAt):null}}:null:null}var C=class{constructor(e,r){this.sessionId=e,this.client=C._getBaseClient(r,e)}async sessions(){let e=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,field:!0,message:!0},"...on UserResponse":{__typename:!0,user:{sessions:{id:!0,lastActivity:!0,userAgent:!0,ip:!0,city:!0,country:!0,appSessions:{id:!0,lastActivity:!0,userAgent:!0,ip:!0,city:!0,country:!0,userApp:{app:{name:!0}}}}}}}]});if(!e.user)return null;let r=e.user;if(r.__typename==="UserResponse"){if(!r.user)return null;let s=r.user.sessions.map(n=>({id:n.id,ip:n.ip,city:n.city,country:n.country,lastActivity:n.lastActivity?new Date(n.lastActivity):void 0,userAgent:n.userAgent,appSessions:n.appSessions.map(o=>({id:o.id,ip:o.ip,city:o.city,country:o.country,lastActivity:o.lastActivity?new Date(o.lastActivity):void 0,userAgent:o.userAgent,app:o.userApp?.app.name??""}))}))??[];return{__typename:"SuccessResponse",data:s}}return r}async logout(e){if(!e){let r=k(!1),s=k(!0);r.jwt.clear(),r.userAppKeys.clear(),r.userAppSession.clear(),s.jwt.clear(),s.userAppKeys.clear(),s.userAppSession.clear(),K.clear()}try{await this.client("mutation")({logout:[{sessionId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on LogoutResponse":{__typename:!0,logout:!0}}]})}catch{}}async me(e){return this.user(e||{withPublicKey:!0})}static async user(e,r){let s=await ze({client:this._getBaseClient(e.env,r),userId:e.userId,withPublicKey:e.withPublicKey});return s?(s.__typename==="ErrorNotFound"||s&&K.set(s.data.id,s.data),s):null}async user(e){let r=await ze({client:this.client,userId:e.userId,withPublicKey:e.withPublicKey});return r?(r.__typename==="ErrorNotFound"||r&&K.set(r.data.id,r.data),r):null}async updateProfile({firstname:e,lastname:r,lang:s}){let{updateProfile:n}=await this.client("mutation")({updateProfile:[{firstname:e,lastname:r,lang:s},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on UpdateProfileResponse":{__typename:!0,updateProfile:{id:!0,firstname:!0,lastname:!0,lang:!0,email:!0,phone:!0,role:!0,deletedAt:!0,lastLogin:!0}}}]});return n?n.__typename==="ErrorAccessDenied"||n.__typename==="ErrorNotFound"?n:n.updateProfile?{__typename:"SuccessResponse",data:{email:n.updateProfile.email,firstname:n.updateProfile.firstname,id:n.updateProfile.id,lang:n.updateProfile.lang,lastLogin:new Date(n.updateProfile.lastLogin),lastname:n.updateProfile.lastname,phone:n.updateProfile.phone,role:n.updateProfile.role,deletedAt:n.updateProfile.deletedAt?new Date(n.updateProfile.deletedAt):null}}:null:null}static async plans(e,r){let{plans:s}=await C._getBaseClient(e,r)("query")({plans:{"...on PlanResponse":{__typename:!0,plan:{kind:!0,codes:!0,limits:{downloadBandwidth:!0,downloadCount:!0,hardFileCount:!0,hardFileSize:!0,perFileSize:!0,uploadBandwidth:!0,uploadCount:!0,receivedMails:{count:!0,fileCount:!0,fileSize:!0,hardCount:!0,hardFileCount:!0,hardFileSize:!0,perFileSize:!0},sentMails:{count:!0,fileCount:!0,fileSize:!0,hardCount:!0,hardFileCount:!0,hardFileSize:!0,perFileSize:!0}}}}}});return s?{__typename:"SuccessResponse",data:s.plan}:null}async pay(e,r,s){let{pay:n}=await this.client("mutation")({pay:[{input:r,planCode:e,autoRenew:s},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on PayResponse":{__typename:!0,pay:!0}}]});return n?n.__typename==="ErrorAccessDenied"?n:{__typename:"SuccessResponse",data:n.pay??!1}:null}async cancelPayment(){let{cancelPayment:e}=await this.client("mutation")({cancelPayment:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on CancelPaymentResponse":{__typename:!0,cancelPayment:!0}}});return e?e.__typename==="ErrorAccessDenied"?e:{__typename:"SuccessResponse",data:e.cancelPayment??!1}:null}async paymentInfos(){let{paymentInfos:e}=await this.client("query")({paymentInfos:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on PaymentInfosResponse":{__typename:!0,paymentInfos:{hostedUrl:!0,currentSubscription:{autorenew:!0,activatedAt:!0,currentPeriodEndsAt:!0,currentPeriodStartedAt:!0,canceledAt:!0,createdAt:!0,expiresAt:!0,pausedAt:!0,trialEndsAt:!0,trialStartedAt:!0,updatedAt:!0,state:!0,collectionMethod:!0,plan:!0,planCode:!0,total:!0},invoices:{pdf:!0,date:!0,due:!0,status:!0,total:!0,name:!0,currency:!0}}}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;if(!e.paymentInfos)return null;let r=Dr(e.paymentInfos);return{__typename:"SuccessResponse",data:r}}async limits(){let{limits:e}=await this.client("query")({limits:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorLimit":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on QueryLimits":{__typename:!0,cloud:{size:!0,maxSize:!0,count:!0,maxCount:!0},mail:{received:{count:!0,maxCount:!0,fileCount:!0,maxFileCount:!0,fileSize:!0,maxFileSize:!0},sent:{count:!0,maxCount:!0,fileCount:!0,maxFileCount:!0,fileSize:!0,maxFileSize:!0}}}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied"||e.__typename==="ErrorNotExist"||e.__typename==="ErrorLimit"||e.__typename==="ErrorNotFound")return e;let{cloud:r,mail:s}=e;return{__typename:"SuccessResponse",data:{cloud:{count:BigInt(r.count),size:BigInt(r.size),maxCount:r.maxCount?BigInt(r.maxCount):null,maxSize:r.maxSize?BigInt(r.maxSize):null},mail:{received:{count:BigInt(s.received.count),maxCount:s.received.maxCount?BigInt(s.received.maxCount):null,fileCount:BigInt(s.received.fileCount),maxFileCount:s.received.maxFileCount?BigInt(s.received.maxFileCount):null,fileSize:BigInt(s.received.fileSize),maxFileSize:s.received.maxFileSize?BigInt(s.received.maxFileSize):null},sent:{count:BigInt(s.sent.count),maxCount:s.sent.maxCount?BigInt(s.sent.maxCount):null,fileCount:BigInt(s.sent.fileCount),maxFileCount:s.sent.maxFileCount?BigInt(s.sent.maxFileCount):null,fileSize:BigInt(s.sent.fileSize),maxFileSize:s.sent.maxFileSize?BigInt(s.sent.maxFileSize):null}}}}}async godFatherAndChildren(){let{user:e}=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserResponse":{__typename:!0,godChildren:{id:!0,firstname:!0,lastname:!0,email:!0,phone:!0},godFather:{id:!0,firstname:!0,lastname:!0,email:!0,phone:!0}}}]});return e?e.__typename==="ErrorNotFound"?e:{__typename:"SuccessResponse",data:{godChildren:e.godChildren,godFather:e.godFather}}:null}static async updateAppDBConfig({appCode:e,config:r,env:s,sessionId:n}){let{dbConfigMutation:o}=await C._getBaseClient(s,n)("mutation")({dbConfigMutation:[{appCode:e,config:JSON.stringify(r)},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DbConfigMutationResponse":{__typename:!0,dbConfigMutation:!0}}]});return o?o.__typename==="ErrorAccessDenied"?o:{__typename:"SuccessResponse",data:o.dbConfigMutation}:null}static async getAppDBConfig(e,r,s){let{dbConfig:n}=await C._getBaseClient(r,s)("query")({dbConfig:[{appCode:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on DbConfigResponse":{__typename:!0,json:!0}}]});return n?n.__typename==="ErrorAccessDenied"||n.__typename==="ErrorNotFound"||n.__typename==="ErrorNotExist"?n:{__typename:"SuccessResponse",data:n.json}:null}static async getFAQ({lang:e,env:r,sessionId:s}){let{faq:n}=await C._getBaseClient(r,s)("query")({faq:[{lang:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on FaqResponse":{__typename:!0,faq:{answer:!0,order:!0,question:!0}}}]});return n?n.__typename==="ErrorAccessDenied"?n:{__typename:"SuccessResponse",data:n.faq}:null}static async getBlog({env:e,lang:r,sessionId:s}){let{blog:n}=await C._getBaseClient(e,s)("query")({blog:[{lang:r},{"...on ErrorLangNotExist":{__typename:!0,message:!0},"...on BlogResponse":{__typename:!0,blogItems:{id:!0,blogId:!0,author:!0,body:!0,date:!0,image:!0,imageAlt:!0,summary:!0,title:!0,order:!0}}}]});return n?n.__typename==="ErrorLangNotExist"?n:{__typename:"SuccessResponse",data:n.blogItems.map(o=>({...o,date:new Date(o.date)}))}:null}async reportUser(e,r){let{sendReport:s}=await this.client("mutation")({sendReport:[{reportedUserId:e,customMessage:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on SendReportResponse":{__typename:!0,sendReport:{id:!0,customMessage:!0,user:{id:!0,firstname:!0,lastname:!0,email:!0},reportedUser:{id:!0,firstname:!0,lastname:!0,email:!0}}}}]});return s?s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorNotFound"?s:s.sendReport?{__typename:"SuccessResponse",data:s.sendReport}:null:null}static async deleteUser({sessionId:e,userId:r,env:s}){let{deleteUser:n}=await C._getBaseClient(s,e)("mutation")({deleteUser:[{userId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteUserResponse":{__typename:!0,deleteUser:!0}}]});return n?n.__typename==="ErrorAccessDenied"?n:n.deleteUser?{__typename:"SuccessResponse",data:n.deleteUser}:null:null}async dbGet({field:e,userId:r}){let{dbGet:s}=await this.client("query")({dbGet:[{field:e,userId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on DbGetResponse":{__typename:!0,json:!0}}]});return s?s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorNotExist"||s.__typename==="ErrorNotFound"?s:{__typename:"SuccessResponse",data:s.json.res}:null}async dbSet({value:e,userId:r}){if(typeof e!="object")throw new Error("value should be an object including fields you want to update.");let{dbSet:s}=await this.client("mutation")({dbSet:[{userId:r,value:Er(e).toString("base64")},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on DbSetResponse":{__typename:!0,dbSet:!0}}]});return s?s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorNotFound"?s:s.dbSet?{__typename:"SuccessResponse",data:s.dbSet.res}:null:null}async dbSearch({search:e,field:r}){let{dbSearch:s}=await this.client("query")({dbSearch:[{search:e,field:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on DbSearchResponse":{__typename:!0,json:!0}}]});return s?s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorBasic"||s.__typename==="ErrorNotExist"?s:{__typename:"SuccessResponse",data:s.json}:null}async deleteFolder({id:e}){let{deleteFolder:r}=await this.client("mutation")({deleteFolder:[{id:e},{"...on ErrorNotExist":{__typename:!0,message:!0},"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteFolderResponse":{__typename:!0,deleteFolder:!0}}]});return r?r.__typename==="ErrorNotExist"||r.__typename==="ErrorAccessDenied"?r:{__typename:"SuccessResponse",data:r.deleteFolder??!1}:null}async moveFolders({foldersId:e,parentFolderId:r}){let{moveFolders:s}=await this.client("mutation")({moveFolders:[{foldersId:e,parentFolderId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on MoveFoldersResponse":{__typename:!0,moveFolders:!0}}]});return s?s.__typename==="ErrorAccessDenied"?s:{__typename:"SuccessResponse",data:s.moveFolders??!1}:null}async moveFiles({filesId:e,parentFolderId:r}){let{moveFiles:s}=await this.client("mutation")({moveFiles:[{filesId:e,parentFolderId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on MoveFilesResponse":{__typename:!0,moveFiles:!0}}]});return s?s.__typename==="ErrorAccessDenied"?s:{__typename:"SuccessResponse",data:s.moveFiles??!1}:null}async folderSize({folderId:e}){let{folderSize:r}=await this.client("query")({folderSize:[{folderId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on FolderSizeResponse":{__typename:!0,size:!0,sizeBefore:!0}}]});return r?r.__typename==="ErrorAccessDenied"?r:{__typename:"SuccessResponse",data:{size:BigInt(r.size),sizeBefore:BigInt(r.sizeBefore)}}:null}async getSponsorshipLink({backUrl:e}){let r=await this.me({withPublicKey:!1});return!r||r.__typename==="ErrorNotFound"?null:Ar({app:"auth",path:`/sign-up?gf=${btoa(r.data.email)}&au=${btoa(e)}`})}},v=C;v.getBaseUrl=(e="prod",r=!0)=>{let s=process.env.SECRECY_API_URL;if(s)return s;switch(e){case"prod":return r?"https://secrecy.graphcdn.app":"https://api.secrecy.me/graphql";case"dev":default:return"https://api.dev.secrecy.me/graphql"}},v._getBaseClient=(e,r)=>ke(C.getBaseUrl(e),r);import l from"libsodium-wrappers";async function ge(){await l.ready}import je from"spark-md5";function P(...t){let e=0;for(let n of t)e+=n.length;let r=new Uint8Array(e),s=0;for(let n of t)r.set(n,s),s+=n.length;return r}function*We(t){let e=0;for(let r of t)yield[e,r],e++}function*Z(t,e){for(let r=0;r<t.length;r+=e)yield t.slice(r,r+e)}var Ee=async(t,e)=>{let r=e.slice(0,t),s=e.slice(t),n=[],o=async(a,p,d)=>{n[p]=await a(),await d()},i=async()=>{let a=e.length-s.length,p=s.shift();p!==void 0&&await o(p,a,i)};return await Promise.all(r.map((a,p)=>o(a,p,i))),n};function W(t,e){if(!t)throw new Error(e)}function pe(){return l.crypto_secretstream_xchacha20poly1305_keygen()}function Vr(t){let e=!1,{state:r,header:s}=l.crypto_secretstream_xchacha20poly1305_init_push(t),n=(i,a)=>(W(e===!1,"state already destroyed"),l.crypto_secretstream_xchacha20poly1305_push(r,a,null,i));function o(){W(e===!1,"state already destroyed"),e=!0}return{encrypt:n,destroy:o,header:s}}function Lr(t,e){W(t.byteLength>=l.crypto_secretstream_xchacha20poly1305_HEADERBYTES,`header must be at least HEADERBYTES (${l.crypto_secretstream_xchacha20poly1305_HEADERBYTES}) long`),W(e.byteLength>=l.crypto_secretstream_xchacha20poly1305_KEYBYTES,`key must be at least KEYBYTES (${l.crypto_secretstream_xchacha20poly1305_KEYBYTES}) long`);let r=!1,s=l.crypto_secretstream_xchacha20poly1305_init_pull(t,e),n=i=>(W(r===!1,"state already destroyed"),l.crypto_secretstream_xchacha20poly1305_pull(s,i));function o(){W(r===!1,"state already destroyed"),r=!0}return{decrypt:n,destroy:o}}var j=8192;async function He(t,e,r,s){await ge();let{encrypt:n,destroy:o,header:i}=Vr(t),a=j+l.crypto_secretstream_xchacha20poly1305_ABYTES,p=Math.ceil(e.byteLength/j)*a+i.byteLength;r?.({percent:0,total:p,current:0});let d=new Uint8Array(p),F=new je.ArrayBuffer,m=new je.ArrayBuffer;d.set(i),F.append(i);let u=i.byteLength;r?.({percent:u/p,total:p,current:u});let h=u/p;for(let f of Z(e,j)){if(s?.signal.aborted)throw new Error("Encrypt aborted");m.append(f);let R=f.length<j?l.crypto_secretstream_xchacha20poly1305_TAG_FINAL:l.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE,T=n(R,f);F.append(T),d.set(T,u),u+=T.byteLength;let _=u/p;_>h+.01&&(r?.({percent:_,total:p,current:u}),h=_)}return o(),r?.({percent:1,total:u,current:u}),{data:d.slice(0,u),md5Encrypted:F.end(),md5:m.end()}}async function J(t,e,r,s){await ge();let n=e.slice(0,l.crypto_secretstream_xchacha20poly1305_HEADERBYTES);e=e.slice(l.crypto_secretstream_xchacha20poly1305_HEADERBYTES);let{decrypt:o,destroy:i}=Lr(n,t),a=j+l.crypto_secretstream_xchacha20poly1305_ABYTES,p=Math.ceil(e.byteLength/a)*j;r?.({percent:0,total:p,current:0});let d=new Uint8Array(p),F=0,m=F/p;for(let u of Z(e,a)){if(s?.signal.aborted)throw new Error("Decrypt aborted");let h=o(u);d.set(h.message,F),F+=h.message.byteLength;let f=F/p;f>m+.01&&(r?.({percent:f,total:p,current:F}),m=f)}return i(),r?.({percent:1,total:F,current:F}),d.slice(0,F)}var M=new Error("invalid source"),V=new Error("short buffer"),X=4,Ur=16,be=1<<Ur,de=be-1,$e=16,Ir=1<<$e,Ae=X*8-$e,xr=8+X;var De=-1640531535;function Cr(t,e){let r=t>>>16&65535,s=t&65535,n=e>>>16&65535,o=e&65535;return s*o+(r*o+s*n<<16>>>0)|0}var Me=Math.imul?Math.imul:Cr;function Se(t,e){return t[e+3]|t[e+2]<<8|t[e+1]<<16|t[e]<<24}function ee(t,e,r,s,n){for(let o=0;o<n;++o)t[r++]=e[s++]}function Ye(t){let e=t.length;if(e===0)return 0;let r=0,s=0;for(;;){let n=t[r]>>4,o=t[r]&15;if(++r===e)throw M;if(n>0){if(n===15){for(;t[r]===255;)if(n+=255,++r===e)throw M;if(n+=t[r],++r===e)throw M}if(s+=n,r+=n,r>=e)return s}if(r+=2,r>=e)throw M;let i=t[r-2]|t[r-1]<<8;if(s-i<0||i===0)throw M;if(o===15){for(;t[r]===255;)if(o+=255,++r===e)throw M;if(o+=t[r],++r===e)throw M}for(o+=4;o>=i;o-=i)s+=i;s+=o}}function Ze(t,e){let r=t.length,s=e.length;if(r===0)return 0;let n=0,o=0;for(;;){let i=t[n]>>4,a=t[n]&15;if(++n===r)throw M;if(i>0){if(i===15){for(;t[n]===255;)if(i+=255,++n===r)throw M;if(i+=t[n],++n===r)throw M}if(s-o<i||n+i>r)throw V;if(ee(e,t,o,n,i),o+=i,n+=i,n>=r)return o}if(n+=2,n>=r)throw M;let p=t[n-2]|t[n-1]<<8;if(o-p<0||p===0)throw M;if(a===15){for(;t[n]===255;)if(a+=255,++n===r)throw M;if(a+=t[n],++n===r)throw M}if(a+=4,s-o<=a)throw V;for(;a>=p;a-=p)ee(e,e,o,o-p,p),o+=p;ee(e,e,o,o-p,a),o+=a}}function Je(t){return t+(t/255|0)+16}function Xe(t,e,r){let s=t.length-xr,n=e.length;if(s<=0||n===0||r>=s)return 0;let o=0,i=0,a=new Uint32Array(Ir),p=new Uint32Array(be);for(;o<r;){let h=Me(Se(t,o),De)>>>Ae;p[o&de]=a[h],a[h]=++o}let d=o;for(;o<s-X;){let h=Me(Se(t,o),De)>>>Ae,f=0,R=0;for(let E=a[h]-1;E>0&&E>o-be;E=p[E&de]-1)if(t[E+f]===t[o+f]){for(let g=0;;++g)if(t[E+g]!==t[o+g]||o+g>s){f<g&&g>=X&&(f=g,R=o-E);break}}if(p[o&de]=a[h],a[h]=o+1,f===0){++o;continue}let T=o+1,_=o+f;for(;T<_;){let E=Me(Se(t,T),De)>>>Ae;p[T&de]=a[E],a[E]=++T}let D=o-d;if(o+=f,f-=X,f<15?e[i]=f:e[i]=15,D<15)e[i]|=D<<4;else{if(e[i]|=240,++i===n)throw V;let E=D-15;for(;E>=255;E-=255)if(e[i]=255,++i===n)throw V;e[i]=E&255}if(++i===n||i+D>=n||(ee(e,t,i,d,D),i+=D,d=o,i+=2,i>=n))throw V;if(e[i-2]=R,e[i-1]=R>>8,f>=15){for(f-=15;f>=255;f-=255)if(e[i]=255,++i===n)throw V;if(e[i]=f,++i===n)throw V}}if(d===0)return 0;let F=t.length-d;if(F<15)e[i]=F<<4;else{if(e[i]=240,++i===n)throw V;for(F-=15;F>=255;F-=255)if(e[i]=255,++i===n)throw V;e[i]=F}if(++i===n)throw V;let m=t.length-d,u=i+m;if(u>n)throw V;return u>=s?0:(ee(e,t,i,d,m),i+=m,i)}function er(t){if(t.byteLength>15e6)return P(new Uint8Array([0]),t);let e=new Uint8Array(Je(t.byteLength)),r=Xe(t,e,0);return r===0?P(new Uint8Array([0]),t):P(new Uint8Array([1]),e.slice(0,r))}function rr(t){let e=t.slice(1);if(t[0]===0)return e;let r=new Uint8Array(Ye(e)),s=Ze(e,r);return r.slice(0,s)}function A(t,e,r){let s=l.randombytes_buf(l.crypto_box_NONCEBYTES),n=l.crypto_box_easy(t,s,l.from_hex(e),l.from_hex(r));return P(s,n)}function Ds(){return l.crypto_box_keypair("hex")}function S(t,e,r){let s=t.slice(0,l.crypto_box_NONCEBYTES),n=t.slice(l.crypto_box_NONCEBYTES);return l.crypto_box_open_easy(n,s,l.from_hex(e),l.from_hex(r))}function Ms(){return l.randombytes_buf(l.crypto_secretbox_KEYBYTES,"hex")}function Ss(t,e){let r=l.randombytes_buf(l.crypto_secretbox_NONCEBYTES),s=l.crypto_secretbox_easy(t,r,l.from_hex(e));return P(r,s)}function bs(t,e){let r=t.slice(0,l.crypto_secretbox_NONCEBYTES),s=t.slice(l.crypto_secretbox_NONCEBYTES);return l.crypto_secretbox_open_easy(s,r,l.from_hex(e))}function Vs(t,e){return l.crypto_box_seal(t,l.from_hex(e))}function Ls(t,{privateKey:e,publicKey:r}){return l.crypto_box_seal_open(t,l.from_hex(r),l.from_hex(e))}function ue(t,e){let r={...t,createdAt:new Date(t.createdAt),size:BigInt(t.size),sizeBefore:BigInt(t.sizeBefore),user:null};return t.user?.userApp.keyPair&&(r.user={...t.user,key:l.to_hex(S(l.from_hex(t.user.key),t.user.userApp.keyPair.pub,e.privateKey))}),I.set(r.id,r),r}function ye(t){let e={...t};return delete e.user,e}function sr(t,e){return ye(ue(t,e))}async function re(t,e){if(!t.current)throw`VFile ${t.id} doesn't have current file`;if(!t.userApp)throw`VFile ${t.id} doesn't have userApp`;let r=S(l.from_hex(t.userApp.nameKey),t.createdBy.user.publicKey,e.privateKey),s={...t,createdBy:t.createdBy.user,filename:l.to_string(await J(r,l.from_hex(t.filename))),userApp:{userApp:t.userApp.userApp,rights:t.userApp.rights,isRoot:t.userApp.isRoot,nameKey:l.to_hex(r)},users:t.userApps.map(n=>[n.userApp.user,n.rights]),createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),deletedAt:t.deletedAt?new Date(t.deletedAt):null,current:ue(t.current,e),history:t.history.map(n=>ue(n,e))};if("folder"in t){let n={...s,folder:await H(t.folder,e)};return U.set(s.id,n),n}return delete s.userApps,U.set(s.id,s),s}function se(t){let e={...t,current:ye(t.current),history:t.history.map(ye)};return delete e.nameKey,"folder"in t?{...t,folder:$(t.folder)}:e}async function q(t,e){return se(await re(t,e))}async function H(t,e){if(!t.userApp)throw`Can't access folder ${t.id}`;let r={id:t.id,userApp:t.userApp,name:t.name,isFavorite:t.isFavorite,breadcrumb:t.breadcrumb,createdBy:t.createdBy.user,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),deletedAt:t.deletedAt?new Date(t.deletedAt):null,users:t.userApps.map(s=>[s.userApp.user,s.rights])};if(r.userApp={...t.userApp},t.userApp.nameKey){let s=S(l.from_hex(t.userApp.nameKey),t.createdBy.user.publicKey,e.privateKey);r.name=l.to_string(await J(s,l.from_hex(r.name))),r.userApp.nameKey=l.to_hex(s)}for(let s of r.breadcrumb){if(!s.nameKey)continue;let n=S(l.from_hex(s.nameKey),s.pubKey,e.privateKey);s.nameKey=l.to_hex(n),s.name=l.to_string(await J(n,l.from_hex(s.name)))}return x.set(r.id,r),r}async function Pr(t,e){return{...await H(t,e),vFiles:await Promise.all(t.vFiles.filter(s=>s.userApp).map(s=>re(s,e))),parentFolder:t.parentFolder?await H(t.parentFolder,e):null,subfolders:await Promise.all(t.subfolders.map(s=>H(s,e)))}}function $(t){let e={...t};for(let r of e.breadcrumb)delete r.nameKey;return delete e.nameKey,e}function vr(t){return{...$(t),vFiles:t.vFiles.map(se),parentFolder:t.parentFolder?$(t.parentFolder):null,subfolders:t.subfolders.map($)}}async function ce(t,e){return vr(await Pr(t,e))}async function me(t,e){return $(await H(t,e))}import{generate as Nr}from"shortid";var Ve=`let sodium;
2
-
3
- self.sodium = {
4
- onload: (sod) => {
5
- sodium = sod
6
- postMessage({ event: "ready" })
7
- }
8
- };
9
-
10
- importScripts('https://cdn.jsdelivr.net/gh/jedisct1/libsodium.js@master/dist/browsers/sodium.js');
11
- importScripts('https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js');
12
-
13
- function* chunks(arr, n) {
14
- for (let i = 0; i < arr.length; i += n) {
15
- yield arr.slice(i, i + n);
16
- }
17
- }
18
-
19
- function assert(c, message) {
20
- if (!c) {
21
- throw new Error(message);
22
- }
23
- }
24
-
25
- function encrypt(key) {
26
- let destroyed = false;
27
- const {
28
- state,
29
- header
30
- } = sodium.crypto_secretstream_xchacha20poly1305_init_push(key);
31
-
32
- const encrypt = (tag, plaintext) => {
33
- assert(destroyed === false, "state already destroyed");
34
-
35
- return sodium.crypto_secretstream_xchacha20poly1305_push(
36
- state,
37
- plaintext,
38
- null,
39
- tag
40
- );
41
- };
42
-
43
- function destroy() {
44
- assert(destroyed === false, "state already destroyed");
45
- destroyed = true;
46
- }
47
-
48
- return {
49
- encrypt,
50
- destroy,
51
- header
52
- };
53
- }
54
-
55
- function decrypt(header, key) {
56
- assert(
57
- header.byteLength >=
58
- sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES,
59
- "header must be at least HEADERBYTES (" + sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES + ") long"
60
- );
61
- assert(
62
- key.byteLength >= sodium.crypto_secretstream_xchacha20poly1305_KEYBYTES,
63
- "key must be at least KEYBYTES (" + sodium.crypto_secretstream_xchacha20poly1305_KEYBYTES + ") long"
64
- );
65
-
66
- let destroyed = false;
67
- const state = sodium.crypto_secretstream_xchacha20poly1305_init_pull(
68
- header,
69
- key
70
- );
71
-
72
- const decrypt = ciphertext => {
73
- assert(destroyed === false, "state already destroyed");
74
-
75
- return sodium.crypto_secretstream_xchacha20poly1305_pull(state, ciphertext);
76
- };
77
-
78
- function destroy() {
79
- assert(destroyed === false, "state already destroyed");
80
- destroyed = true;
81
- }
82
-
83
- return {
84
- decrypt,
85
- destroy
86
- };
87
- }
88
-
89
- const CHUNK_SIZE = 8192;
90
-
91
- async function encryptSecretstream(key, data, progress) {
92
- const { encrypt: crypt, destroy, header } = encrypt(key);
93
- const cryptedChunk =
94
- CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;
95
- const max =
96
- Math.ceil(data.byteLength / CHUNK_SIZE) * cryptedChunk + header.byteLength;
97
-
98
- progress?.({
99
- percent: 0,
100
- total: max,
101
- current: 0
102
- });
103
- const final = new Uint8Array(max);
104
- const sparkEncrypted = new SparkMD5.ArrayBuffer();
105
- const spark = new SparkMD5.ArrayBuffer();
106
-
107
- final.set(header);
108
- sparkEncrypted.append(header);
109
- let total = header.byteLength;
110
- progress?.({
111
- percent: total / max,
112
- total: max,
113
- current: total
114
- });
115
- let lastPercent = total / max;
116
-
117
- for (const chunk of chunks(data, CHUNK_SIZE)) {
118
- spark.append(chunk);
119
- const tag =
120
- chunk.length < CHUNK_SIZE
121
- ? sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL
122
- : sodium.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE;
123
- const crypted = crypt(tag, chunk);
124
- sparkEncrypted.append(crypted);
125
- final.set(crypted, total);
126
- total += crypted.byteLength;
127
- const percent = total / max;
128
- if (percent > lastPercent + 0.01) {
129
- progress?.({
130
- percent,
131
- total: max,
132
- current: total
133
- });
134
- lastPercent = percent;
135
- }
136
- }
137
-
138
- destroy();
139
- progress?.({
140
- percent: 1,
141
- total,
142
- current: total
143
- });
144
- return {
145
- data: final.slice(0, total),
146
- md5Encrypted: sparkEncrypted.end(),
147
- md5: spark.end()
148
- };
149
- }
150
-
151
- async function decryptSecretstream(key, data, progress) {
152
- const header = data.slice(
153
- 0,
154
- sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES
155
- );
156
- data = data.slice(sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);
157
-
158
- const { decrypt: decryptt, destroy } = decrypt(header, key);
159
- const chunkSize =
160
- CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;
161
- const max = Math.ceil(data.byteLength / chunkSize) * CHUNK_SIZE;
162
-
163
- progress?.({
164
- percent: 0,
165
- total: max,
166
- current: 0
167
- });
168
- const final = new Uint8Array(max);
169
- let total = 0;
170
- let lastPercent = total / max;
171
-
172
- for (const chunk of chunks(data, chunkSize)) {
173
- const tmp = decryptt(chunk);
174
- final.set(tmp.message, total);
175
- total += tmp.message.byteLength;
176
-
177
- const percent = total / max;
178
- if (percent > lastPercent + 0.01) {
179
- progress?.({
180
- percent,
181
- total: max,
182
- current: total
183
- });
184
- lastPercent = percent;
185
- }
186
- }
187
-
188
- destroy();
189
- progress?.({
190
- percent: 1,
191
- total,
192
- current: total
193
- });
194
- return final.slice(0, total);
195
- }
196
-
197
- self.onmessage = async ({ data }) => {
198
- switch (data.event) {
199
- case "encrypt": {
200
- postMessage({ event: "working" })
201
- postMessage({
202
- event: "encrypt-result",
203
- data: await encryptSecretstream(data.key, data.data, progress => postMessage({
204
- event: "encrypt-progress",
205
- data: progress
206
- }))
207
- });
208
- postMessage({ event: "ready" })
209
- break;
210
- }
211
- case "decrypt": {
212
- postMessage({ event: "working" })
213
- postMessage({
214
- event: "decrypt-result",
215
- data: await decryptSecretstream(data.key, data.data, progress => postMessage({
216
- event: "decrypt-progress",
217
- data: progress
218
- }))
219
- });
220
- postMessage({ event: "ready" })
221
- break;
222
- }
223
- }
224
- }`,tr=`importScripts('https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js');
225
-
226
- function* chunks(arr, n) {
227
- for (let i = 0; i < arr.length; i += n) {
228
- yield arr.slice(i, i + n);
229
- }
230
- }
231
-
232
- const CHUNK_SIZE = 8192;
233
-
234
- function md5(data) {
235
- const spark = new SparkMD5.ArrayBuffer();
236
- for (const chunk of chunks(data, CHUNK_SIZE)) {
237
- spark.append(chunk);
238
- }
239
- return spark.end();
240
- }
241
-
242
-
243
- self.onmessage = ({ data }) => {
244
- switch (data.event) {
245
- case "md5": {
246
- postMessage({
247
- event: "md5-result",
248
- data: md5(data.data)
249
- });
250
- break;
251
- }
252
- }
253
- }`;async function te(t){return new Promise((e,r)=>{let s=new Worker(URL.createObjectURL(new Blob([tr],{type:"text/javascript"})));s.addEventListener("error",r),s.addEventListener("messageerror",r),s.addEventListener("message",({data:n})=>{if(n.event==="md5-result")return s.terminate(),e(n.data)}),s.postMessage({event:"md5",data:t})})}async function nr(t,e,r,s){return new Promise((n,o)=>{r?.({current:0,percent:0,total:e.byteLength});let i=new Worker(URL.createObjectURL(new Blob([Ve],{type:"text/javascript"})));i.addEventListener("error",o),i.addEventListener("messageerror",o),i.addEventListener("message",({data:a})=>{switch(a.event){case"ready":{let p={event:"encrypt",data:e,key:t};i.postMessage(p,[p.data.buffer]);break}case"encrypt-progress":{if(s?.aborted){let p=new Error("Aborted");p.name="AbortError",i.terminate(),o(p)}r?.(a.data);break}case"encrypt-result":return i.terminate(),n(a.data)}})})}async function or(t,e,r,s){return new Promise((n,o)=>{r?.({current:0,percent:0,total:e.byteLength});let i=new Worker(URL.createObjectURL(new Blob([Ve],{type:"text/javascript"})));i.addEventListener("error",o),i.addEventListener("messageerror",o),i.addEventListener("message",({data:a})=>{switch(a.event){case"ready":{let p={event:"decrypt",key:t,data:e};i.postMessage(p,[p.data.buffer]);break}case"decrypt-progress":{if(s?.aborted){let p=new Error("Aborted");p.name="AbortError",i.terminate(),o(p)}r?.(a.data);break}case"decrypt-result":return i.terminate(),n(a.data)}})})}var fe={id:!0,size:!0,sizeBefore:!0,createdAt:!0,md5:!0,md5Encrypted:!0,user:{key:!0,userApp:{keyPair:{pub:!0}}}},Y={id:!0,filename:!0,createdBy:{user:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0}},userApps:{rights:!0,isRoot:!0,userApp:{user:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0}}},userApp:{userApp:{user:{id:!0}},nameKey:!0,rights:!0,isRoot:!0},isFavorite:!0,createdAt:!0,deletedAt:!0,updatedAt:!0,current:{...fe},history:{...fe}},Q={id:!0,isFavorite:!0,createdAt:!0,deletedAt:!0,updatedAt:!0,name:!0,createdBy:{user:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0}},userApps:{rights:!0,isRoot:!0,userApp:{user:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0}}},userApp:{userApp:{user:{id:!0}},nameKey:!0,rights:!0,isRoot:!0},breadcrumb:{id:!0,name:!0,nameKey:!0,pubKey:!0}},Fe={...Q,vFiles:{...Y},parentFolder:Q,subfolders:Q},ne={...Y,folder:{...Q}},G={id:!0,type:!0,body:!0,subject:!0,openedAt:!0,createdAt:!0,deletedAt:!0,recipients:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},recipient:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},sender:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},mailIntegrity:{temporaryRecipients:{email:!0},recipients:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},id:!0,hash:!0,hashKey:!0,replyTo:{id:!0}},mailIntegrityDraft:{temporaryRecipients:{email:!0},recipients:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},id:!0,hash:!0,hashKey:!0,replyTo:{id:!0}},files:{fileKey:!0,filename:!0,file:{id:!0}}};function N(t,e){t.mailIntegrityDraft&&(t.type="draft");let r=t.type==="draft"?t.mailIntegrityDraft:t.mailIntegrity;if(!r)return null;let s=t.type==="received"?t.sender.publicKey:e.publicKey,n=l.to_string(S(l.from_hex(t.body),s,e.privateKey)),o=l.to_string(S(l.from_hex(t.subject),s,e.privateKey)),i=l.crypto_generichash(l.crypto_generichash_BYTES,JSON.stringify({body:n,subject:o}),r.hashKey,"hex");return{type:t.type,id:t.id,mailIntegrityId:r.id,replyTo:r.replyTo?.id,body:n,subject:o,createdAt:new Date(t.createdAt),deletedAt:t.deletedAt?new Date(t.deletedAt):null,openedAt:t.openedAt?new Date(t.openedAt):null,isAltered:i!==r.hash,temporaryRecipients:r.temporaryRecipients,recipients:t.type==="draft"?r.recipients:t.recipients,sender:t.sender,files:t.files.map(a=>{let p=l.to_string(S(l.from_hex(a.filename),s,e.privateKey));return{id:a.file.id,name:p,key:a.fileKey}})}}var oe=async(t,e)=>{let{data:r}=await He(l.from_hex(e),l.from_string(t));return l.to_hex(r)},y,ie=class extends v{constructor(e,r,s,n){super(e,n);Ue(this,y,void 0);this.perFolder=async(e,r)=>{let s=x.get(e);return!s&&(await this.folder({id:e}),s=x.get(e),!s)||!s.userApp?.nameKey?null:{id:e,nameKey:l.to_hex(A(l.from_hex(s.userApp.nameKey),r,c(this,y).privateKey))}};this.perVFile=async(e,r)=>{let s=U.get(e);return!s&&(await this.vFile({id:e}),s=U.get(e),!s)?null:{id:s.id,nameKey:l.to_hex(A(l.from_hex(s.userApp.nameKey),r,c(this,y).privateKey)),files:s.history.map(n=>({id:n.id,key:l.to_hex(A(l.from_hex(n.user.key),r,c(this,y).privateKey))}))}};this._eachUser=async(e,r,s,n)=>{let o=K.get(n);if(!o||!("publicKey"in o)){let a=await this.user({userId:n,withPublicKey:!0});if(!a||a.__typename!=="SuccessResponse"||(o=a.data,!o))return null}if(!("publicKey"in o))throw new Error(`User ${n} have no public key`);let i=new Array;for(let a of e){let p=I.get(a.id);if(!p&&(await this.file({id:a.id}),p=I.get(a.id),!p))throw new Error(`File ${a.name} (${a.id}) does not exists`);let d=p.user?.key;!d||i.push({id:a.id,name:l.to_hex(A(l.from_string(a.name),o.publicKey,c(this,y).privateKey)),fileKey:l.to_hex(A(l.from_hex(d),o.publicKey,c(this,y).privateKey))})}return{recipientId:o.id,body:l.to_hex(A(l.from_string(s),o.publicKey,c(this,y).privateKey)),subject:l.to_hex(A(l.from_string(r),o.publicKey,c(this,y).privateKey)),files:i}};this.jwt=s,Ie(this,y,r)}get publicKey(){return c(this,y).publicKey}async addFileToHistory({fileId:e,vFileId:r}){let{addFileToHistory:s}=await this.client("mutation")({addFileToHistory:[{fileId:e,vFileId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on AddFileToHistoryResponse":{__typename:!0,addFileToHistory:{gqlVFileQuery:Y}}}]});if(!s)return null;if(s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorNotExist")return s;let n=await re(s.addFileToHistory,c(this,y)),o=n.history.find(a=>a.id===e);if(o){let a=n.users.filter(([d])=>d.publicKey!==c(this,y).publicKey),p={fileId:o.id,users:a.map(([d])=>({id:d.id,key:l.to_hex(A(l.from_hex(o.user.key),c(this,y).publicKey,c(this,y).privateKey))}))};await this.client("mutation")({shareFileInHistory:[{input:p,vFileId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on ShareFileInHistoryResponse":{__typename:!0,shareFileInHistory:!0}}]})}let i=se(n);return{__typename:"SuccessResponse",data:i}}async uploadFile({file:e,encryptProgress:r,uploadProgress:s,signal:n}){let o=pe(),i=e instanceof File?new Uint8Array(await e.arrayBuffer()):e,a=er(i),{data:p,md5:d,md5Encrypted:F}=await nr(o,a,r,n),m=A(o,c(this,y).publicKey,c(this,y).privateKey),{uploadFile:u}=await this.client("mutation")({uploadFile:[{fileSize:p.byteLength,fileSizeBefore:i.byteLength,fileKey:l.to_hex(m),md5Encrypted:F,md5:d},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorLimit":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on UploadFileResponse":{__typename:!0,uploadFile:{fileId:!0,filePartSize:!0,parts:{fields:!0,order:!0,url:!0}}}}]});if(!u)return null;if(u.__typename==="ErrorAccessDenied"||u.__typename==="ErrorLimit"||u.__typename==="ErrorNotFound")return u;if(!u.uploadFile)return null;if(s?.({total:p.byteLength,current:0,percent:0}),u.uploadFile.parts.length===0)return s?.({total:p.byteLength,current:p.byteLength,percent:1}),{__typename:"SuccessResponse",data:u.uploadFile.fileId};let h=async(g,L)=>{if(!u.uploadFile)return null;let{uploadFilePartEnd:b}=await this.client("mutation")({uploadFilePartEnd:[{fileId:u.uploadFile.fileId,md5:g,order:L},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on UploadFilePartEndResponse":{__typename:!0,uploadFilePartEnd:!0}}]});return b?b.__typename==="ErrorAccessDenied"?b:{__typename:"SuccessResponse",data:b.uploadFilePartEnd}:null},f=async()=>{if(!u.uploadFile)return null;let{uploadFileEnd:g}=await this.client("mutation")({uploadFileEnd:[{fileId:u.uploadFile.fileId},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on UploadFileEndResponse":{__typename:!0,uploadFileEnd:!0}}]});return g?g.__typename==="ErrorAccessDenied"||g.__typename==="ErrorNotFound"?g:g.uploadFileEnd?{__typename:"SuccessResponse",data:g.uploadFileEnd}:null:null},R=new Array;for(let[g,L]of We(Z(p,Number(u.uploadFile.filePartSize))))R.push({order:g+1,data:L,md5:await te(L)});let T={},_=(g,L)=>{T[g]=L;let b=Object.values(T).reduce((B,Re)=>B+Re.loaded,0);s?.({percent:b/p.byteLength,total:p.byteLength,current:b})},D=async g=>{if(!u.uploadFile)return;let L=new FormData,b=R.find(B=>B.order===g.order);if(!!b){for(let[B,Re]of Object.entries(g.fields))L.append(B,Re);L.append("file",new Blob([b.data]),`${u.uploadFile.fileId}-${b.order}`),await Gr.post(g.url,L,{onUploadProgress:B=>_(g.order,B),signal:n}),await h(b.md5,b.order)}};if(!u.uploadFile)return null;await Ee(3,u.uploadFile.parts.map(g=>()=>D(g)));let E=await f();return E?E.__typename==="ErrorAccessDenied"||E.__typename==="ErrorNotFound"?E:{__typename:"SuccessResponse",data:E.data}:null}async uploadFileInCloud({file:e,name:r,folderId:s,encryptProgress:n,uploadProgress:o,signal:i}){let a=await this.uploadFile({file:e,encryptProgress:n,uploadProgress:o,signal:i});if(!a)return null;if(a.__typename==="ErrorAccessDenied"||a.__typename==="ErrorLimit"||a.__typename==="ErrorNotFound")return a;let p=await this.saveInCloud({fileId:a.data,name:r,folderId:s});return p?p.__typename==="ErrorAccessDenied"||p.__typename==="ErrorBasic"||p.__typename==="ErrorNotExist"?p:{__typename:"SuccessResponse",data:p.data}:null}async logout(e){U.clear(),I.clear(),x.clear(),await super.logout(e)}async createFolder({name:e,parentFolderId:r}){let s=pe(),n=await oe(e,l.to_hex(s)),o=A(s,c(this,y).publicKey,c(this,y).privateKey),{createFolder:i}=await this.client("mutation")({createFolder:[{name:n,parentFolderId:r,key:l.to_hex(o)},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on CreateFolderResponse":{__typename:!0,createFolder:Fe}}]});if(!i)return null;if(i.__typename==="ErrorAccessDenied"||i.__typename==="ErrorNotExist")return i;if(!i.createFolder)return null;let a=await ce(i.createFolder,c(this,y)),p=a.parentFolder?.users?.filter(([d])=>d.publicKey!==c(this,y).publicKey)??[];return p.length&&await Promise.all(p.map(([d,F])=>this.shareFolder({folderId:a.id,rights:F,userId:d.id}))),{__typename:"SuccessResponse",data:a}}async folder({id:e,deleted:r}={}){let{folder:s}=await this.client("query")({folder:[{deleted:r,id:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on FolderResponse":{__typename:!0,folder:Fe}}]});if(!s)return null;if(s.__typename==="ErrorAccessDenied")return s;if(!s.folder)return null;let n=await ce(s.folder,c(this,y));return{__typename:"SuccessResponse",data:n}}async file({id:e}){let{file:r}=await this.client("query")({file:[{id:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on FileQueryResponse":{__typename:!0,file:fe}}]});if(!r)return null;if(r.__typename==="ErrorAccessDenied")return r;if(!r.file)return null;let s=sr(r.file,c(this,y));return{__typename:"SuccessResponse",data:s}}async vFile({id:e}){let{vFile:r}=await this.client("query")({vFile:[{id:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on VFileResponse":{__typename:!0,vFile:ne}}]});if(!r)return null;if(r.__typename==="ErrorAccessDenied")return r;if(!r.vFile)return null;let s=await q(r.vFile,c(this,y));return{__typename:"SuccessResponse",data:s}}async mail({id:e}){let{mail:r}=await this.client("query")({mail:[{id:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on QueryMailResponse":{__typename:!0,mail:G}}]});if(!r)return null;if(r.__typename==="ErrorAccessDenied")return r;if(!r.mail)return null;let s=N(r.mail,c(this,y));return s?{__typename:"SuccessResponse",data:s}:null}async shareVFile({vFileId:e,userId:r,rights:s}){let n=U.get(e);if(!n&&(await this.vFile({id:e}),n=U.get(e),!n))return{__typename:"SuccessResponse",data:!1};let o=await this.user({userId:r,withPublicKey:!0});if(!o)return{__typename:"SuccessResponse",data:!1};if(o.__typename!=="SuccessResponse")return{__typename:"SuccessResponse",data:!1};let i=l.to_hex(A(l.from_hex(n.userApp.nameKey),o.data.publicKey,c(this,y).privateKey)),a=new Array;for(let d of n.history)!d.user||a.push({id:d.id,key:l.to_hex(A(l.from_hex(d.user.key),o.data.publicKey,c(this,y).privateKey))});let{shareVFile:p}=await this.client("mutation")({shareVFile:[{vFileId:e,userId:r,rights:s,nameKey:i,history:a},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on ShareVFileResponse":{__typename:!0,shareVFile:!0}}]});return p?p.__typename==="ErrorAccessDenied"||p.__typename==="ErrorNotExist"||p.__typename==="ErrorNotFound"?p:{__typename:"SuccessResponse",data:p.shareVFile??!1}:null}async sharedVFiles(){let{sharedVFiles:e}=await this.client("query")({sharedVFiles:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on SharedVFilesResponse":{__typename:!0,sharedVFiles:ne}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;let r=new Array;for(let s of e.sharedVFiles)r.push(await q(s,c(this,y)));return{__typename:"SuccessResponse",data:r}}async vFilesSharedWithMe(){let{vFilesSharedWithMe:e}=await this.client("query")({vFilesSharedWithMe:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on VFilesSharedWithMeResponse":{__typename:!0,vFilesSharedWithMe:ne}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;let r=new Array;for(let s of e.vFilesSharedWithMe)r.push(await q(s,c(this,y)));return{__typename:"SuccessResponse",data:r}}async deletedVFiles(){let{deletedVFiles:e}=await this.client("query")({deletedVFiles:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeletedVFilesResponse":{__typename:!0,deletedVFiles:Y}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;let r=new Array;for(let s of e.deletedVFiles)r.push(await q(s,c(this,y)));return{__typename:"SuccessResponse",data:r}}async sharedFolders(){let{sharedFolders:e}=await this.client("query")({sharedFolders:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on SharedFoldersResponse":{__typename:!0,sharedFolders:Q}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;let r=new Array;for(let s of e.sharedFolders)r.push(await me(s,c(this,y)));return{__typename:"SuccessResponse",data:r}}async foldersSharedWithMe(){let{foldersSharedWithMe:e}=await this.client("query")({foldersSharedWithMe:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on FolderSharedWithMeResponse":{__typename:!0,foldersSharedWithMe:Q}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;let r=new Array;for(let s of e.foldersSharedWithMe)r.push(await me(s,c(this,y)));return{__typename:"SuccessResponse",data:r}}async deletedFolders(){let{deletedFolders:e}=await this.client("query")({deletedFolders:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeletedFoldersResponse":{__typename:!0,deletedFolders:Q}}});if(!e)return null;if(e.__typename==="ErrorAccessDenied")return e;let r=new Array;for(let s of e.deletedFolders)r.push(await me(s,c(this,y)));return{__typename:"SuccessResponse",data:r}}async deletedMails({mailType:e}){let{deletedMails:r}=await this.client("query")({deletedMails:[{mailType:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeletedMailsResponse":{__typename:!0,deletedMails:G}}]});if(!r)return null;if(r.__typename==="ErrorAccessDenied")return r;let s=new Array;for(let n of r.deletedMails){let o=N(n,c(this,y));o&&s.push(o)}return{__typename:"SuccessResponse",data:s}}async shareFolder({folderId:e,userId:r,rights:s}){let n=await this.user({userId:r,withPublicKey:!0});if(!n||n.__typename==="ErrorNotFound")return n;let{shareFolder:o}=await this.client("mutation")({shareFolder:[{folderId:e,userId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on ShareFolderResponse":{__typename:!0,vFiles:!0,folders:!0}}]});if(!o)return null;if(o.__typename==="ErrorAccessDenied"||o.__typename==="ErrorNotFound")return o;let i={vFiles:[],folders:[]};for(let p of o.folders){let d=await this.perFolder(p,n.data.publicKey);d&&i.folders.push(d)}for(let p of o.vFiles){let d=await this.perVFile(p,n.data.publicKey);d&&i.vFiles.push(d)}let{shareFolderFinish:a}=await this.client("mutation")({shareFolderFinish:[{rights:s,userId:r,shareFolders:i},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on ShareFolderFinishResponse":{__typename:!0,shareFolderFinish:!0}}]});return a?a.__typename==="ErrorAccessDenied"||a.__typename==="ErrorNotFound"?a:{__typename:"SuccessResponse",data:a.shareFolderFinish??!1}:null}async updateFolder({folderId:e,name:r,isFavorite:s,deletedAt:n}){let o=x.get(e);if(!o&&(await this.folder({id:e}),o=x.get(e),!o))throw`Can't find folder ${e}`;r=r?o.userApp?.nameKey?await oe(r,o.userApp.nameKey):r:null;let{updateFolder:i}=await this.client("mutation")({updateFolder:[{folderId:e,name:r,isFavorite:s,deletedAt:n},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on UpdateFolderResponse":{__typename:!0,updateFolder:Fe}}]});if(!i)return null;if(i.__typename==="ErrorAccessDenied"||i.__typename==="ErrorNotExist")return i;if(!i.updateFolder)return null;let a=await ce(i.updateFolder,c(this,y));return{__typename:"SuccessResponse",data:a}}async updateAppNotifications(e){let{updateAppNotifications:r}=await this.client("mutation")({updateAppNotifications:[e,{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on UpdateAppNotificationsResponse":{__typename:!0,updateAppNotifications:{enableAll:!0,mail:!0,cloud:!0,disableAllUntil:!0}}}]});return r?r.__typename==="ErrorAccessDenied"?r:r.updateAppNotifications?{__typename:"SuccessResponse",data:{cloud:r.updateAppNotifications.cloud,enableAll:r.updateAppNotifications.enableAll,mail:r.updateAppNotifications.mail,disableAllUntil:r.updateAppNotifications.disableAllUntil?new Date(r.updateAppNotifications.disableAllUntil):null}}:null:null}async appNotifications(){let{appNotifications:e}=await this.client("query")({appNotifications:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserAppNotifications":{__typename:!0,enableAll:!0,mail:!0,cloud:!0,disableAllUntil:!0}}});return e?e.__typename==="ErrorAccessDenied"||e.__typename==="ErrorNotFound"?e:{__typename:"SuccessResponse",data:{enableAll:e.enableAll,mail:e.mail,cloud:e.cloud,disableAllUntil:e.disableAllUntil?new Date(e.disableAllUntil):null}}:null}async createMail(e,r){let s=await this.createDraftMail(e);if(!s)return{__typename:"SuccessResponse",data:!1};if(s.__typename==="ErrorBasic"||s.__typename==="ErrorAccessDenied")return s;let n=await this.sendDraftMail(s.data.mailIntegrityId,r);return n?n.__typename==="ErrorAccessDenied"||n.__typename==="ErrorBasic"?n:{__typename:"SuccessResponse",data:n.data}:null}async waitingReceivedMails(){let{user:e}=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserResponse":{__typename:!0,user:{waitingReceivedMails:{date:!0,attachmentsCount:!0,sender:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},recipients:{id:!0,firstname:!0,lastname:!0,email:!0,publicKey:!0},temporaryRecipients:{email:!0}}}}}]});if(!e)return null;if(e.__typename==="ErrorNotFound")return e;if(!e.user)return null;let r=e.user.waitingReceivedMails.map(s=>({id:Nr(),...s,date:new Date(s.date)}));return{__typename:"SuccessResponse",data:r}}async updateDraftMail(e,{body:r,subject:s,files:n,recipientsIds:o,replyTo:i}){let a=await this.draftMails();if(!a)return null;if(a.__typename!=="SuccessResponse")return a;if(!a.data.find(f=>f.mailIntegrityId===e))throw new Error(`Invalid draft ${e}`);let d=null,F=null;(r||s)&&(d=l.randombytes_buf(l.crypto_generichash_KEYBYTES,"hex"),F=l.crypto_generichash(l.crypto_generichash_BYTES,JSON.stringify({body:r,subject:s}),d,"hex"));let m=new Array;if(n)for(let f of n){let R=I.get(f.id);if(!R&&(await this.file({id:f.id}),R=I.get(f.id),!R))throw new Error(`File ${f.name} (${f.id}) does not exists`);!R.user||m.push({id:R.id,fileKey:l.to_hex(A(l.from_string(R.user.key),c(this,y).publicKey,c(this,y).privateKey)),name:l.to_hex(A(l.from_string(f.name),c(this,y).publicKey,c(this,y).privateKey))})}let{updateDraftMail:u}=await this.client("mutation")({updateDraftMail:[{draftId:e,recipients:o,replyTo:i,body:r?l.to_hex(A(l.from_string(r),c(this,y).publicKey,c(this,y).privateKey)):null,subject:s?l.to_hex(A(l.from_string(s),c(this,y).publicKey,c(this,y).privateKey)):null,senderFiles:m,hash:F,hashKey:d},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on UpdateDraftMailResponse":{__typename:!0,updateDraftMail:G}}]});if(!u)return null;if(u.__typename==="ErrorAccessDenied"||u.__typename==="ErrorBasic")return u;if(!u.updateDraftMail)return null;let h=N(u.updateDraftMail,c(this,y));return{__typename:"SuccessResponse",data:h}}async deleteDraftMail(e){let{deleteDraftMail:r}=await this.client("mutation")({deleteDraftMail:[{draftId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteDraftMailResponse":{__typename:!0,deleteDraftMail:!0}}]});return r?r.__typename==="ErrorAccessDenied"?r:r.deleteDraftMail?{__typename:"SuccessResponse",data:r.deleteDraftMail??!1}:null:null}async deleteVFileSharing({vFileId:e,userId:r}){let{deleteVFileSharing:s}=await this.client("mutation")({deleteVFileSharing:[{vFileId:e,userId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on DeleteVFileSharingResponse":{__typename:!0,deleteVFileSharing:!0}}]});return s?s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorNotExist"?s:{__typename:"SuccessResponse",data:s.deleteVFileSharing}:null}async deleteFolderSharing({folderId:e,userId:r}){let{deleteFolderSharing:s}=await this.client("mutation")({deleteFolderSharing:[{folderId:e,userId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteFolderSharingResponse":{__typename:!0,deleteFolderSharing:!0}}]});return s?s.__typename==="ErrorAccessDenied"?s:{__typename:"SuccessResponse",data:s.deleteFolderSharing}:null}async duplicateVFile({vFileId:e,folderId:r,customName:s}){let n=U.get(e);if(!n&&(await this.vFile({id:e}),n=U.get(e),!n))throw new Error(`File (${e}) does not exists`);s=s?await oe(s,n.userApp.nameKey):null;let{duplicateVFile:o}=await this.client("mutation")({duplicateVFile:[{vFileId:e,folderId:r,customName:s},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on DuplicateVFileResponse":{__typename:!0,duplicateVFile:!0}}]});return o?o.__typename==="ErrorAccessDenied"||o.__typename==="ErrorNotFound"?o:{__typename:"SuccessResponse",data:o.duplicateVFile}:null}async deleteFolderCloudTrash({ids:e}){let{deleteFolderCloudTrash:r}=await this.client("mutation")({deleteFolderCloudTrash:[{ids:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteFolderCloudTrashResponse":{__typename:!0,deleteFolderCloudTrash:!0}}]});return r?r.__typename==="ErrorAccessDenied"?r:r.deleteFolderCloudTrash?{__typename:"SuccessResponse",data:r.deleteFolderCloudTrash}:null:null}async deleteVFileCloudTrash({ids:e}){let{deleteVFileCloudTrash:r}=await this.client("mutation")({deleteVFileCloudTrash:[{ids:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteVFileCloudTrashResponse":{__typename:!0,deleteVFileCloudTrash:!0}}]});return r?r.__typename==="ErrorAccessDenied"?r:r.deleteVFileCloudTrash?{__typename:"SuccessResponse",data:r.deleteVFileCloudTrash}:null:null}async deleteMailTrash({ids:e}){let{deleteMailTrash:r}=await this.client("mutation")({deleteMailTrash:[{ids:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteMailTrashResponse":{__typename:!0,deleteMailTrash:!0}}]});return r?r.__typename==="ErrorAccessDenied"?r:r.deleteMailTrash?{__typename:"SuccessResponse",data:r.deleteMailTrash}:null:null}async emptyMailTrash(){let{emptyMailTrash:e}=await this.client("mutation")({emptyMailTrash:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on EmptyMailTrashResponse":{__typename:!0,emptyMailTrash:!0}}});return e?e.__typename==="ErrorAccessDenied"?e:e.emptyMailTrash?{__typename:"SuccessResponse",data:e.emptyMailTrash}:null:null}async emptyCloudTrash(){let{emptyCloudTrash:e}=await this.client("mutation")({emptyCloudTrash:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteMailResponse":{__typename:!0,deleteMail:!0}}});return e?e.__typename==="ErrorAccessDenied"?e:e.deleteMail?{__typename:"SuccessResponse",data:e.deleteMail}:null:null}async recoverVFile({vFileId:e}){let{recoverVFile:r}=await this.client("mutation")({recoverVFile:[{vFileId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on RecoverVFileResponse":{__typename:!0,recoverVFile:!0}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorNotExist"?r:{__typename:"SuccessResponse",data:r.recoverVFile}:null}async recoverFolder({id:e}){let{recoverFolder:r}=await this.client("mutation")({recoverFolder:[{id:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on RecoverFolderResponse":{__typename:!0,recoverFolder:!0}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorNotExist"?r:r.recoverFolder?{__typename:"SuccessResponse",data:r.recoverFolder}:null:null}async recoverMail({mailId:e}){let{recoverMail:r}=await this.client("mutation")({recoverMail:[{mailId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on RecoverMailResponse":{__typename:!0,recoverMail:!0}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorBasic"?r:{__typename:"SuccessResponse",data:r.recoverMail}:null}async deleteFile({fileId:e,vFileId:r}){let{deleteFile:s}=await this.client("mutation")({deleteFile:[{fileId:e,vFileId:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on DeleteFileResponse":{__typename:!0,deleteFile:!0}}]});return s?s.__typename==="ErrorAccessDenied"||s.__typename==="ErrorNotExist"?s:{__typename:"SuccessResponse",data:s.deleteFile}:null}async deleteVFile({fileId:e}){let{deleteVFile:r}=await this.client("mutation")({deleteVFile:[{fileId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on DeleteVFileResponse":{__typename:!0,deleteVFile:!0}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorNotExist"?r:{__typename:"SuccessResponse",data:r.deleteVFile}:null}async deleteMail({mailId:e}){let{deleteMail:r}=await this.client("mutation")({deleteMail:[{mailId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on DeleteMailResponse":{__typename:!0,deleteMail:!0}}]});return r?r.__typename==="ErrorAccessDenied"?r:{__typename:"SuccessResponse",data:r.deleteMail}:null}async saveInCloud({fileId:e,name:r,folderId:s}){if(s&&!x.has(s)&&(await this.folder({id:s}),!x.has(s)))return{__typename:"ErrorBasic",message:`The folder ${s} does not exists`};let n="",o=I.get(e);if(o){if(!o.user)return{__typename:"ErrorBasic",message:"Unexpected error 2"};n=o.user.key}else{await this.file({id:e});let u=I.get(e)??null;if(u){if(!u.user)return{__typename:"ErrorBasic",message:"Unexpected error 1"};n=u.user.key}else{let h=await this.receivedMails();if(!h||h.__typename!=="SuccessResponse")return null;let f=h.data.find(_=>_.files.some(D=>D.id===e));if(!f)return{__typename:"ErrorBasic",message:`Can't find mail with the file ${e}`};let R=f.files.find(_=>_.id===e);if(!R)return{__typename:"ErrorBasic",message:`Can't find mail with the file ${e}`};let T=S(l.from_hex(R.key),f.sender.publicKey,c(this,y).privateKey);n=l.to_hex(T)}}if(n==="")return{__typename:"ErrorBasic",message:"Unexpected error 3"};n=l.to_hex(A(l.from_hex(n),c(this,y).publicKey,c(this,y).privateKey));let i=pe(),a=await oe(r,l.to_hex(i)),p=l.to_hex(A(i,c(this,y).publicKey,c(this,y).privateKey)),{saveInCloud:d}=await this.client("mutation")({saveInCloud:[{fileId:e,key:n,folderId:s,filename:a,nameKey:p},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on SaveInCloudResponse":{__typename:!0,saveInCloud:ne}}]});if(!d)return null;if(d.__typename==="ErrorAccessDenied"||d.__typename==="ErrorBasic"||d.__typename==="ErrorNotExist")return d;if(!d.saveInCloud)return null;let F=await q(d.saveInCloud,c(this,y)),m=F.folder.users.find(([u])=>u.publicKey===c(this,y).publicKey);if(m&&["admin","write"].includes(m[1])){let u=F.folder.users.filter(([h])=>h.publicKey!==c(this,y).publicKey);await Promise.all(u.map(([h,f])=>this.shareVFile({vFileId:F.id,rights:f,userId:h.id})))}return{__typename:"SuccessResponse",data:F}}async sendDraftMail(e,r){let s=await this.draftMails();if(!s)return{__typename:"SuccessResponse",data:!1};if(s.__typename!=="SuccessResponse")return{__typename:"SuccessResponse",data:!1};let n=s.data.find(p=>p.mailIntegrityId===e);if(!n)return{__typename:"SuccessResponse",data:!1};let o=new Array,i=new Array;for(let{email:p}of n.temporaryRecipients){if(!p)continue;let d=await this._eachUser(n.files,n.subject,n.body,p);d?o.push(d):i.push(p)}for(let{id:p}of n.recipients){let d=await this._eachUser(n.files,n.subject,n.body,p);d?o.push(d):i.push(p)}let{sendDraftMail:a}=await this.client("mutation")({sendDraftMail:[{temporaryRecipients:i,recipients:o,draftMailId:n.mailIntegrityId,customMessage:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on SendDraftMailResponse":{__typename:!0,sendDraftMail:!0}}]});return a?a.__typename==="ErrorAccessDenied"||a.__typename==="ErrorBasic"?a:a.sendDraftMail?{__typename:"SuccessResponse",data:a.sendDraftMail}:null:null}async sendWaitingEmails(){let e=await this.sentMails();if(!e)return{__typename:"SuccessResponse",data:!1};if(e.__typename!=="SuccessResponse")return{__typename:"SuccessResponse",data:!1};let r=e.data.filter(s=>s.temporaryRecipients.length>0);for(let s of r)for(let{email:n}of s.temporaryRecipients){if(!n)continue;let o=await this._eachUser(s.files,s.subject,s.body,n);o&&await this.client("mutation")({sendOneMail:[{mailIntegrityId:s.mailIntegrityId,recipient:o},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on RecoverFolderResponse":{__typename:!0,recoverFolder:!0}}]})}return{__typename:"SuccessResponse",data:!1}}async createDraftMail({body:e,subject:r,files:s,recipientsIds:n,replyTo:o}){let i=l.randombytes_buf(l.crypto_generichash_KEYBYTES,"hex"),a=l.crypto_generichash(l.crypto_generichash_BYTES,JSON.stringify({body:e,subject:r}),i,"hex"),p=new Array;for(let m of s){let u=I.get(m.id);if(!u&&(await this.file({id:m.id}),u=I.get(m.id),!u))throw new Error(`File ${m.name} (${m.id}) does not exists`);!u.user||p.push({id:u.id,fileKey:l.to_hex(A(l.from_string(u.user.key),c(this,y).publicKey,c(this,y).privateKey)),name:l.to_hex(A(l.from_string(m.name),c(this,y).publicKey,c(this,y).privateKey))})}let{createDraftMail:d}=await this.client("mutation")({createDraftMail:[{recipients:n,replyTo:o,body:l.to_hex(A(l.from_string(e),c(this,y).publicKey,c(this,y).privateKey)),subject:l.to_hex(A(l.from_string(r),c(this,y).publicKey,c(this,y).privateKey)),senderFiles:p,hash:a,hashKey:i},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on CreateDraftMailResponse":{__typename:!0,createDraftMail:G}}]});if(!d)return null;if(d.__typename==="ErrorAccessDenied"||d.__typename==="ErrorBasic")return d;if(!d.createDraftMail)return null;let F=N(d.createDraftMail,c(this,y));return{__typename:"SuccessResponse",data:F}}async fileContent({fileId:e,onDownloadProgress:r,progressDecrypt:s,signal:n}){let{fileContent:o}=await this.client("query")({fileContent:[{fileId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on FileContentResponse":{__typename:!0,file:{"...on FileContentCloud":{__typename:!0,parts:{contentUrl:!0,order:!0,md5:!0},key:!0,publicKey:!0,totalSize:!0,md5:!0,md5Encrypted:!0},"...on FileContentReceivedMail":{__typename:!0,parts:{contentUrl:!0,order:!0,md5:!0},key:!0,senderPublicKey:!0,totalSize:!0,md5:!0,md5Encrypted:!0},"...on FileContentSentMail":{__typename:!0,parts:{contentUrl:!0,order:!0,md5:!0},key:!0,totalSize:!0,md5:!0,md5Encrypted:!0}}}}]});if(!o)return null;if(o.__typename==="ErrorAccessDenied"||o.__typename==="ErrorBasic")return o;let i=o.file;if(!i)return null;let a={},p=(T,_)=>{a[T]=_;let D=Object.values(a).reduce((g,L)=>g+L.transferredBytes,0),E=Number(i.totalSize);r?.({percent:D/E,totalBytes:E,transferredBytes:D})},d=new Array,F=async T=>{let _=new Uint8Array(await Qr.get(T.contentUrl,{timeout:!1,onDownloadProgress:E=>p(T.order,E),signal:n}).arrayBuffer());if(await te(_)!==T.md5)throw new Error(`Invalid md5 for part ${T.order} of file ${e}`);d.push({data:_,order:T.order})};await Ee(3,i.parts.map(T=>()=>F(T)));let m=P(...d.sort((T,_)=>T.order-_.order).map(T=>T.data));if(await te(m)!==i.md5Encrypted)throw new Error("Encrypted content does not match");let h=S(l.from_hex(i.key),i.__typename==="FileContentReceivedMail"?i.senderPublicKey:i.__typename==="FileContentCloud"?i.publicKey:c(this,y).publicKey,c(this,y).privateKey),f=await or(h,m,s,n);if(await te(f)!==i.md5)throw new Error("Content does not match");return{__typename:"SuccessResponse",data:rr(f)}}async updateFile({fileId:e,filename:r,isFavorite:s,deletedAt:n}){let o=U.get(e);if(!o)throw`Can't find file ${e}`;let i=r?await oe(r,o.userApp.nameKey):null,{updateFile:a}=await this.client("mutation")({updateFile:[{fileId:e,filename:i,isFavorite:s,deletedAt:n},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on ErrorNotExist":{__typename:!0,message:!0},"...on UpdateFileResponse":{__typename:!0,updateFile:{gqlVFileQuery:Y}}}]});if(!a)return{__typename:"ErrorBasic",message:"Can't update file"};if(a.__typename==="ErrorAccessDenied"||a.__typename==="ErrorBasic"||a.__typename==="ErrorNotExist")return a;if(!a.updateFile)return null;let p=await q(a.updateFile,c(this,y));return{__typename:"SuccessResponse",data:p}}async readMail({mailId:e}){let{readMail:r}=await this.client("mutation")({readMail:[{mailId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on ReadMailResponse":{__typename:!0,readMail:!0}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorBasic"||r.__typename==="ErrorNotFound"?r:r.readMail?{__typename:"SuccessResponse",data:r.readMail}:null:null}async unreadMail({mailId:e}){let{unreadMail:r}=await this.client("mutation")({unreadMail:[{mailId:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on ErrorNotFound":{__typename:!0,message:!0},"...on UnreadMailResponse":{__typename:!0,unreadMail:!0}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorBasic"||r.__typename==="ErrorNotFound"?r:r.unreadMail?{__typename:"SuccessResponse",data:r.unreadMail}:null:null}async appSettings(){let{user:e}=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserResponse":{__typename:!0,appSettings:{autoDisconnectDelay:!0,cloudFileDaysForDelete:!0,cloudFolderDaysForDelete:!0,historyFileDaysForDelete:!0,historyMaxFileCount:!0}}}]});return e?e.__typename==="ErrorNotFound"?e:{__typename:"SuccessResponse",data:e.appSettings}:null}async updateAppSettings(e){let{updateAppSettings:r}=await this.client("mutation")({updateAppSettings:[e,{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ErrorBasic":{__typename:!0,message:!0},"...on UpdateAppSettingsResponse":{__typename:!0,updateAppSettings:{autoDisconnectDelay:!0,cloudFileDaysForDelete:!0,cloudFolderDaysForDelete:!0,historyFileDaysForDelete:!0,historyMaxFileCount:!0}}}]});return r?r.__typename==="ErrorAccessDenied"||r.__typename==="ErrorBasic"?r:{__typename:"SuccessResponse",data:r.updateAppSettings}:null}async receivedMails(){let{user:e}=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserResponse":{__typename:!0,user:{receivedMails:G}}}]});if(!e)return null;if(e.__typename==="ErrorNotFound")return e;if(!e.user)return null;let r=new Array;for(let s of e.user.receivedMails){let n=N(s,c(this,y));n&&r.push(n)}return{__typename:"SuccessResponse",data:r}}async sentMails(){let{user:e}=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserResponse":{__typename:!0,user:{sentMails:G}}}]});if(!e)return null;if(e.__typename==="ErrorNotFound")return e;if(!e.user)return null;let r=new Array;for(let s of e.user.sentMails){let n=N(s,c(this,y));n&&r.push(n)}return{__typename:"SuccessResponse",data:r}}async draftMails(){let{user:e}=await this.client("query")({user:[{},{"...on ErrorNotFound":{__typename:!0,message:!0},"...on UserResponse":{__typename:!0,user:{draftMails:G}}}]});if(!e)return null;if(e.__typename==="ErrorNotFound")return e;if(!e.user)return null;let r=new Array;for(let s of e.user.draftMails){let n=N(s,c(this,y));n&&r.push(n)}return{__typename:"SuccessResponse",data:r}}async unreadReceivedMailsCount(){let{unreadReceivedMailsCount:e}=await this.client("query")({unreadReceivedMailsCount:{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on UnreadReceivedMailsCountResponse":{__typename:!0,count:!0}}});return e?e.__typename==="ErrorAccessDenied"?e:{__typename:"SuccessResponse",data:e.count}:null}};y=new WeakMap;var ir={id:!0,firstname:!0,lastname:!0,lang:!0,email:!0,phone:!0,role:!0,deletedAt:!0,lastLogin:!0},ar=class extends v{async userList(e){let{userList:r}=await this.client("query")({userList:[{search:e},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on UserListResponse":{__typename:!0,userList:ir}}]});if(!r)return null;if(r.__typename==="ErrorAccessDenied")return r;let s=r.userList.map(n=>({...n,lastLogin:new Date(n.lastLogin),deletedAt:n.deletedAt?new Date(n.deletedAt):null}));return{__typename:"SuccessResponse",data:s}}async changeUserPlan(e,r){let{changeUserPlan:s}=await this.client("mutation")({changeUserPlan:[{userId:e,plan:r},{"...on ErrorAccessDenied":{__typename:!0,message:!0},"...on ChangeUserPlanResponse":{__typename:!0,changeUserPlan:ir}}]});return s?s.__typename==="ErrorAccessDenied"?s:s.changeUserPlan?{__typename:"SuccessResponse",data:{deletedAt:s.changeUserPlan.deletedAt?new Date(s.changeUserPlan.deletedAt):null,lastLogin:new Date(s.changeUserPlan.lastLogin),email:s.changeUserPlan.email,firstname:s.changeUserPlan.firstname,id:s.changeUserPlan.id,lang:s.changeUserPlan.lang,lastname:s.changeUserPlan.lastname,phone:s.changeUserPlan.phone,role:s.changeUserPlan.role}}:null:null}};function Et(t,e){let s=O("secrecy.user_session",e).init("").load();return s===""?null:new ar(s,t)}function Br(t){return"breadcrumb"in t}function wr(t){return"history"in t&&"filename"in t}var qr={width:700,height:520,menubar:"no",resizable:"yes",location:"yes",scrollbars:"no",centered:!0},lr=1;function Kr(t){return Object.entries(t).map(([e,r])=>`${e}=${r}`).join(",")}function Or(){return lr+=1,`Popup ${lr}`}function kr(t){if(!t.width||!t.height)throw new Error("Should have width and height");let e={...t},r=window.outerWidth-t.width,s=window.outerHeight-t.height;return t.centered&&(e.left=t.left||Math.round(window.screenX+r/2),e.top=t.top||Math.round(window.screenY+s/2.5),delete e.centered),e}function zr(t,e,r,s,n){let o=r||Or(),i=kr(Object.assign({},qr,s)),a=n||function(){},p=Kr(i),d=t(e,o,p),F=!1,m;function u(f,R){F||(F=!0,a(f,R))}function h(f){let R=f?f.data:void 0;R&&(u(void 0,R),window.removeEventListener("message",h))}return window.addEventListener("message",h,!1),d?m=window.setInterval(function(){(d===null||d.closed)&&setTimeout(function(){clearInterval(m),u(new Error("Popup closed"))},500)},100):u(new Error("Popup blocked")),d}function pr(t,e,r,s){return zr(window.open,t,e,r,s)}function dr(){if(!window.location.hash)return null;let t=window.location.hash.substr(1);try{let e=JSON.parse(atob(t));return window.location.hash="",e}catch{return null}}function Wr(t,e){let r=k(e),s=r.userAppSession.load(),n=r.userAppKeys.load(),o=r.jwt.load();if(!s||!n||!o){let i=dr();return i?(r.userAppKeys.save(i.keys),r.userAppSession.save(i.uaSession),r.jwt.save(i.jwt),new ie(i.uaSession,i.keys,i.jwt,t)):null}return new ie(s,n,o,t)}function Nt({appCode:t,path:e,redirect:r,scopes:s,backPath:n,env:o,session:i}={}){return new Promise((a,p)=>{let d=window.location.origin;if(t&&!d.includes("localhost"))return p("Can't use appCode if not in localhost");let F=Wr(o);if(F)return a(F);{let m={appUrl:d,appCode:t,redirect:r,path:e,scopes:s,backPath:n},u=btoa(JSON.stringify(m)).replaceAll("=",""),h="";o==="dev"&&(h="dev.");let f=document.documentElement.lang,R=`https://auth.${h}secrecy.me${f?`/${f}`:""}/login#${u}`,T=_=>{let D=k(i);return D.userAppSession.save(_.uaSession),D.userAppKeys.save(_.keys),D.jwt.save(_.jwt),a(new ie(_.uaSession,_.keys,_.jwt,o))};if(r){let _=dr();return _?T(_):(window.location.href=R,a(null))}else pr(R,"Secrecy Login",{},(_,D)=>{if(_)return p(_);{let E=D;if(E)return T(E)}})}})}export{ar as AdminSecrecyClient,v as BaseClient,Be as FileContentType,Pe as Lang,Ge as MailType,we as PayInputType,ve as PlanKind,Ne as Rights,ie as SecrecyClient,Qe as UserRole,Ls as decryptAnonymous,S as decryptCryptoBox,bs as decryptSecretBox,Vs as encryptAnonymous,A as encryptCryptoBox,Ss as encryptSecretBox,Ds as generateCryptoBoxKeyPair,Ms as generateSecretBoxKey,Et as getSecrecyAdminClient,Wr as getSecrecyClient,Br as isFolder,wr as isVFile,Sr as isValidPlan,Nt as login,dr as parseInfos,ge as setup,l as sodium,O as storeBuddy};
254
- // lz4-ts @license BSD-3-Clause / Copyright (c) 2015, Pierre Curto / 2016, oov. All rights reserved.
255
- //# sourceMappingURL=index.mjs.map