@secrecy/lib 1.0.0-dev.21 → 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 (158) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/README.md +0 -1
  3. package/__tests__/client/client.test.ts +81 -0
  4. package/__tests__/client/folder.test.ts +302 -0
  5. package/__tests__/client/mail.test.ts +476 -0
  6. package/__tests__/client/timing.test.ts +35 -0
  7. package/__tests__/client/utils.ts +41 -0
  8. package/__tests__/client/vFile.test.ts +207 -0
  9. package/__tests__/index.test.ts +171 -0
  10. package/commitlint.config.cjs +3 -0
  11. package/dist/index.d.ts +3857 -0
  12. package/dist/index.js +255 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.mjs +255 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/docs/assets/css/main.css +2660 -0
  17. package/docs/assets/images/icons.png +0 -0
  18. package/docs/assets/images/icons@2x.png +0 -0
  19. package/docs/assets/images/widgets.png +0 -0
  20. package/docs/assets/images/widgets@2x.png +0 -0
  21. package/docs/assets/js/main.js +248 -0
  22. package/docs/assets/js/search.js +1 -0
  23. package/docs/classes/baseclient.baseclient-1.html +1165 -0
  24. package/docs/classes/client.secrecyclient.html +2527 -0
  25. package/docs/enums/index.sodium.base64_variants.html +205 -0
  26. package/docs/index.html +198 -0
  27. package/docs/interfaces/client_types.draftmail.html +335 -0
  28. package/docs/interfaces/client_types.filecontentbase.html +231 -0
  29. package/docs/interfaces/client_types.filecontentcloud.html +244 -0
  30. package/docs/interfaces/client_types.filecontentreceivedmail.html +244 -0
  31. package/docs/interfaces/client_types.filecontentsentmail.html +230 -0
  32. package/docs/interfaces/client_types.receivedmail.html +363 -0
  33. package/docs/interfaces/client_types.sentmail.html +335 -0
  34. package/docs/interfaces/crypto.keypair.html +202 -0
  35. package/docs/interfaces/index.sodium.cryptobox.html +185 -0
  36. package/docs/interfaces/index.sodium.cryptokx.html +185 -0
  37. package/docs/interfaces/index.sodium.keypair.html +199 -0
  38. package/docs/interfaces/index.sodium.messagetag.html +185 -0
  39. package/docs/interfaces/index.sodium.secretbox.html +185 -0
  40. package/docs/interfaces/index.sodium.stateaddress.html +171 -0
  41. package/docs/interfaces/index.sodium.stringcryptobox.html +185 -0
  42. package/docs/interfaces/index.sodium.stringcryptokx.html +185 -0
  43. package/docs/interfaces/index.sodium.stringkeypair.html +199 -0
  44. package/docs/interfaces/index.sodium.stringmessagetag.html +185 -0
  45. package/docs/interfaces/index.sodium.stringsecretbox.html +185 -0
  46. package/docs/interfaces/utils_store_buddy.storebuddy.html +333 -0
  47. package/docs/modules/baseclient.html +929 -0
  48. package/docs/modules/cache.html +185 -0
  49. package/docs/modules/client.html +207 -0
  50. package/docs/modules/client_convert_file.html +216 -0
  51. package/docs/modules/client_convert_folder.html +303 -0
  52. package/docs/modules/client_convert_vfile.html +216 -0
  53. package/docs/modules/client_helpers.html +311 -0
  54. package/docs/modules/client_storage.html +167 -0
  55. package/docs/modules/client_types.html +1227 -0
  56. package/docs/modules/client_types_file.html +233 -0
  57. package/docs/modules/client_types_filesonusersonapplications.html +168 -0
  58. package/docs/modules/client_types_folder.html +383 -0
  59. package/docs/modules/client_types_inputs.html +263 -0
  60. package/docs/modules/client_types_mail.html +181 -0
  61. package/docs/modules/client_types_queries.html +199 -0
  62. package/docs/modules/client_types_userappsettings.html +163 -0
  63. package/docs/modules/client_types_vfile.html +364 -0
  64. package/docs/modules/crypto.html +366 -0
  65. package/docs/modules/crypto_file.html +344 -0
  66. package/docs/modules/index.html +779 -0
  67. package/docs/modules/index.sodium.html +6039 -0
  68. package/docs/modules/minify.html +183 -0
  69. package/docs/modules/minify_lz4.html +279 -0
  70. package/docs/modules/popuptools.html +259 -0
  71. package/docs/modules/sodium.html +167 -0
  72. package/docs/modules/utils.html +219 -0
  73. package/docs/modules/utils_store_buddy.html +208 -0
  74. package/docs/modules/utils_time.html +330 -0
  75. package/docs/modules/worker_md5.html +156 -0
  76. package/docs/modules/worker_sodium.html +231 -0
  77. package/docs/modules/worker_workercodes.html +157 -0
  78. package/docs/modules.html +235 -0
  79. package/index.html +21 -0
  80. package/jest.config.ts +27 -0
  81. package/jest.setup.ts +6 -0
  82. package/package.json +39 -47
  83. package/release.config.cjs +15 -0
  84. package/tsup.config.ts +23 -0
  85. package/lib/BaseClient.d.ts +0 -274
  86. package/lib/BaseClient.js +0 -1837
  87. package/lib/PopupTools.d.ts +0 -17
  88. package/lib/PopupTools.js +0 -213
  89. package/lib/ZeusThunder.d.ts +0 -2
  90. package/lib/ZeusThunder.js +0 -112
  91. package/lib/cache.d.ts +0 -7
  92. package/lib/cache.js +0 -5
  93. package/lib/client/admin/index.d.ts +0 -11
  94. package/lib/client/admin/index.js +0 -163
  95. package/lib/client/convert/file.d.ts +0 -5
  96. package/lib/client/convert/file.js +0 -39
  97. package/lib/client/convert/folder.d.ts +0 -8
  98. package/lib/client/convert/folder.js +0 -264
  99. package/lib/client/convert/mail.d.ts +0 -3
  100. package/lib/client/convert/mail.js +0 -46
  101. package/lib/client/convert/vFile.d.ts +0 -5
  102. package/lib/client/convert/vFile.js +0 -164
  103. package/lib/client/helpers.d.ts +0 -23
  104. package/lib/client/helpers.js +0 -116
  105. package/lib/client/index.d.ts +0 -172
  106. package/lib/client/index.js +0 -4501
  107. package/lib/client/storage.d.ts +0 -7
  108. package/lib/client/storage.js +0 -12
  109. package/lib/client/types/File.d.ts +0 -21
  110. package/lib/client/types/File.js +0 -3
  111. package/lib/client/types/FilesOnUsersOnApplications.d.ts +0 -9
  112. package/lib/client/types/FilesOnUsersOnApplications.js +0 -3
  113. package/lib/client/types/Folder.d.ts +0 -68
  114. package/lib/client/types/Folder.js +0 -7
  115. package/lib/client/types/Inputs.d.ts +0 -21
  116. package/lib/client/types/Inputs.js +0 -3
  117. package/lib/client/types/UserAppNotifications.d.ts +0 -6
  118. package/lib/client/types/UserAppNotifications.js +0 -3
  119. package/lib/client/types/UserAppSettings.d.ts +0 -7
  120. package/lib/client/types/UserAppSettings.js +0 -3
  121. package/lib/client/types/VFile.d.ts +0 -62
  122. package/lib/client/types/VFile.js +0 -4
  123. package/lib/client/types/index.d.ts +0 -154
  124. package/lib/client/types/index.js +0 -10
  125. package/lib/client/types/queries.d.ts +0 -535
  126. package/lib/client/types/queries.js +0 -192
  127. package/lib/crypto/file.d.ts +0 -14
  128. package/lib/crypto/file.js +0 -291
  129. package/lib/crypto/index.d.ts +0 -12
  130. package/lib/crypto/index.js +0 -37
  131. package/lib/error.d.ts +0 -30
  132. package/lib/error.js +0 -3
  133. package/lib/index.d.ts +0 -13
  134. package/lib/index.js +0 -42
  135. package/lib/minify/index.d.ts +0 -2
  136. package/lib/minify/index.js +0 -28
  137. package/lib/minify/lz4.d.ts +0 -5
  138. package/lib/minify/lz4.js +0 -633
  139. package/lib/sodium.d.ts +0 -3
  140. package/lib/sodium.js +0 -28
  141. package/lib/utils/store-buddy.d.ts +0 -14
  142. package/lib/utils/store-buddy.js +0 -69
  143. package/lib/utils/time.d.ts +0 -10
  144. package/lib/utils/time.js +0 -22
  145. package/lib/utils.d.ts +0 -4
  146. package/lib/utils.js +0 -188
  147. package/lib/worker/__mock__/sodium.worker.d.ts +0 -19
  148. package/lib/worker/__mock__/sodium.worker.js +0 -46
  149. package/lib/worker/md5.d.ts +0 -1
  150. package/lib/worker/md5.js +0 -43
  151. package/lib/worker/sodium.d.ts +0 -3
  152. package/lib/worker/sodium.js +0 -155
  153. package/lib/worker/workerCodes.d.ts +0 -2
  154. package/lib/worker/workerCodes.js +0 -3
  155. package/lib/zeus/const.d.ts +0 -2
  156. package/lib/zeus/const.js +0 -1895
  157. package/lib/zeus/index.d.ts +0 -2798
  158. package/lib/zeus/index.js +0 -549
