@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.
- package/CHANGELOG.md +178 -0
- package/__tests__/client/client.test.ts +81 -0
- package/__tests__/client/folder.test.ts +302 -0
- package/__tests__/client/mail.test.ts +476 -0
- package/__tests__/client/timing.test.ts +35 -0
- package/__tests__/client/utils.ts +41 -0
- package/__tests__/client/vFile.test.ts +207 -0
- package/__tests__/index.test.ts +171 -0
- package/commitlint.config.cjs +3 -0
- package/{lib/zeus → dist}/index.d.ts +729 -915
- package/dist/index.js +255 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +255 -0
- package/dist/index.mjs.map +1 -0
- package/docs/assets/css/main.css +2660 -0
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +248 -0
- package/docs/assets/js/search.js +1 -0
- package/docs/classes/baseclient.baseclient-1.html +1165 -0
- package/docs/classes/client.secrecyclient.html +2527 -0
- package/docs/enums/index.sodium.base64_variants.html +205 -0
- package/docs/index.html +198 -0
- package/docs/interfaces/client_types.draftmail.html +335 -0
- package/docs/interfaces/client_types.filecontentbase.html +231 -0
- package/docs/interfaces/client_types.filecontentcloud.html +244 -0
- package/docs/interfaces/client_types.filecontentreceivedmail.html +244 -0
- package/docs/interfaces/client_types.filecontentsentmail.html +230 -0
- package/docs/interfaces/client_types.receivedmail.html +363 -0
- package/docs/interfaces/client_types.sentmail.html +335 -0
- package/docs/interfaces/crypto.keypair.html +202 -0
- package/docs/interfaces/index.sodium.cryptobox.html +185 -0
- package/docs/interfaces/index.sodium.cryptokx.html +185 -0
- package/docs/interfaces/index.sodium.keypair.html +199 -0
- package/docs/interfaces/index.sodium.messagetag.html +185 -0
- package/docs/interfaces/index.sodium.secretbox.html +185 -0
- package/docs/interfaces/index.sodium.stateaddress.html +171 -0
- package/docs/interfaces/index.sodium.stringcryptobox.html +185 -0
- package/docs/interfaces/index.sodium.stringcryptokx.html +185 -0
- package/docs/interfaces/index.sodium.stringkeypair.html +199 -0
- package/docs/interfaces/index.sodium.stringmessagetag.html +185 -0
- package/docs/interfaces/index.sodium.stringsecretbox.html +185 -0
- package/docs/interfaces/utils_store_buddy.storebuddy.html +333 -0
- package/docs/modules/baseclient.html +929 -0
- package/docs/modules/cache.html +185 -0
- package/docs/modules/client.html +207 -0
- package/docs/modules/client_convert_file.html +216 -0
- package/docs/modules/client_convert_folder.html +303 -0
- package/docs/modules/client_convert_vfile.html +216 -0
- package/docs/modules/client_helpers.html +311 -0
- package/docs/modules/client_storage.html +167 -0
- package/docs/modules/client_types.html +1227 -0
- package/docs/modules/client_types_file.html +233 -0
- package/docs/modules/client_types_filesonusersonapplications.html +168 -0
- package/docs/modules/client_types_folder.html +383 -0
- package/docs/modules/client_types_inputs.html +263 -0
- package/docs/modules/client_types_mail.html +181 -0
- package/docs/modules/client_types_queries.html +199 -0
- package/docs/modules/client_types_userappsettings.html +163 -0
- package/docs/modules/client_types_vfile.html +364 -0
- package/docs/modules/crypto.html +366 -0
- package/docs/modules/crypto_file.html +344 -0
- package/docs/modules/index.html +779 -0
- package/docs/modules/index.sodium.html +6039 -0
- package/docs/modules/minify.html +183 -0
- package/docs/modules/minify_lz4.html +279 -0
- package/docs/modules/popuptools.html +259 -0
- package/docs/modules/sodium.html +167 -0
- package/docs/modules/utils.html +219 -0
- package/docs/modules/utils_store_buddy.html +208 -0
- package/docs/modules/utils_time.html +330 -0
- package/docs/modules/worker_md5.html +156 -0
- package/docs/modules/worker_sodium.html +231 -0
- package/docs/modules/worker_workercodes.html +157 -0
- package/docs/modules.html +235 -0
- package/index.html +21 -0
- package/jest.config.ts +27 -0
- package/jest.setup.ts +6 -0
- package/package.json +29 -37
- package/release.config.cjs +15 -0
- package/tsup.config.ts +23 -0
- package/lib/BaseClient.d.ts +0 -274
- package/lib/BaseClient.js +0 -2227
- package/lib/PopupTools.d.ts +0 -17
- package/lib/PopupTools.js +0 -213
- package/lib/ZeusThunder.d.ts +0 -2
- package/lib/ZeusThunder.js +0 -113
- package/lib/cache.d.ts +0 -7
- package/lib/cache.js +0 -5
- package/lib/client/admin/index.d.ts +0 -11
- package/lib/client/admin/index.js +0 -198
- package/lib/client/convert/file.d.ts +0 -5
- package/lib/client/convert/file.js +0 -39
- package/lib/client/convert/folder.d.ts +0 -8
- package/lib/client/convert/folder.js +0 -264
- package/lib/client/convert/mail.d.ts +0 -3
- package/lib/client/convert/mail.js +0 -46
- package/lib/client/convert/vFile.d.ts +0 -5
- package/lib/client/convert/vFile.js +0 -164
- package/lib/client/helpers.d.ts +0 -23
- package/lib/client/helpers.js +0 -114
- package/lib/client/index.d.ts +0 -172
- package/lib/client/index.js +0 -6171
- package/lib/client/storage.d.ts +0 -7
- package/lib/client/storage.js +0 -12
- package/lib/client/types/File.d.ts +0 -21
- package/lib/client/types/File.js +0 -3
- package/lib/client/types/FilesOnUsersOnApplications.d.ts +0 -9
- package/lib/client/types/FilesOnUsersOnApplications.js +0 -3
- package/lib/client/types/Folder.d.ts +0 -68
- package/lib/client/types/Folder.js +0 -7
- package/lib/client/types/Inputs.d.ts +0 -21
- package/lib/client/types/Inputs.js +0 -3
- package/lib/client/types/UserAppNotifications.d.ts +0 -6
- package/lib/client/types/UserAppNotifications.js +0 -3
- package/lib/client/types/UserAppSettings.d.ts +0 -7
- package/lib/client/types/UserAppSettings.js +0 -3
- package/lib/client/types/VFile.d.ts +0 -62
- package/lib/client/types/VFile.js +0 -4
- package/lib/client/types/index.d.ts +0 -154
- package/lib/client/types/index.js +0 -10
- package/lib/client/types/queries.d.ts +0 -535
- package/lib/client/types/queries.js +0 -192
- package/lib/crypto/file.d.ts +0 -14
- package/lib/crypto/file.js +0 -291
- package/lib/crypto/index.d.ts +0 -12
- package/lib/crypto/index.js +0 -37
- package/lib/error.d.ts +0 -30
- package/lib/error.js +0 -3
- package/lib/index.d.ts +0 -13
- package/lib/index.js +0 -42
- package/lib/minify/index.d.ts +0 -2
- package/lib/minify/index.js +0 -28
- package/lib/minify/lz4.d.ts +0 -5
- package/lib/minify/lz4.js +0 -633
- package/lib/sodium.d.ts +0 -3
- package/lib/sodium.js +0 -28
- package/lib/utils/store-buddy.d.ts +0 -14
- package/lib/utils/store-buddy.js +0 -69
- package/lib/utils/time.d.ts +0 -10
- package/lib/utils/time.js +0 -22
- package/lib/utils.d.ts +0 -4
- package/lib/utils.js +0 -188
- package/lib/worker/__mock__/sodium.worker.d.ts +0 -19
- package/lib/worker/__mock__/sodium.worker.js +0 -46
- package/lib/worker/md5.d.ts +0 -1
- package/lib/worker/md5.js +0 -43
- package/lib/worker/sodium.d.ts +0 -3
- package/lib/worker/sodium.js +0 -155
- package/lib/worker/workerCodes.d.ts +0 -2
- package/lib/worker/workerCodes.js +0 -3
- package/lib/zeus/const.d.ts +0 -2
- package/lib/zeus/const.js +0 -2267
- package/lib/zeus/index.js +0 -549
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { raph, chris, chrisId, raphId } from "./utils.js";
|
|
2
|
+
import { MailType } from "./../../src/zeus/index.js";
|
|
3
|
+
import { setup } from "../../src/index.js";
|
|
4
|
+
|
|
5
|
+
const mailSubject = "jest unitTest";
|
|
6
|
+
|
|
7
|
+
beforeAll(setup);
|
|
8
|
+
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
await Promise.all([chris.emptyMailTrash(), raph.emptyMailTrash()]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterAll(async () => {
|
|
14
|
+
const reqRaphSentMails = await raph.sentMails();
|
|
15
|
+
if (!reqRaphSentMails) {
|
|
16
|
+
throw new Error("reqRaphSentMails not found");
|
|
17
|
+
}
|
|
18
|
+
if (reqRaphSentMails.__typename === "ErrorNotFound") {
|
|
19
|
+
throw new Error("Error: raph sentMails not found");
|
|
20
|
+
}
|
|
21
|
+
const sentMailsRaph = reqRaphSentMails.data.filter(
|
|
22
|
+
m => m.subject === mailSubject
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const reqChrisSentMails = await chris.sentMails();
|
|
26
|
+
if (!reqChrisSentMails) {
|
|
27
|
+
throw new Error("reqChrisSentMails not found");
|
|
28
|
+
}
|
|
29
|
+
if (reqChrisSentMails.__typename === "ErrorNotFound") {
|
|
30
|
+
throw new Error("Error: chris sentMails not found");
|
|
31
|
+
}
|
|
32
|
+
const sentMailsChris = reqChrisSentMails.data.filter(
|
|
33
|
+
m => m.subject === mailSubject
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const reqRaphReceivedMails = await raph.receivedMails();
|
|
37
|
+
if (!reqRaphReceivedMails) {
|
|
38
|
+
throw new Error("reqRaphReceivedMails not found");
|
|
39
|
+
}
|
|
40
|
+
if (reqRaphReceivedMails.__typename === "ErrorNotFound") {
|
|
41
|
+
throw new Error("Error: raph receivedMails not found");
|
|
42
|
+
}
|
|
43
|
+
const receivedMailsRaph = reqRaphReceivedMails.data.filter(
|
|
44
|
+
m => m.subject === mailSubject
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const reqChrisReceivedMails = await chris.receivedMails();
|
|
48
|
+
if (!reqChrisReceivedMails) {
|
|
49
|
+
throw new Error("reqChrisReceivedMails not found");
|
|
50
|
+
}
|
|
51
|
+
if (reqChrisReceivedMails.__typename === "ErrorNotFound") {
|
|
52
|
+
throw new Error("Error: chris receivedMails not found");
|
|
53
|
+
}
|
|
54
|
+
const receivedMailsChris = reqChrisReceivedMails.data.filter(
|
|
55
|
+
m => m.subject === mailSubject
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const chrisMails = [...sentMailsChris, ...receivedMailsChris].map(m =>
|
|
59
|
+
chris.deleteMail({ mailId: m.id })
|
|
60
|
+
);
|
|
61
|
+
const raphMails = [...sentMailsRaph, ...receivedMailsRaph].map(m =>
|
|
62
|
+
raph.deleteMail({ mailId: m.id })
|
|
63
|
+
);
|
|
64
|
+
await Promise.all([chrisMails, raphMails]);
|
|
65
|
+
}, 50000);
|
|
66
|
+
|
|
67
|
+
describe("SecrecyClient - mail", () => {
|
|
68
|
+
test("wrong mail", async () => {
|
|
69
|
+
//wrong mail
|
|
70
|
+
const mail = await raph.mail({
|
|
71
|
+
id: "id"
|
|
72
|
+
});
|
|
73
|
+
expect(mail).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("search mail", async () => {
|
|
77
|
+
//create draft mail
|
|
78
|
+
const mail = await raph.createDraftMail({
|
|
79
|
+
body: "test",
|
|
80
|
+
subject: mailSubject,
|
|
81
|
+
files: [],
|
|
82
|
+
recipientsIds: [chrisId],
|
|
83
|
+
replyTo: null
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(mail).not.toBeNull();
|
|
87
|
+
if (!mail) {
|
|
88
|
+
throw new Error("empty or undefined value: mail");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
92
|
+
throw new Error("mail is not a SuccessResponse");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//search for existing mail
|
|
96
|
+
const mailFound = await raph.mail({
|
|
97
|
+
id: mail.data.id
|
|
98
|
+
});
|
|
99
|
+
if (!mailFound) {
|
|
100
|
+
throw new Error("undefined value: mailFound");
|
|
101
|
+
}
|
|
102
|
+
expect(mailFound).not.toBeNull();
|
|
103
|
+
|
|
104
|
+
if (mailFound.__typename === "ErrorAccessDenied") {
|
|
105
|
+
throw new Error("mailFound: Access denied");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//delete draft mail
|
|
109
|
+
const deletedDraftMail = await raph.deleteDraftMail(
|
|
110
|
+
mailFound.data.mailIntegrityId
|
|
111
|
+
);
|
|
112
|
+
expect(deletedDraftMail).toStrictEqual({
|
|
113
|
+
__typename: "SuccessResponse",
|
|
114
|
+
data: true
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("create, send draft mail and delete send and received mail", async () => {
|
|
119
|
+
//create draft mail
|
|
120
|
+
const mail = await raph.createDraftMail({
|
|
121
|
+
body: "hello ceci est un test",
|
|
122
|
+
subject: mailSubject,
|
|
123
|
+
files: [],
|
|
124
|
+
recipientsIds: [chrisId],
|
|
125
|
+
replyTo: null
|
|
126
|
+
});
|
|
127
|
+
expect(mail).not.toBeNull();
|
|
128
|
+
if (!mail) {
|
|
129
|
+
throw new Error("empty or undefined value: mail");
|
|
130
|
+
}
|
|
131
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
132
|
+
throw new Error("mail is not a SuccessResponse");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//search for previous created draftMail
|
|
136
|
+
const draftMails = await raph.draftMails();
|
|
137
|
+
if (!draftMails) {
|
|
138
|
+
throw new Error("undefined value: draftMails");
|
|
139
|
+
}
|
|
140
|
+
if (draftMails.__typename === "ErrorNotFound") {
|
|
141
|
+
throw new Error("draftMails: not found");
|
|
142
|
+
}
|
|
143
|
+
const draftMail = draftMails.data.find(m => m.id === mail.data.id);
|
|
144
|
+
if (!draftMail) {
|
|
145
|
+
throw new Error("undefined value: draftMail");
|
|
146
|
+
}
|
|
147
|
+
expect(draftMail).toStrictEqual(mail.data);
|
|
148
|
+
|
|
149
|
+
//send draft mail
|
|
150
|
+
const draftMailSent = await raph.sendDraftMail(
|
|
151
|
+
mail.data.mailIntegrityId,
|
|
152
|
+
null
|
|
153
|
+
);
|
|
154
|
+
expect(draftMailSent).toStrictEqual({
|
|
155
|
+
__typename: "SuccessResponse",
|
|
156
|
+
data: true
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("Create, update and delete draft mails", async () => {
|
|
161
|
+
//create draft mail
|
|
162
|
+
const mail = await raph.createDraftMail({
|
|
163
|
+
body: "hello ceci est un test c'est le numero 2",
|
|
164
|
+
subject: mailSubject,
|
|
165
|
+
files: [],
|
|
166
|
+
recipientsIds: [chrisId],
|
|
167
|
+
replyTo: null
|
|
168
|
+
});
|
|
169
|
+
expect(mail).not.toBeNull();
|
|
170
|
+
if (!mail) {
|
|
171
|
+
throw new Error("empty or undefined value: mail");
|
|
172
|
+
}
|
|
173
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
174
|
+
throw new Error("mail is not a SuccessResponse");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//search for previous created draftMail
|
|
178
|
+
const draftMails = await raph.draftMails();
|
|
179
|
+
if (!draftMails) {
|
|
180
|
+
throw new Error("empty or undefined value: draftMails");
|
|
181
|
+
}
|
|
182
|
+
if (draftMails.__typename === "ErrorNotFound") {
|
|
183
|
+
throw new Error("draftMails: not found");
|
|
184
|
+
}
|
|
185
|
+
const draftMail = draftMails.data.find(m => m.id === mail.data.id);
|
|
186
|
+
if (!draftMail) {
|
|
187
|
+
throw new Error("empty or undefined value: draftMail");
|
|
188
|
+
}
|
|
189
|
+
expect(draftMail).toStrictEqual(mail.data);
|
|
190
|
+
|
|
191
|
+
//update draft mail
|
|
192
|
+
const mailUpdated = await raph.updateDraftMail(mail.data.mailIntegrityId, {
|
|
193
|
+
body: "hello ceci est un draft mail mis a jour",
|
|
194
|
+
subject: mailSubject,
|
|
195
|
+
files: [],
|
|
196
|
+
recipientsIds: [chrisId],
|
|
197
|
+
replyTo: null
|
|
198
|
+
});
|
|
199
|
+
expect(mailUpdated).not.toBeNull();
|
|
200
|
+
if (!mailUpdated) {
|
|
201
|
+
throw new Error("empty or undefined value: mailUpdated");
|
|
202
|
+
}
|
|
203
|
+
if (mailUpdated.__typename !== "SuccessResponse") {
|
|
204
|
+
throw new Error("mailUpdated is not a SuccessResponse");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
expect(mailUpdated.data.body).toBe(
|
|
208
|
+
"hello ceci est un draft mail mis a jour"
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
//delete draft mail
|
|
212
|
+
const deletedDraftMail = await raph.deleteDraftMail(
|
|
213
|
+
mail.data.mailIntegrityId
|
|
214
|
+
);
|
|
215
|
+
expect(deletedDraftMail).toStrictEqual({
|
|
216
|
+
__typename: "SuccessResponse",
|
|
217
|
+
data: true
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("Create and send mail", async () => {
|
|
222
|
+
//create draftMail
|
|
223
|
+
const mail = await raph.createDraftMail({
|
|
224
|
+
body: "hello ceci est un test c'est le numero 3",
|
|
225
|
+
subject: mailSubject,
|
|
226
|
+
files: [],
|
|
227
|
+
recipientsIds: [chrisId],
|
|
228
|
+
replyTo: null
|
|
229
|
+
});
|
|
230
|
+
expect(mail).not.toBeNull();
|
|
231
|
+
if (!mail) {
|
|
232
|
+
throw new Error("empty or undefined value: mail");
|
|
233
|
+
}
|
|
234
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
235
|
+
throw new Error("mail is not a SuccessResponse");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
//send draft mail
|
|
239
|
+
const draftMailSent = await raph.sendDraftMail(
|
|
240
|
+
mail.data.mailIntegrityId,
|
|
241
|
+
null
|
|
242
|
+
);
|
|
243
|
+
expect(draftMailSent).not.toBeNull();
|
|
244
|
+
if (!draftMailSent) {
|
|
245
|
+
throw new Error("empty or undefined value: mail");
|
|
246
|
+
}
|
|
247
|
+
expect(draftMailSent.__typename).toBe("SuccessResponse");
|
|
248
|
+
|
|
249
|
+
//sent Mail
|
|
250
|
+
const sentMails = await raph.sentMails();
|
|
251
|
+
expect(sentMails).not.toBeNull();
|
|
252
|
+
if (!sentMails) {
|
|
253
|
+
throw new Error("empty or undefined value: sentMails");
|
|
254
|
+
}
|
|
255
|
+
if (sentMails.__typename !== "SuccessResponse") {
|
|
256
|
+
throw new Error("sentMails is not a SuccessResponse");
|
|
257
|
+
}
|
|
258
|
+
const mailSent = sentMails.data.find(m => m.id === mail.data.id);
|
|
259
|
+
if (!mailSent) {
|
|
260
|
+
throw new Error("empty or undefined value: mailSent");
|
|
261
|
+
}
|
|
262
|
+
expect(mailSent.id).toStrictEqual(mail.data.id);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("Create and received mail", async () => {
|
|
266
|
+
//create draftMail
|
|
267
|
+
const mail = await chris.createDraftMail({
|
|
268
|
+
body: "test mail send from chris to raph",
|
|
269
|
+
subject: mailSubject,
|
|
270
|
+
files: [],
|
|
271
|
+
recipientsIds: [raphId],
|
|
272
|
+
replyTo: null
|
|
273
|
+
});
|
|
274
|
+
expect(mail).not.toBeNull();
|
|
275
|
+
if (!mail) {
|
|
276
|
+
throw new Error("empty or undefined value: mail");
|
|
277
|
+
}
|
|
278
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
279
|
+
throw new Error("mail is not a SuccessResponse");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
//send draft mail
|
|
283
|
+
const draftMailSent = await chris.sendDraftMail(
|
|
284
|
+
mail.data.mailIntegrityId,
|
|
285
|
+
null
|
|
286
|
+
);
|
|
287
|
+
expect(draftMailSent).not.toBeNull();
|
|
288
|
+
if (!draftMailSent) {
|
|
289
|
+
throw new Error("empty or undefined value: mail");
|
|
290
|
+
}
|
|
291
|
+
expect(draftMailSent.__typename).toBe("SuccessResponse");
|
|
292
|
+
|
|
293
|
+
//received Mail
|
|
294
|
+
const receivedMailsToDel = await raph.receivedMails();
|
|
295
|
+
if (!receivedMailsToDel) {
|
|
296
|
+
throw new Error("empty or undefined value: receivedMailsToDel");
|
|
297
|
+
}
|
|
298
|
+
if (receivedMailsToDel.__typename === "ErrorNotFound") {
|
|
299
|
+
throw new Error("receivedMails: not found");
|
|
300
|
+
}
|
|
301
|
+
const mailReceived = receivedMailsToDel.data.find(
|
|
302
|
+
m => m.body === mail.data.body
|
|
303
|
+
);
|
|
304
|
+
if (!mailReceived) {
|
|
305
|
+
throw new Error("empty or undefined value: mailReceived");
|
|
306
|
+
}
|
|
307
|
+
expect(mailReceived.body).toBe("test mail send from chris to raph");
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("read and unread mail", async () => {
|
|
311
|
+
//create draftMail
|
|
312
|
+
const mail = await chris.createDraftMail({
|
|
313
|
+
body: "read and unread test",
|
|
314
|
+
subject: mailSubject,
|
|
315
|
+
files: [],
|
|
316
|
+
recipientsIds: [raphId],
|
|
317
|
+
replyTo: null
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
expect(mail).not.toBeNull();
|
|
321
|
+
if (!mail) {
|
|
322
|
+
throw new Error("empty or undefined value: mail");
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
326
|
+
throw new Error("mail is not a SuccessResponse");
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
//send draft mail
|
|
330
|
+
const draftMailSent = await chris.sendDraftMail(
|
|
331
|
+
mail.data.mailIntegrityId,
|
|
332
|
+
null
|
|
333
|
+
);
|
|
334
|
+
expect(draftMailSent).toStrictEqual({
|
|
335
|
+
__typename: "SuccessResponse",
|
|
336
|
+
data: true
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
//mail from chris
|
|
340
|
+
const receivedMails = await raph.receivedMails();
|
|
341
|
+
if (!receivedMails) {
|
|
342
|
+
throw new Error("empty or undefined value: receivedMails");
|
|
343
|
+
}
|
|
344
|
+
if (receivedMails.__typename === "ErrorNotFound") {
|
|
345
|
+
throw new Error("receivedMails: not found");
|
|
346
|
+
}
|
|
347
|
+
const mailReceived = receivedMails.data.find(
|
|
348
|
+
m => m.body === mail.data.body
|
|
349
|
+
);
|
|
350
|
+
if (!mailReceived) {
|
|
351
|
+
throw new Error("empty or undefined value: mailReceived");
|
|
352
|
+
}
|
|
353
|
+
expect(mailReceived.body).toBe("read and unread test");
|
|
354
|
+
|
|
355
|
+
//read mail
|
|
356
|
+
const readMail = await raph.readMail({ mailId: mailReceived.id });
|
|
357
|
+
expect(readMail).toStrictEqual({
|
|
358
|
+
__typename: "SuccessResponse",
|
|
359
|
+
data: true
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
//looker for mail opened
|
|
363
|
+
const mailReaded = await raph.mail({ id: mailReceived.id });
|
|
364
|
+
if (!mailReaded) {
|
|
365
|
+
throw new Error("empty or undefined value: mailReaded");
|
|
366
|
+
}
|
|
367
|
+
if (mailReaded.__typename === "ErrorAccessDenied") {
|
|
368
|
+
throw new Error("mailReaded: access denied");
|
|
369
|
+
}
|
|
370
|
+
expect(mailReaded.data.openedAt).not.toBeNull();
|
|
371
|
+
|
|
372
|
+
//unread mail
|
|
373
|
+
const unreadMail = await raph.unreadMail({ mailId: mailReceived.id });
|
|
374
|
+
expect(unreadMail).toStrictEqual({
|
|
375
|
+
__typename: "SuccessResponse",
|
|
376
|
+
data: true
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
//looker for mail unreaded
|
|
380
|
+
const mailUnread = await raph.mail({ id: mailReceived.id });
|
|
381
|
+
if (!mailUnread) {
|
|
382
|
+
throw new Error("empty or undefined value: mailUnread");
|
|
383
|
+
}
|
|
384
|
+
if (mailUnread.__typename === "ErrorAccessDenied") {
|
|
385
|
+
throw new Error("mailUnread: access denied");
|
|
386
|
+
}
|
|
387
|
+
expect(mailUnread.data.openedAt).toBeNull();
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test("deletedMails", async () => {
|
|
391
|
+
//create draftMail
|
|
392
|
+
const mail = await raph.createDraftMail({
|
|
393
|
+
body: "hello ceci est un test c'est pour test les deletedMails",
|
|
394
|
+
subject: mailSubject,
|
|
395
|
+
files: [],
|
|
396
|
+
recipientsIds: [chrisId],
|
|
397
|
+
replyTo: null
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
expect(mail).not.toBeNull();
|
|
401
|
+
if (!mail) {
|
|
402
|
+
throw new Error("empty or undefined value: mail");
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (mail.__typename !== "SuccessResponse") {
|
|
406
|
+
throw new Error("mail is not a SuccessResponse");
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
//send draft mail
|
|
410
|
+
const draftMailSent = await raph.sendDraftMail(
|
|
411
|
+
mail.data.mailIntegrityId,
|
|
412
|
+
null
|
|
413
|
+
);
|
|
414
|
+
expect(draftMailSent).toStrictEqual({
|
|
415
|
+
__typename: "SuccessResponse",
|
|
416
|
+
data: true
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
//delete mail sent
|
|
420
|
+
//sent
|
|
421
|
+
const sentMailsRaph = await raph.sentMails();
|
|
422
|
+
if (!sentMailsRaph) {
|
|
423
|
+
throw new Error("empty or undefined value: sentMailsRaph");
|
|
424
|
+
}
|
|
425
|
+
if (sentMailsRaph.__typename === "ErrorNotFound") {
|
|
426
|
+
throw new Error("sentMails: not found");
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
for (const m of sentMailsRaph.data) {
|
|
430
|
+
if (m.subject === mailSubject) {
|
|
431
|
+
await raph.deleteMail({ mailId: m.id });
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
//deleted Mails
|
|
436
|
+
const deletedMails = await raph.deletedMails({ mailType: MailType.sent });
|
|
437
|
+
if (!deletedMails) {
|
|
438
|
+
throw new Error("empty or undefined value: deletedMails");
|
|
439
|
+
}
|
|
440
|
+
if (deletedMails.__typename === "ErrorAccessDenied") {
|
|
441
|
+
throw new Error("deletedMails: access denied");
|
|
442
|
+
}
|
|
443
|
+
expect(deletedMails.data[0].type).toBe(MailType.sent);
|
|
444
|
+
expect(deletedMails.data[0].deletedAt).not.toBeNull();
|
|
445
|
+
}, 50000);
|
|
446
|
+
|
|
447
|
+
test("unreadReceivedMailsCount", async () => {
|
|
448
|
+
const count = await raph.unreadReceivedMailsCount();
|
|
449
|
+
|
|
450
|
+
await chris.createMail({
|
|
451
|
+
body: "hello ceci est un test c'est pour test les unreadReceivedMailsCount",
|
|
452
|
+
subject: mailSubject,
|
|
453
|
+
files: [],
|
|
454
|
+
recipientsIds: [raphId],
|
|
455
|
+
replyTo: null
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
if (!count) {
|
|
459
|
+
throw new Error("empty or undefined value: count");
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (count.__typename === "ErrorAccessDenied") {
|
|
463
|
+
throw new Error("unreadReceivedMailsCount2: access denied");
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const countTwo = await raph.unreadReceivedMailsCount();
|
|
467
|
+
if (!countTwo) {
|
|
468
|
+
throw new Error("empty or undefined value: count2");
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (countTwo.__typename === "ErrorAccessDenied") {
|
|
472
|
+
throw new Error("unreadReceivedMailsCount2: access denied");
|
|
473
|
+
}
|
|
474
|
+
expect(count.data + 1).toBe(countTwo.data);
|
|
475
|
+
});
|
|
476
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { raph } from "./utils.js";
|
|
2
|
+
import { setup } from "../../src/index.js";
|
|
3
|
+
|
|
4
|
+
beforeAll(setup);
|
|
5
|
+
|
|
6
|
+
describe("Testing Timer", () => {
|
|
7
|
+
test("Load Cloud", async () => {
|
|
8
|
+
const load = await raph.folder();
|
|
9
|
+
if (!load) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}, 50000);
|
|
14
|
+
test("Load Sent Mails", async () => {
|
|
15
|
+
const load = await raph.sentMails();
|
|
16
|
+
if (!load) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}, 50000);
|
|
21
|
+
test("Load Receive Mails", async () => {
|
|
22
|
+
const load = await raph.receivedMails();
|
|
23
|
+
if (!load) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}, 50000);
|
|
28
|
+
test("Load Draft Mails", async () => {
|
|
29
|
+
const load = await raph.draftMails();
|
|
30
|
+
if (!load) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}, 50000);
|
|
35
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SecrecyClient } from "../../src/index.js";
|
|
2
|
+
|
|
3
|
+
export const chrisId = "ckudr5prq005801aznqly0rv2";
|
|
4
|
+
export const axelId = "ckufkdt40004901293cxftrav";
|
|
5
|
+
export const raphId = "ckxit9sbk6268901c1svzcvwzu";
|
|
6
|
+
|
|
7
|
+
export const chris = new SecrecyClient(
|
|
8
|
+
"e11dfbe1ba291b5fc9d69c0922e7dd6a720e0a06257c41274c98b1b597851b75",
|
|
9
|
+
{
|
|
10
|
+
privateKey:
|
|
11
|
+
"dfe06b209231e07b85de05c2428b8fed7465c8c04b6b09fd10126643d229c6b1",
|
|
12
|
+
publicKey:
|
|
13
|
+
"27fb31855dba1e3466822dfe90e51455918d8c7934bf168816de93d922aaf705"
|
|
14
|
+
},
|
|
15
|
+
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNocmlzQHNlY3JlY3kubWUiLCJpYXQiOjE2MzM2MDU0ODksImV4cCI6MTYzNDIxMDI4OSwiYXVkIjoiaHR0cHM6Ly9hcHAuZGV2LnNlY3JlY3kubWUiLCJpc3MiOiJodHRwczovL2F1dGguc2VjcmVjeS5tZSIsInN1YiI6ImNrdWRyNmVlbjAxMjgwMWF6MzI4MXB1OHUifQ.9MuQJpLFhW2nSJA_S6svQttRxOreItOZ1876Lz-tRkjcGW6M6yLM0S5lsqrT0_DzDN1jxoRSyZA9nzfZoEnmdA",
|
|
16
|
+
"dev"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const axel = new SecrecyClient(
|
|
20
|
+
"539dfe1e23b799c684ff5df0cfe52821f5debfc2cdb81da999e6a26b003e8651",
|
|
21
|
+
{
|
|
22
|
+
privateKey:
|
|
23
|
+
"fd7b5a72b6f71094782a6b744bff8f0d061a32c4dcca0f0efb3c91b78ccf244f",
|
|
24
|
+
publicKey:
|
|
25
|
+
"00f97b35ce49815202107cd4ce7831dfb00d6ec8cafd25fb06b4e2ef1a475404"
|
|
26
|
+
},
|
|
27
|
+
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImF4ZWwubGF2b2llQGdtYWlsLmNvbSIsImlhdCI6MTYzMzYwNTQ0MCwiZXhwIjoxNjM0MjEwMjQwLCJhdWQiOiJodHRwczovL2FwcC5kZXYuc2VjcmVjeS5tZSIsImlzcyI6Imh0dHBzOi8vYXV0aC5zZWNyZWN5Lm1lIiwic3ViIjoiY2t1Zmtkdm50MDEwNzAxMjk5a2ZqanpxcyJ9.XqFB7oXCqNYAlW9uP919i8rdvJjZ5AZAda76fr_9x2d5ScImVzGm6ALiG5tb8lIt804aRaJ_qAVaQdikoSG2-Q",
|
|
28
|
+
"dev"
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const raph = new SecrecyClient(
|
|
32
|
+
"a10db5cedd6096713ef44c4f98d62c698513cf4e77a20945e528d7cdedd6c6e2",
|
|
33
|
+
{
|
|
34
|
+
privateKey:
|
|
35
|
+
"7673fa7c534987ae69dc6d7c85458133afb03e2d2c43c3a5982d1abb04c7fbdc",
|
|
36
|
+
publicKey:
|
|
37
|
+
"113fd1991579d5e787ea9e8ce8ec944df930586e5a04af04e9ef4971e087c04e"
|
|
38
|
+
},
|
|
39
|
+
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJhcGhhZWxtb3J0aWVyQG91dGxvb2suZnIiLCJpYXQiOjE2NDA4NzIyNjcsImV4cCI6MTY0MTQ3NzA2NywiYXVkIjoiaHR0cHM6Ly9hcHAuZGV2LnNlY3JlY3kubWUiLCJpc3MiOiJodHRwczovL2F1dGguc2VjcmVjeS5tZSIsInN1YiI6ImNreGl0YmEzcjYyNzc3MDFjMTJqM2J4Y2cwIn0.mKZVKRSxVMOy6uuTFyxJuz2tH2MWpjQZEzjbny5ScwMYdexjnkGCy1EkHX-iZ-SdcOUQkk39buIl_W1kIFQQKg",
|
|
40
|
+
"dev"
|
|
41
|
+
);
|