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

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 (156) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/__tests__/client/client.test.ts +81 -0
  3. package/__tests__/client/folder.test.ts +302 -0
  4. package/__tests__/client/mail.test.ts +476 -0
  5. package/__tests__/client/timing.test.ts +35 -0
  6. package/__tests__/client/utils.ts +41 -0
  7. package/__tests__/client/vFile.test.ts +207 -0
  8. package/__tests__/index.test.ts +171 -0
  9. package/commitlint.config.cjs +3 -0
  10. package/{lib/zeus → dist}/index.d.ts +729 -915
  11. package/dist/index.js +255 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/index.mjs +255 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/docs/assets/css/main.css +2660 -0
  16. package/docs/assets/images/icons.png +0 -0
  17. package/docs/assets/images/icons@2x.png +0 -0
  18. package/docs/assets/images/widgets.png +0 -0
  19. package/docs/assets/images/widgets@2x.png +0 -0
  20. package/docs/assets/js/main.js +248 -0
  21. package/docs/assets/js/search.js +1 -0
  22. package/docs/classes/baseclient.baseclient-1.html +1165 -0
  23. package/docs/classes/client.secrecyclient.html +2527 -0
  24. package/docs/enums/index.sodium.base64_variants.html +205 -0
  25. package/docs/index.html +198 -0
  26. package/docs/interfaces/client_types.draftmail.html +335 -0
  27. package/docs/interfaces/client_types.filecontentbase.html +231 -0
  28. package/docs/interfaces/client_types.filecontentcloud.html +244 -0
  29. package/docs/interfaces/client_types.filecontentreceivedmail.html +244 -0
  30. package/docs/interfaces/client_types.filecontentsentmail.html +230 -0
  31. package/docs/interfaces/client_types.receivedmail.html +363 -0
  32. package/docs/interfaces/client_types.sentmail.html +335 -0
  33. package/docs/interfaces/crypto.keypair.html +202 -0
  34. package/docs/interfaces/index.sodium.cryptobox.html +185 -0
  35. package/docs/interfaces/index.sodium.cryptokx.html +185 -0
  36. package/docs/interfaces/index.sodium.keypair.html +199 -0
  37. package/docs/interfaces/index.sodium.messagetag.html +185 -0
  38. package/docs/interfaces/index.sodium.secretbox.html +185 -0
  39. package/docs/interfaces/index.sodium.stateaddress.html +171 -0
  40. package/docs/interfaces/index.sodium.stringcryptobox.html +185 -0
  41. package/docs/interfaces/index.sodium.stringcryptokx.html +185 -0
  42. package/docs/interfaces/index.sodium.stringkeypair.html +199 -0
  43. package/docs/interfaces/index.sodium.stringmessagetag.html +185 -0
  44. package/docs/interfaces/index.sodium.stringsecretbox.html +185 -0
  45. package/docs/interfaces/utils_store_buddy.storebuddy.html +333 -0
  46. package/docs/modules/baseclient.html +929 -0
  47. package/docs/modules/cache.html +185 -0
  48. package/docs/modules/client.html +207 -0
  49. package/docs/modules/client_convert_file.html +216 -0
  50. package/docs/modules/client_convert_folder.html +303 -0
  51. package/docs/modules/client_convert_vfile.html +216 -0
  52. package/docs/modules/client_helpers.html +311 -0
  53. package/docs/modules/client_storage.html +167 -0
  54. package/docs/modules/client_types.html +1227 -0
  55. package/docs/modules/client_types_file.html +233 -0
  56. package/docs/modules/client_types_filesonusersonapplications.html +168 -0
  57. package/docs/modules/client_types_folder.html +383 -0
  58. package/docs/modules/client_types_inputs.html +263 -0
  59. package/docs/modules/client_types_mail.html +181 -0
  60. package/docs/modules/client_types_queries.html +199 -0
  61. package/docs/modules/client_types_userappsettings.html +163 -0
  62. package/docs/modules/client_types_vfile.html +364 -0
  63. package/docs/modules/crypto.html +366 -0
  64. package/docs/modules/crypto_file.html +344 -0
  65. package/docs/modules/index.html +779 -0
  66. package/docs/modules/index.sodium.html +6039 -0
  67. package/docs/modules/minify.html +183 -0
  68. package/docs/modules/minify_lz4.html +279 -0
  69. package/docs/modules/popuptools.html +259 -0
  70. package/docs/modules/sodium.html +167 -0
  71. package/docs/modules/utils.html +219 -0
  72. package/docs/modules/utils_store_buddy.html +208 -0
  73. package/docs/modules/utils_time.html +330 -0
  74. package/docs/modules/worker_md5.html +156 -0
  75. package/docs/modules/worker_sodium.html +231 -0
  76. package/docs/modules/worker_workercodes.html +157 -0
  77. package/docs/modules.html +235 -0
  78. package/index.html +21 -0
  79. package/jest.config.ts +27 -0
  80. package/jest.setup.ts +6 -0
  81. package/package.json +29 -37
  82. package/release.config.cjs +15 -0
  83. package/tsup.config.ts +23 -0
  84. package/lib/BaseClient.d.ts +0 -274
  85. package/lib/BaseClient.js +0 -2227
  86. package/lib/PopupTools.d.ts +0 -17
  87. package/lib/PopupTools.js +0 -213
  88. package/lib/ZeusThunder.d.ts +0 -2
  89. package/lib/ZeusThunder.js +0 -113
  90. package/lib/cache.d.ts +0 -7
  91. package/lib/cache.js +0 -5
  92. package/lib/client/admin/index.d.ts +0 -11
  93. package/lib/client/admin/index.js +0 -198
  94. package/lib/client/convert/file.d.ts +0 -5
  95. package/lib/client/convert/file.js +0 -39
  96. package/lib/client/convert/folder.d.ts +0 -8
  97. package/lib/client/convert/folder.js +0 -264
  98. package/lib/client/convert/mail.d.ts +0 -3
  99. package/lib/client/convert/mail.js +0 -46
  100. package/lib/client/convert/vFile.d.ts +0 -5
  101. package/lib/client/convert/vFile.js +0 -164
  102. package/lib/client/helpers.d.ts +0 -23
  103. package/lib/client/helpers.js +0 -114
  104. package/lib/client/index.d.ts +0 -172
  105. package/lib/client/index.js +0 -6171
  106. package/lib/client/storage.d.ts +0 -7
  107. package/lib/client/storage.js +0 -12
  108. package/lib/client/types/File.d.ts +0 -21
  109. package/lib/client/types/File.js +0 -3
  110. package/lib/client/types/FilesOnUsersOnApplications.d.ts +0 -9
  111. package/lib/client/types/FilesOnUsersOnApplications.js +0 -3
  112. package/lib/client/types/Folder.d.ts +0 -68
  113. package/lib/client/types/Folder.js +0 -7
  114. package/lib/client/types/Inputs.d.ts +0 -21
  115. package/lib/client/types/Inputs.js +0 -3
  116. package/lib/client/types/UserAppNotifications.d.ts +0 -6
  117. package/lib/client/types/UserAppNotifications.js +0 -3
  118. package/lib/client/types/UserAppSettings.d.ts +0 -7
  119. package/lib/client/types/UserAppSettings.js +0 -3
  120. package/lib/client/types/VFile.d.ts +0 -62
  121. package/lib/client/types/VFile.js +0 -4
  122. package/lib/client/types/index.d.ts +0 -154
  123. package/lib/client/types/index.js +0 -10
  124. package/lib/client/types/queries.d.ts +0 -535
  125. package/lib/client/types/queries.js +0 -192
  126. package/lib/crypto/file.d.ts +0 -14
  127. package/lib/crypto/file.js +0 -291
  128. package/lib/crypto/index.d.ts +0 -12
  129. package/lib/crypto/index.js +0 -37
  130. package/lib/error.d.ts +0 -30
  131. package/lib/error.js +0 -3
  132. package/lib/index.d.ts +0 -13
  133. package/lib/index.js +0 -42
  134. package/lib/minify/index.d.ts +0 -2
  135. package/lib/minify/index.js +0 -28
  136. package/lib/minify/lz4.d.ts +0 -5
  137. package/lib/minify/lz4.js +0 -633
  138. package/lib/sodium.d.ts +0 -3
  139. package/lib/sodium.js +0 -28
  140. package/lib/utils/store-buddy.d.ts +0 -14
  141. package/lib/utils/store-buddy.js +0 -69
  142. package/lib/utils/time.d.ts +0 -10
  143. package/lib/utils/time.js +0 -22
  144. package/lib/utils.d.ts +0 -4
  145. package/lib/utils.js +0 -188
  146. package/lib/worker/__mock__/sodium.worker.d.ts +0 -19
  147. package/lib/worker/__mock__/sodium.worker.js +0 -46
  148. package/lib/worker/md5.d.ts +0 -1
  149. package/lib/worker/md5.js +0 -43
  150. package/lib/worker/sodium.d.ts +0 -3
  151. package/lib/worker/sodium.js +0 -155
  152. package/lib/worker/workerCodes.d.ts +0 -2
  153. package/lib/worker/workerCodes.js +0 -3
  154. package/lib/zeus/const.d.ts +0 -2
  155. package/lib/zeus/const.js +0 -2267
  156. package/lib/zeus/index.js +0 -549