@@ -0,0 +1,207 @@
1
+ import { chris } from "./utils.js";
2
+ import { setup } from "../../src/index.js";
3
+ // import { Rights } from "../../src/zeus/index.js";
4
+ // import WorkerMock from "../../src/worker/__mock__/sodium.worker";
5
+
6
+ beforeAll(setup);
7
+
8
+ beforeAll(async () => {
9
+ // await chris.emptyCloudTrash();
10
+ // await dauph.emptyCloudTrash();
11
+ // (self as Window & typeof globalThis).Worker = WorkerMock; // # Ca cest le bon type
12
+ });
13
+
14
+ describe("SecrecyClient - vFile", () => {
15
+ test("wrong vFile", async () => {
16
+ const vFile = await chris.vFile({
17
+ id: "id"
18
+ });
19
+ expect(vFile).toBeNull();
20
+ });
21
+
22
+ test("upload and delete vFile", async () => {
23
+ // //Root folder
24
+ // const rootFolder = await chris.folder();
25
+ // expect(rootFolder).not.toBeNull();
26
+ // if (!rootFolder) {
27
+ // throw new Error("empty or undefined value: rootFolder");
28
+ // }
29
+ // const cloudFolderSub = rootFolder.subfolders.find(f => f.name === "cloud");
30
+ // expect(cloudFolderSub).not.toBeUndefined();
31
+ // if (!cloudFolderSub) {
32
+ // throw new Error("empty or undefined value: cloudFolder");
33
+ // }
34
+ // const cloudFolder = await chris.folder({
35
+ // id: cloudFolderSub.id
36
+ // });
37
+ // if (!cloudFolder) {
38
+ // throw new Error("empty or undefined value: cloudFolder");
39
+ // }
40
+ // // const uploadFile = await chris.uploadFileInCloud({
41
+ // // file: new Uint8Array([1, 2, 3, 4, 5]),
42
+ // // name: "testChris",
43
+ // // folderId: cloudFolder.id
44
+ // // });
45
+ // //look for vFile
46
+ // const vFileChris = await chris.vFile({ id: cloudFolder.vFiles[0].id });
47
+ // expect(vFileChris).not.toBeNull();
48
+ // if (!vFileChris) {
49
+ // throw new Error("empty or undefined value: vFileChris");
50
+ // }
51
+ // //delete vFile
52
+ // const deleteVFile = await chris.deleteVFile({
53
+ // fileId: vFileChris.id
54
+ // });
55
+ // expect(deleteVFile).toBe(true);
56
+ // //look for vFile deleted
57
+ // const deletedVFile = await chris.vFile({ id: cloudFolder.vFiles[0].id });
58
+ // expect(deletedVFile).not.toBeNull();
59
+ // if (!deletedVFile) {
60
+ // throw new Error("empty or undefined value: deletedVFile");
61
+ // }
62
+ // expect(deletedVFile.deletedAt).not.toBeNull();
63
+ // //recover vFile
64
+ // const recoveredFile = await chris.recoverFile({
65
+ // fileId: vFileChris.id
66
+ // });
67
+ // //look for vFile recovered
68
+ // expect(recoveredFile).toBe(true);
69
+ // const vFileChrisRecovered = await chris.vFile({
70
+ // id: vFileChris.id
71
+ // });
72
+ // expect(vFileChrisRecovered).not.toBeNull();
73
+ // if (!vFileChrisRecovered) {
74
+ // throw new Error("empty or undefined value: vFileChrisRecovered");
75
+ // }
76
+ // expect(vFileChrisRecovered.deletedAt).toBeNull();
77
+ // const deletedVFileToDeleteFromTrash = await chris.deleteVFile({
78
+ // fileId: uploadFile.id
79
+ // });
80
+ // expect(deletedVFileToDeleteFromTrash).toBe(true);
81
+ // const deletedFromTrash = await chris.deleteVFileCloudTrash({
82
+ // ids: [uploadFile.id]
83
+ // });
84
+ // expect(deletedFromTrash).toBe(true);
85
+ });
86
+
87
+ test("shareVFile", async () => {
88
+ // //Root folder
89
+ // const rootFolder = await chris.folder();
90
+ // expect(rootFolder).not.toBeNull();
91
+ // if (!rootFolder) {
92
+ // throw new Error("empty or undefined value: rootFolder");
93
+ // }
94
+ // const cloudFolderSub = rootFolder.subfolders.find(f => f.name === "cloud");
95
+ // expect(cloudFolderSub).not.toBeUndefined();
96
+ // if (!cloudFolderSub) {
97
+ // throw new Error("empty or undefined value: cloudFolder");
98
+ // }
99
+ // const cloudFolder = await chris.folder({
100
+ // id: cloudFolderSub.id
101
+ // });
102
+ // if (!cloudFolder) {
103
+ // throw new Error("empty or undefined value: cloudFolder");
104
+ // }
105
+ // // const uploadFile = await chris.uploadFileInCloud({
106
+ // // file: new Uint8Array([1, 2, 3, 4, 5]),
107
+ // // name: "testChris",
108
+ // // folderId: cloudFolder.id
109
+ // // });
110
+ // //look for vFile
111
+ // const vFileChris = await chris.vFile({ id: cloudFolder.vFiles[0].id });
112
+ // expect(vFileChris).not.toBeNull();
113
+ // if (!vFileChris) {
114
+ // throw new Error("empty or undefined value: vFileChris");
115
+ // }
116
+ // //share vFile
117
+ // const vFileSharing = await chris.shareVFile({
118
+ // vFileId: vFileChris.id,
119
+ // userId: dauphId,
120
+ // rights: Rights.admin
121
+ // });
122
+ // expect(vFileSharing).toBe(true);
123
+ // //look for shared vFile
124
+ // const allVFilesShared = await chris.sharedVFiles();
125
+ // const vFileShared = allVFilesShared.find(f => f.id === vFileChris.id);
126
+ // if (!vFileShared) {
127
+ // throw new Error("empty or undefined value: vFileShared");
128
+ // }
129
+ // expect(vFileShared.id).toBe(vFileChris.id);
130
+ // //look for vFile shared w/ me
131
+ // // const allVFilesSharedWithMe = await dauph.vFilesSharedWithMe();
132
+ // // expect(allVFilesSharedWithMe).not.toBeNull();
133
+ // // if (!allVFilesSharedWithMe) {
134
+ // // throw new Error("empty or undefined value: allVFilesSharedWithMe");
135
+ // // }
136
+ // // const vFileSharedWithMe = allVFilesSharedWithMe.find(
137
+ // // f => f.id === vFileChris.id
138
+ // // );
139
+ // // if (!vFileSharedWithMe) {
140
+ // // throw new Error("empty or undefined value: vFileSharedWithMe");
141
+ // // }
142
+ // // expect(vFileSharedWithMe.id).toBe(vFileChris.id);
143
+ // //delete vFile sharing
144
+ // const deleteSharing = await chris.deleteVFileSharing({
145
+ // vFileId: vFileChris.id,
146
+ // userId: dauphId
147
+ // });
148
+ // expect(deleteSharing).toBe(true);
149
+ // const allDeletedShraring = await chris.sharedVFiles();
150
+ // const deletedSharing = allDeletedShraring.find(f => f.id === vFileChris.id);
151
+ // expect(deletedSharing).toBeUndefined();
152
+ // const deletedVFiles = await chris.deleteVFile({ fileId: uploadFile.id });
153
+ // expect(deletedVFiles).toBe(true);
154
+ // const deletedFromTrash = await chris.deleteVFileCloudTrash({
155
+ // ids: [uploadFile.id]
156
+ // });
157
+ // expect(deletedFromTrash).toBe(true);
158
+ });
159
+
160
+ test("duplicate and update vFile", async () => {
161
+ // //Root folder
162
+ // const rootFolder = await chris.folder();
163
+ // expect(rootFolder).not.toBeNull();
164
+ // if (!rootFolder) {
165
+ // throw new Error("empty or undefined value: rootFolder");
166
+ // }
167
+ // const cloudFolderSub = rootFolder.subfolders.find(f => f.name === "cloud");
168
+ // expect(cloudFolderSub).not.toBeUndefined();
169
+ // if (!cloudFolderSub) {
170
+ // throw new Error("empty or undefined value: cloudFolder");
171
+ // }
172
+ // const cloudFolder = await chris.folder({
173
+ // id: cloudFolderSub.id
174
+ // });
175
+ // if (!cloudFolder) {
176
+ // throw new Error("empty or undefined value: cloudFolder");
177
+ // }
178
+ // //look for vFile
179
+ // const vFileChris = await chris.vFile({ id: cloudFolder.vFiles[0].id });
180
+ // expect(vFileChris).not.toBeNull();
181
+ // if (!vFileChris) {
182
+ // throw new Error("empty or undefined value: vFileChris");
183
+ // }
184
+ // // duplicate vFile
185
+ // const duplicateVFile = await chris.duplicateVFile({
186
+ // fileId: vFileChris.id
187
+ // });
188
+ // expect(duplicateVFile).toBe(true);
189
+ // const vFileDuplicated = cloudFolder.vFiles.find(
190
+ // f => f.filename === vFileChris.filename
191
+ // );
192
+ // expect(vFileDuplicated).not.toBeUndefined();
193
+ // if (!vFileDuplicated) {
194
+ // throw new Error("empty or undefined value: vFileDuplicated");
195
+ // }
196
+ // //delete duplicated vFile
197
+ // const deleteDuplicatedVFile = await chris.deleteVFile({
198
+ // fileId: vFileDuplicated.id
199
+ // });
200
+ // expect(deleteDuplicatedVFile).toBe(true);
201
+ // //delete duplicated vFile
202
+ // const deleteCloudTrashDuplicatedVFile = await chris.deleteVFileCloudTrash({
203
+ // ids: [vFileDuplicated.id]
204
+ // });
205
+ // expect(deleteCloudTrashDuplicatedVFile).toBe(true);
206
+ });
207
+ });
@@ -0,0 +1,171 @@
1
+ import type { KeyPair } from "../src/crypto/index.js";
2
+ import {
3
+ encryptCryptoBox,
4
+ decryptCryptoBox,
5
+ encryptAnonymous,
6
+ decryptAnonymous,
7
+ encryptSecretBox,
8
+ decryptSecretBox,
9
+ generateSecretBoxKey,
10
+ generateCryptoBoxKeyPair
11
+ } from "../src/crypto/index.js";
12
+ import {
13
+ secretstreamKeygen,
14
+ encryptSecretstream,
15
+ decryptSecretstream
16
+ } from "../src/crypto/file.js";
17
+ import { compress, uncompress } from "../src/minify/index.js";
18
+ import { sodium, setup } from "../src/sodium.js";
19
+
20
+ function random(seed: number): {
21
+ seed: (s: number) => void;
22
+ nextInt: () => number;
23
+ nextFloat: () => number;
24
+ } {
25
+ function pSeed(s: number): void {
26
+ if ((seed = (s | 0) % 2147483647) <= 0) {
27
+ seed += 2147483646;
28
+ }
29
+ }
30
+
31
+ function pNextInt(): number {
32
+ return (seed = (seed * 48271) % 2147483647);
33
+ }
34
+
35
+ function pNextFLoat(): number {
36
+ return (pNextInt() - 1) / 2147483646;
37
+ }
38
+
39
+ pSeed(seed);
40
+
41
+ return {
42
+ seed: pSeed,
43
+ nextInt: pNextInt,
44
+ nextFloat: pNextFLoat
45
+ };
46
+ }
47
+
48
+ const { nextInt } = random(Date.now());
49
+
50
+ const randomArray = (size: number, random = true): Uint8Array =>
51
+ new Uint8Array([...Array(size).keys()].map(() => (random ? nextInt() : 0)));
52
+
53
+ beforeAll(setup);
54
+
55
+ let keyPair: KeyPair;
56
+ let random1mo: Uint8Array;
57
+ // let random10mo: Uint8Array;
58
+ // let random100mo: Uint8Array;
59
+ // let random1go: Uint8Array;
60
+ // let random2go: Uint8Array;
61
+ // let random4go: Uint8Array;
62
+
63
+ const ONE_MO = 1_000_000;
64
+
65
+ beforeAll(() => {
66
+ keyPair = generateCryptoBoxKeyPair();
67
+ random1mo = randomArray(ONE_MO);
68
+ // random10mo = randomArray(ONE_MO * 10);
69
+ // random100mo = randombytes_buf(ONE_MO * 100);
70
+ // random1go = randombytes_buf(ONE_MO * 1024);
71
+ // random2go = randombytes_buf(ONE_MO * 2048);
72
+ // random4go = randombytes_buf(ONE_MO * 4096);
73
+ });
74
+
75
+ describe("lz4", () => {
76
+ test("compress/decompress", () => {
77
+ const data = randomArray(ONE_MO, false);
78
+ const compressed = compress(data);
79
+ // const l = data.byteLength;
80
+ // const bl = compressed.byteLength;
81
+ // console.log(
82
+ // `original: ${l}, compressed: ${bl}, ${((bl / l) * 100).toFixed(2)}%`
83
+ // );
84
+ const dst = uncompress(compressed);
85
+ expect(data).toEqual(dst);
86
+ });
87
+ test("impossible compress/decompress", () => {
88
+ const data = new Uint8Array([0]);
89
+ const compressed = compress(data);
90
+ expect(compressed).toEqual(new Uint8Array([0, 0]));
91
+ const dst = uncompress(compressed);
92
+ expect(data).toEqual(dst);
93
+ });
94
+ });
95
+
96
+ test("two encrypt with same keypair are different", () => {
97
+ const crypt1 = encryptCryptoBox(
98
+ random1mo,
99
+ keyPair.publicKey,
100
+ keyPair.privateKey
101
+ );
102
+ const crypt2 = encryptCryptoBox(
103
+ random1mo,
104
+ keyPair.publicKey,
105
+ keyPair.privateKey
106
+ );
107
+ expect(crypt2).not.toEqual(crypt1);
108
+ });
109
+
110
+ describe("encrypt file benchmark", () => {
111
+ // test("100mo", () => {
112
+ // encryptFile(random100mo, key);
113
+ // });
114
+ // // test("1go", () => {
115
+ // // encryptFile(random1go, key);
116
+ // // });
117
+ // // test("2go", () => {
118
+ // // encryptFile(random2go, key);
119
+ // // });
120
+ // // test("4go", () => {
121
+ // // encryptFile(random4go, key);
122
+ // // });
123
+ test("secretstream", async () => {
124
+ const key = secretstreamKeygen();
125
+ const { data: crypted } = await encryptSecretstream(key, random1mo);
126
+ const decrypted = await decryptSecretstream(key, crypted);
127
+ expect(random1mo).toEqual(decrypted);
128
+ });
129
+ test("decrypt crypto box", () => {
130
+ const { privateKey } = generateCryptoBoxKeyPair();
131
+ const privateKeyEncrypted = encryptCryptoBox(
132
+ sodium.from_hex(privateKey),
133
+ keyPair.publicKey,
134
+ keyPair.privateKey
135
+ );
136
+ const priv = decryptCryptoBox(
137
+ privateKeyEncrypted,
138
+ keyPair.publicKey,
139
+ keyPair.privateKey
140
+ );
141
+ expect(sodium.to_hex(priv)).toEqual(privateKey);
142
+ });
143
+ test("send crypto box", () => {
144
+ const alice = generateCryptoBoxKeyPair();
145
+ const bob = generateCryptoBoxKeyPair();
146
+ const data = new Uint8Array([1, 2, 3, 4, 5]);
147
+ const encryptedMessage = encryptCryptoBox(
148
+ data,
149
+ bob.publicKey,
150
+ alice.privateKey
151
+ );
152
+ const decryptedMessage = decryptCryptoBox(
153
+ encryptedMessage,
154
+ alice.publicKey,
155
+ bob.privateKey
156
+ );
157
+ expect(decryptedMessage).toEqual(data);
158
+ });
159
+ test("anonymous to recipient", () => {
160
+ const alice = generateCryptoBoxKeyPair();
161
+ const encryptedMessage = encryptAnonymous(random1mo, alice.publicKey);
162
+ const decryptedMessage = decryptAnonymous(encryptedMessage, alice);
163
+ expect(decryptedMessage).toEqual(random1mo);
164
+ });
165
+ test("secretbox", () => {
166
+ const key = generateSecretBoxKey();
167
+ const encryptedMessage = encryptSecretBox(random1mo, key);
168
+ const decryptedMessage = decryptSecretBox(encryptedMessage, key);
169
+ expect(decryptedMessage).toEqual(random1mo);
170
+ });
171
+ });
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ["@commitlint/config-conventional"]
3
+ };