package/CHANGELOG.md ADDED
@@ -0,0 +1,178 @@
1
+ # [1.0.0-dev.24](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.23...v1.0.0-dev.24) (2022-02-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * remove staging ([#8](https://github.com/xsecrecy/lib/issues/8)) ([935e2eb](https://github.com/xsecrecy/lib/commit/935e2ebc11ee12ba26963b6479ddf1fb9ceaa2fd))
7
+
8
+ # [1.0.0-dev.23](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.22...v1.0.0-dev.23) (2022-01-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * accept-language on header ([bef6b04](https://github.com/xsecrecy/lib/commit/bef6b04afe869d60bad93d7ce23b594acab29ced))
14
+
15
+ # [1.0.0-dev.22](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.21...v1.0.0-dev.22) (2022-01-13)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * mutation finito ([4a59874](https://github.com/xsecrecy/lib/commit/4a59874cefb24e998080e18b3d8c4ddea8832dce))
21
+
22
+
23
+ ### Features
24
+
25
+ * handling mutation error ([81826ea](https://github.com/xsecrecy/lib/commit/81826ea75eeeea7e33129cf6a701ca9a71e4a0a3))
26
+
27
+ # [1.0.0-dev.21](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.20...v1.0.0-dev.21) (2022-01-06)
28
+
29
+
30
+ ### Features
31
+
32
+ * handling graphql query error ([135c8c6](https://github.com/xsecrecy/lib/commit/135c8c63775a4e035410fdc5d8497ea21deb426f))
33
+
34
+ # [1.0.0-dev.20](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.19...v1.0.0-dev.20) (2022-01-03)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * const enum ([8d80e98](https://github.com/xsecrecy/lib/commit/8d80e98466c769676e243ab3ac11d2f44e363fd3))
40
+
41
+ # [1.0.0-dev.19](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.18...v1.0.0-dev.19) (2022-01-03)
42
+
43
+
44
+ ### Features
45
+
46
+ * unreadReceivedMailsCount ([936e319](https://github.com/xsecrecy/lib/commit/936e3193f8da2656f7fbb8db20e85acb3b0efbd1))
47
+
48
+ # [1.0.0-dev.18](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.17...v1.0.0-dev.18) (2021-12-22)
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * admin publicKey ([2d0b6fb](https://github.com/xsecrecy/lib/commit/2d0b6fb50e03487e82b2e8c901d73eaa13895ce0))
54
+
55
+ # [1.0.0-dev.17](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.16...v1.0.0-dev.17) (2021-10-27)
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * publicKey meta ([0496aef](https://github.com/xsecrecy/lib/commit/0496aef201a1edf72c1ea9fbc3f74d1902e9085a))
61
+
62
+ # [1.0.0-dev.16](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.15...v1.0.0-dev.16) (2021-10-14)
63
+
64
+
65
+ ### Bug Fixes
66
+
67
+ * error upload ([5cbe9da](https://github.com/xsecrecy/lib/commit/5cbe9daf2f688decbea5ae05af7ab5c517147e16))
68
+
69
+ # [1.0.0-dev.15](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.14...v1.0.0-dev.15) (2021-10-14)
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * const enum ([50394e4](https://github.com/xsecrecy/lib/commit/50394e481bb010ea7acd2a6f6e6df96c698b36bf))
75
+
76
+ # [1.0.0-dev.14](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.13...v1.0.0-dev.14) (2021-10-13)
77
+
78
+
79
+ ### Bug Fixes
80
+
81
+ * const enum [#1](https://github.com/xsecrecy/lib/issues/1) ([11c92da](https://github.com/xsecrecy/lib/commit/11c92da9f218999fadcbc8c3afed4fc60584963f))
82
+
83
+ # [1.0.0-dev.13](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.12...v1.0.0-dev.13) (2021-10-12)
84
+
85
+
86
+ ### Bug Fixes
87
+
88
+ * const enums ([234bd7b](https://github.com/xsecrecy/lib/commit/234bd7b5db5bd5b30fa92651ec3aef1dbf50dca0))
89
+
90
+ # [1.0.0-dev.12](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.11...v1.0.0-dev.12) (2021-10-12)
91
+
92
+
93
+ ### Bug Fixes
94
+
95
+ * admin client ([f222d34](https://github.com/xsecrecy/lib/commit/f222d34b4774ca8c4c71b45231f0a6afbf0cdacb))
96
+
97
+ # [1.0.0-dev.11](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.10...v1.0.0-dev.11) (2021-10-12)
98
+
99
+
100
+ ### Bug Fixes
101
+
102
+ * user session ([bf186a0](https://github.com/xsecrecy/lib/commit/bf186a09d8919b15fa35bb763af162cd1bd142b4))
103
+
104
+ # [1.0.0-dev.10](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.9...v1.0.0-dev.10) (2021-10-07)
105
+
106
+
107
+ ### Bug Fixes
108
+
109
+ * add getSponsorshipLink ([77e14d0](https://github.com/xsecrecy/lib/commit/77e14d00691316ff28aa4a4bd49647d05c01e0ec))
110
+
111
+ # [1.0.0-dev.9](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.8...v1.0.0-dev.9) (2021-10-07)
112
+
113
+
114
+ ### Features
115
+
116
+ * admin client ([1c75370](https://github.com/xsecrecy/lib/commit/1c753700300452ed8c85e94dc6dc724c529c8d88))
117
+
118
+ # [1.0.0-dev.8](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.7...v1.0.0-dev.8) (2021-10-06)
119
+
120
+
121
+ ### Features
122
+
123
+ * app notifications query ([#6](https://github.com/xsecrecy/lib/issues/6)) ([e64d132](https://github.com/xsecrecy/lib/commit/e64d1326c5bd0a1daf2ee8023fd53d0c14eef264))
124
+
125
+ # [1.0.0-dev.7](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.6...v1.0.0-dev.7) (2021-10-06)
126
+
127
+
128
+ ### Features
129
+
130
+ * updateAppNotifications ([#5](https://github.com/xsecrecy/lib/issues/5)) ([cc72437](https://github.com/xsecrecy/lib/commit/cc7243766090e7e76cc5b6bae5c5b0f309cb03d3))
131
+
132
+ # [1.0.0-dev.6](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.5...v1.0.0-dev.6) (2021-10-01)
133
+
134
+
135
+ ### Features
136
+
137
+ * axios signal (abort) ([5be9283](https://github.com/xsecrecy/lib/commit/5be92833c3e27b94f4ffacbec5c2de16b0382871))
138
+
139
+ # [1.0.0-dev.5](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.4...v1.0.0-dev.5) (2021-09-30)
140
+
141
+
142
+ ### Features
143
+
144
+ * add langs ([f0705fe](https://github.com/xsecrecy/lib/commit/f0705fe48cd424680d1e2373a4bbe734020621d9))
145
+
146
+ # [1.0.0-dev.4](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.3...v1.0.0-dev.4) (2021-09-30)
147
+
148
+
149
+ ### Bug Fixes
150
+
151
+ * folder breadcrumb ([b716c89](https://github.com/xsecrecy/lib/commit/b716c892b351b82a363f9aced952e68a35c1595a))
152
+
153
+ # [1.0.0-dev.3](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.2...v1.0.0-dev.3) (2021-09-29)
154
+
155
+
156
+ ### Bug Fixes
157
+
158
+ * tests ([8d1ee88](https://github.com/xsecrecy/lib/commit/8d1ee88905f86833e76a8c054ced9361145e5a32))
159
+
160
+ # [1.0.0-dev.2](https://github.com/xsecrecy/lib/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2021-09-24)
161
+
162
+
163
+ ### Bug Fixes
164
+
165
+ * redirect ([5ac821c](https://github.com/xsecrecy/lib/commit/5ac821c6db69217b631ff6aa3b839c06081d08d3))
166
+
167
+ # 1.0.0-dev.1 (2021-09-23)
168
+
169
+
170
+ ### Bug Fixes
171
+
172
+ * ci ([432bad3](https://github.com/xsecrecy/lib/commit/432bad354172c88d135aa90d56e7f0a758399cdd))
173
+
174
+
175
+ ### Features
176
+
177
+ * Folder & FolderFull ([f613786](https://github.com/xsecrecy/lib/commit/f6137862960c4c5016a63b618c94eb8c985ab913))
178
+ * yarn 2 ([9b1547c](https://github.com/xsecrecy/lib/commit/9b1547ce911cb11a67af0d601a2b34374457ec8a))
@@ -0,0 +1,81 @@
1
+ import { chrisId, raphId, chris, raph, axel, axelId } from "./utils.js";
2
+ import { setup } from "../../src/index.js";
3
+
4
+ beforeAll(setup);
5
+
6
+ describe("SecrecyClient", () => {
7
+ test("me", async () => {
8
+ const chrisMe = await chris.me({ withPublicKey: true });
9
+ if (!chrisMe) {
10
+ throw new Error("undefined or null: chrisMe");
11
+ }
12
+ if (chrisMe.__typename === "ErrorNotFound") {
13
+ throw new Error("chrisMe not found");
14
+ }
15
+ expect(chrisMe.data).toMatchObject({
16
+ email: "chris@secrecy.me",
17
+ firstname: "Christopher",
18
+ id: chrisId,
19
+ lastname: "Yovanovitch",
20
+ phone: "+33783263010",
21
+ publicKey: chris.publicKey,
22
+ role: "admin"
23
+ });
24
+ const raphMe = await raph.me({ withPublicKey: true });
25
+ if (!raphMe) {
26
+ throw new Error("undefined or null: raphMe");
27
+ }
28
+ if (raphMe.__typename === "ErrorNotFound") {
29
+ throw new Error("raphMe not found");
30
+ }
31
+ expect(raphMe.data).toMatchObject({
32
+ email: "raphaelmortier@outlook.fr",
33
+ firstname: "Raphaël",
34
+ id: raphId,
35
+ lastname: "Mortier",
36
+ phone: "+33622471563",
37
+ publicKey: raph.publicKey,
38
+ role: "admin"
39
+ });
40
+ const axelMe = await axel.me({ withPublicKey: true });
41
+ if (!axelMe) {
42
+ throw new Error("undefined or null: axelMe");
43
+ }
44
+ if (axelMe.__typename === "ErrorNotFound") {
45
+ throw new Error("axelMe not found");
46
+ }
47
+ expect(axelMe.data).toMatchObject({
48
+ email: "axel.lavoie@gmail.com",
49
+ firstname: "Axel",
50
+ id: axelId,
51
+ lastname: "Lavoie",
52
+ phone: "+33627464948",
53
+ publicKey: axel.publicKey,
54
+ role: "admin"
55
+ });
56
+ });
57
+
58
+ test("limits", async () => {
59
+ const limits = await chris.limits();
60
+ if (!limits) {
61
+ throw new Error("limits not found");
62
+ }
63
+ if (limits.__typename === "ErrorAccessDenied") {
64
+ throw new Error("ErrorAccessDenied");
65
+ }
66
+ if (limits.__typename === "ErrorLimit") {
67
+ throw new Error("ErrorLimit");
68
+ }
69
+ if (limits.__typename === "ErrorNotExist") {
70
+ throw new Error("ErrorNotExist");
71
+ }
72
+ if (limits.__typename === "ErrorNotFound") {
73
+ throw new Error("ErrorNotFound");
74
+ }
75
+ expect(limits.data).toMatchObject({
76
+ cloud: {
77
+ maxCount: 10000n
78
+ }
79
+ });
80
+ });
81
+ });
@@ -0,0 +1,302 @@
1
+ import { chris, raph, raphId } from "./utils.js";
2
+ import { Rights, setup } from "../../src/index.js";
3
+
4
+ beforeAll(setup);
5
+
6
+ beforeAll(async () => {
7
+ await Promise.all([chris.emptyCloudTrash(), raph.emptyCloudTrash()]);
8
+ });
9
+
10
+ describe("SecrecyClient - Folders", () => {
11
+ test("wrong folder", async () => {
12
+ //wrong folder
13
+ const folder = await chris.folder({
14
+ id: "id"
15
+ });
16
+ expect(folder).toBeNull();
17
+ });
18
+
19
+ test("shareFolder", async () => {
20
+ //root folder
21
+ const rootFolder = await chris.folder();
22
+ expect(rootFolder).not.toBeNull();
23
+ if (!rootFolder) {
24
+ throw new Error("empty or undefined value: rootFolder");
25
+ }
26
+
27
+ if (rootFolder.__typename === "ErrorAccessDenied") {
28
+ expect(rootFolder.message).toBe("Access denied");
29
+ }
30
+ if (rootFolder.__typename === "SuccessResponse") {
31
+ const cloudFolder = rootFolder.data.subfolders.find(
32
+ f => f.name === "cloud"
33
+ );
34
+ expect(cloudFolder).not.toBeUndefined();
35
+ if (!cloudFolder) {
36
+ throw new Error("empty or undefined value: cloudFolder");
37
+ }
38
+
39
+ //create folder
40
+ const name = "test_folder_to_share";
41
+ const folderToShare = await chris.createFolder({
42
+ name,
43
+ parentFolderId: cloudFolder.id
44
+ });
45
+
46
+ expect(folderToShare).not.toBeNull();
47
+ if (!folderToShare) {
48
+ throw new Error("empty or undefined value: folderToShare");
49
+ }
50
+
51
+ if (folderToShare.__typename !== "SuccessResponse") {
52
+ throw new Error("folderToShare is not a SuccessResponse");
53
+ }
54
+
55
+ //share folder
56
+ const res = await chris.shareFolder({
57
+ folderId: folderToShare.data.id,
58
+ rights: Rights.write,
59
+ userId: raphId
60
+ });
61
+ expect(res).toStrictEqual({ __typename: "SuccessResponse", data: true });
62
+ const allShared = await raph.foldersSharedWithMe();
63
+ if (!allShared) {
64
+ throw new Error("empty or undefined value: allShared");
65
+ }
66
+
67
+ if (allShared.__typename === "ErrorAccessDenied") {
68
+ throw new Error("Access denied");
69
+ }
70
+
71
+ if (allShared.__typename === "SuccessResponse") {
72
+ const folderShared = allShared.data.find(
73
+ f => f.id === folderToShare.data.id
74
+ );
75
+ expect(folderShared).not.toBeUndefined();
76
+ if (!folderShared) {
77
+ throw new Error("empty or undefined value: folderShared");
78
+ }
79
+
80
+ expect(folderShared.name).toBe(name);
81
+
82
+ //create folder in shared folder
83
+ const nameFolder = "test";
84
+ await raph.createFolder({
85
+ name: nameFolder,
86
+ parentFolderId: folderToShare.data.id
87
+ });
88
+ const test = await chris.folder({ id: folderToShare.data.id });
89
+ await chris.deleteFolder({ id: folderToShare.data.id });
90
+ expect(test).not.toBeNull();
91
+ if (!test) {
92
+ throw new Error("empty or undefined value: test");
93
+ }
94
+
95
+ if (test.__typename === "ErrorAccessDenied") {
96
+ throw new Error("Access denied");
97
+ }
98
+
99
+ if (test.__typename === "SuccessResponse") {
100
+ const folderCreatedByraph = test.data.subfolders.find(
101
+ f => f.name === nameFolder
102
+ );
103
+ expect(folderCreatedByraph).not.toBeUndefined();
104
+ if (!folderCreatedByraph) {
105
+ throw new Error("empty or undefined value: folderCreatedByraph");
106
+ }
107
+ expect(folderCreatedByraph.name).toBe(nameFolder);
108
+
109
+ //delete sharing
110
+ const deleteSharing = await chris.deleteFolderSharing({
111
+ folderId: test.data.id,
112
+ userId: raphId
113
+ });
114
+ expect(deleteSharing).toStrictEqual({
115
+ __typename: "SuccessResponse",
116
+ data: true
117
+ });
118
+ }
119
+ }
120
+ }
121
+ }, 50000);
122
+
123
+ test("deleteFolder", async () => {
124
+ //root folder
125
+ const rootFolder = await chris.folder();
126
+ expect(rootFolder).not.toBeNull();
127
+ if (!rootFolder) {
128
+ throw new Error("empty or undefined value: rootFolder");
129
+ }
130
+ if (rootFolder.__typename === "ErrorAccessDenied") {
131
+ throw new Error("Access denied");
132
+ }
133
+ const cloudFolder = rootFolder.data.subfolders.find(
134
+ f => f.name === "cloud"
135
+ );
136
+ expect(cloudFolder).not.toBeUndefined();
137
+ if (!cloudFolder) {
138
+ throw new Error("empty or undefined value: cloudFolder");
139
+ }
140
+
141
+ // create folder
142
+ const name = "test_folder_to_delete";
143
+ const folderToDelete = await chris.createFolder({
144
+ name,
145
+ parentFolderId: cloudFolder.id
146
+ });
147
+
148
+ expect(folderToDelete).not.toBeNull();
149
+ if (!folderToDelete) {
150
+ throw new Error("empty or undefined value: folderToDelete");
151
+ }
152
+
153
+ if (folderToDelete.__typename !== "SuccessResponse") {
154
+ throw new Error("folderToDelete is not a SuccessResponse");
155
+ }
156
+
157
+ // test breadcrumb
158
+ expect(folderToDelete.data.breadcrumb.map(f => f.name)).toEqual([
159
+ name,
160
+ "cloud",
161
+ "root"
162
+ ]);
163
+
164
+ // delete folder
165
+ const deletedFolder = await chris.deleteFolder({
166
+ id: folderToDelete.data.id
167
+ });
168
+ expect(deletedFolder).toStrictEqual({
169
+ __typename: "SuccessResponse",
170
+ data: true
171
+ });
172
+ const folderDeleted = await chris.folder({
173
+ id: folderToDelete.data.id,
174
+ deleted: true
175
+ });
176
+ expect(folderDeleted).not.toBeNull();
177
+ if (!folderDeleted) {
178
+ throw new Error("empty or undefined value: folderDeleted");
179
+ }
180
+ if (folderDeleted.__typename === "ErrorAccessDenied") {
181
+ throw new Error("Access denied");
182
+ }
183
+ expect(folderDeleted.data.deletedAt).not.toBeNull();
184
+ const deletedFolders = await chris.deletedFolders();
185
+ if (!deletedFolders) {
186
+ throw new Error("empty or undefined value: deletedFolders");
187
+ }
188
+ if (deletedFolders.__typename === "ErrorAccessDenied") {
189
+ throw new Error("Access denied");
190
+ }
191
+ const folderDeletedByChris = deletedFolders.data.find(
192
+ f => f.id === folderToDelete.data.id
193
+ );
194
+ if (!folderDeletedByChris) {
195
+ throw new Error("empty or undefined value: folderDeletedByChris");
196
+ }
197
+ expect(folderDeletedByChris.name).toBe(folderToDelete.data.name);
198
+
199
+ //recover folder
200
+ const folderToRecover = await chris.recoverFolder({
201
+ id: folderDeleted.data.id
202
+ });
203
+
204
+ expect(folderToRecover).toStrictEqual({
205
+ __typename: "SuccessResponse",
206
+ data: true
207
+ });
208
+ const folderRecovered = await chris.folder({
209
+ id: folderDeleted.data.id
210
+ });
211
+
212
+ if (!folderRecovered) {
213
+ throw new Error("empty or undefined value: folderRecovered");
214
+ }
215
+ if (folderRecovered.__typename === "ErrorAccessDenied") {
216
+ throw new Error("Access denied");
217
+ }
218
+ expect(folderRecovered).not.toBeNull();
219
+ if (!folderRecovered) {
220
+ throw new Error("empty or undefined value: folderRecovered");
221
+ }
222
+ expect(folderRecovered.data.deletedAt).toBeNull();
223
+
224
+ // await expect(
225
+ // raph.recoverFolder({ id: folderDeleted.id })
226
+ // ).rejects.toThrowError("Invalid plan");
227
+
228
+ //delete cloud trash
229
+ const deletedFolderCloudTrash = await chris.deleteFolderCloudTrash({
230
+ ids: [folderRecovered.data.id]
231
+ });
232
+ expect(deletedFolderCloudTrash).toBe(true);
233
+ }, 50000);
234
+
235
+ test("update folder", async () => {
236
+ //root folder
237
+ const rootFolder = await chris.folder();
238
+ expect(rootFolder).not.toBeNull();
239
+ if (!rootFolder) {
240
+ throw new Error("empty or undefined value: rootFolder");
241
+ }
242
+ if (rootFolder.__typename === "ErrorAccessDenied") {
243
+ throw new Error("Access denied");
244
+ }
245
+ const cloudFolder = rootFolder.data.subfolders.find(
246
+ f => f.name === "cloud"
247
+ );
248
+ expect(cloudFolder).not.toBeUndefined();
249
+ if (!cloudFolder) {
250
+ throw new Error("empty or undefined value: cloudFolder");
251
+ }
252
+
253
+ //create folder
254
+ const name = "test_folder_to_update";
255
+ const folderToUpdate = await chris.createFolder({
256
+ name,
257
+ parentFolderId: cloudFolder.id
258
+ });
259
+
260
+ expect(folderToUpdate).not.toBeNull();
261
+ if (!folderToUpdate) {
262
+ throw new Error("empty or undefined value: folderToUpdate");
263
+ }
264
+
265
+ if (folderToUpdate.__typename !== "SuccessResponse") {
266
+ throw new Error("folderToUpdate is not a SuccessResponse");
267
+ }
268
+
269
+ //update folder
270
+ const folderUpdated = await chris.updateFolder({
271
+ folderId: folderToUpdate.data.id,
272
+ name: "test_folder_updated"
273
+ });
274
+
275
+ expect(folderUpdated).not.toBeNull();
276
+ if (!folderUpdated) {
277
+ throw new Error("empty or undefined value: folderUpdated");
278
+ }
279
+
280
+ if (folderUpdated.__typename !== "SuccessResponse") {
281
+ throw new Error("folderToUpdate is not a SuccessResponse");
282
+ }
283
+
284
+ expect(folderUpdated.data.name).toBe("test_folder_updated");
285
+
286
+ //delete folder
287
+ const deletedFolder = await chris.deleteFolder({
288
+ id: folderToUpdate.data.id
289
+ });
290
+ expect(deletedFolder).toStrictEqual({
291
+ __typename: "SuccessResponse",
292
+ data: true
293
+ });
294
+ const deletedFolderCloudTrash = await chris.deleteFolderCloudTrash({
295
+ ids: [folderToUpdate.data.id]
296
+ });
297
+ expect(deletedFolderCloudTrash).toStrictEqual({
298
+ __typename: "SuccessResponse",
299
+ data: true
300
+ });
301
+ });
302
+ });