core-3nweb-client-lib 0.44.11 → 0.45.0

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 (206) hide show
  1. package/build/core/asmail/msg/opener.js +1 -1
  2. package/build/core/asmail/msg/packer.js +1 -1
  3. package/build/core/index.d.ts +2 -2
  4. package/build/core/keyring/correspondent-keys.js +1 -1
  5. package/build/core/keyring/index.js +1 -1
  6. package/build/core/startup/sign-in.d.ts +1 -1
  7. package/build/core/startup/sign-up.d.ts +1 -1
  8. package/build/core/storage/index.d.ts +1 -1
  9. package/build/lib-client/key-derivation.d.ts +1 -1
  10. package/build/lib-client/xsp-fs/attrs.d.ts +3 -2
  11. package/build/lib-client/xsp-fs/attrs.js +7 -6
  12. package/build/lib-client/xsp-fs/folder-node.js +1 -1
  13. package/build/lib-client/xsp-fs/node-in-fs.js +1 -0
  14. package/build/lib-client/xsp-fs/node-persistence.js +1 -1
  15. package/build/lib-client/xsp-fs/xsp-payload-v2.js +1 -1
  16. package/build/tests/caps-api/asmail/specs/events.d.ts +2 -0
  17. package/build/tests/caps-api/asmail/specs/events.js +63 -0
  18. package/build/tests/caps-api/asmail/specs/send-to-wrong-address.d.ts +2 -0
  19. package/build/tests/caps-api/asmail/specs/send-to-wrong-address.js +68 -0
  20. package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.d.ts +2 -0
  21. package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +259 -0
  22. package/build/tests/caps-api/asmail/specs/send-without-attachments.d.ts +2 -0
  23. package/build/tests/caps-api/asmail/specs/send-without-attachments.js +90 -0
  24. package/build/tests/caps-api/asmail/test-utils.d.ts +12 -0
  25. package/build/tests/caps-api/asmail/test-utils.js +60 -0
  26. package/build/tests/caps-api/asmail.js +86 -0
  27. package/build/tests/caps-api/file-sink-checks/different-cases.d.ts +2 -0
  28. package/build/tests/caps-api/file-sink-checks/different-cases.js +47 -0
  29. package/build/tests/caps-api/file-sink-checks/splice.d.ts +2 -0
  30. package/build/tests/caps-api/file-sink-checks/splice.js +122 -0
  31. package/build/tests/caps-api/file-sink-checks/truncate.d.ts +2 -0
  32. package/build/tests/caps-api/file-sink-checks/truncate.js +122 -0
  33. package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.d.ts +2 -0
  34. package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.js +82 -0
  35. package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.d.ts +2 -0
  36. package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.js +50 -0
  37. package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.d.ts +2 -0
  38. package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.js +73 -0
  39. package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.d.ts +2 -0
  40. package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.js +75 -0
  41. package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.d.ts +2 -0
  42. package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +96 -0
  43. package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.d.ts +2 -0
  44. package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +67 -0
  45. package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.d.ts +2 -0
  46. package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.js +77 -0
  47. package/build/tests/caps-api/fs-checks/not-versioned/link.d.ts +2 -0
  48. package/build/tests/caps-api/fs-checks/not-versioned/link.js +115 -0
  49. package/build/tests/caps-api/fs-checks/not-versioned/listFolder.d.ts +2 -0
  50. package/build/tests/caps-api/fs-checks/not-versioned/listFolder.js +129 -0
  51. package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.d.ts +2 -0
  52. package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.js +73 -0
  53. package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.d.ts +2 -0
  54. package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.js +95 -0
  55. package/build/tests/caps-api/fs-checks/not-versioned/move.d.ts +2 -0
  56. package/build/tests/caps-api/fs-checks/not-versioned/move.js +127 -0
  57. package/build/tests/caps-api/fs-checks/not-versioned/readBytes.d.ts +2 -0
  58. package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +80 -0
  59. package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.d.ts +2 -0
  60. package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.js +59 -0
  61. package/build/tests/caps-api/fs-checks/not-versioned/readLink.d.ts +2 -0
  62. package/build/tests/caps-api/fs-checks/not-versioned/readLink.js +39 -0
  63. package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.d.ts +2 -0
  64. package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.js +54 -0
  65. package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.d.ts +2 -0
  66. package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.js +55 -0
  67. package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.d.ts +2 -0
  68. package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.js +55 -0
  69. package/build/tests/caps-api/fs-checks/not-versioned/select.d.ts +2 -0
  70. package/build/tests/caps-api/fs-checks/not-versioned/select.js +119 -0
  71. package/build/tests/caps-api/fs-checks/not-versioned/stat.d.ts +2 -0
  72. package/build/tests/caps-api/fs-checks/not-versioned/stat.js +96 -0
  73. package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.d.ts +2 -0
  74. package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.js +126 -0
  75. package/build/tests/caps-api/fs-checks/not-versioned/writableFile.d.ts +2 -0
  76. package/build/tests/caps-api/fs-checks/not-versioned/writableFile.js +79 -0
  77. package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.d.ts +2 -0
  78. package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.js +90 -0
  79. package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.d.ts +2 -0
  80. package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +137 -0
  81. package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.d.ts +2 -0
  82. package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.js +101 -0
  83. package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.d.ts +2 -0
  84. package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.js +100 -0
  85. package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.d.ts +2 -0
  86. package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +187 -0
  87. package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.d.ts +2 -0
  88. package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +70 -0
  89. package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.d.ts +2 -0
  90. package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +53 -0
  91. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.d.ts +2 -0
  92. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +194 -0
  93. package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.d.ts +2 -0
  94. package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +396 -0
  95. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.d.ts +2 -0
  96. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +229 -0
  97. package/build/tests/caps-api/fs-checks/test-utils.d.ts +34 -0
  98. package/build/tests/caps-api/fs-checks/test-utils.js +95 -0
  99. package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.d.ts +2 -0
  100. package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +73 -0
  101. package/build/tests/caps-api/fs-checks/versioned/getByteSink.d.ts +2 -0
  102. package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +122 -0
  103. package/build/tests/caps-api/fs-checks/versioned/getByteSource.d.ts +2 -0
  104. package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +71 -0
  105. package/build/tests/caps-api/fs-checks/versioned/listFolder.d.ts +2 -0
  106. package/build/tests/caps-api/fs-checks/versioned/listFolder.js +109 -0
  107. package/build/tests/caps-api/fs-checks/versioned/listVersions.d.ts +2 -0
  108. package/build/tests/caps-api/fs-checks/versioned/listVersions.js +48 -0
  109. package/build/tests/caps-api/fs-checks/versioned/readBytes.d.ts +2 -0
  110. package/build/tests/caps-api/fs-checks/versioned/readBytes.js +90 -0
  111. package/build/tests/caps-api/fs-checks/versioned/readJSONFile.d.ts +2 -0
  112. package/build/tests/caps-api/fs-checks/versioned/readJSONFile.js +60 -0
  113. package/build/tests/caps-api/fs-checks/versioned/readTxtFile.d.ts +2 -0
  114. package/build/tests/caps-api/fs-checks/versioned/readTxtFile.js +56 -0
  115. package/build/tests/caps-api/fs-checks/versioned/stat.d.ts +2 -0
  116. package/build/tests/caps-api/fs-checks/versioned/stat.js +80 -0
  117. package/build/tests/caps-api/fs-checks/versioned/watchFile.d.ts +2 -0
  118. package/build/tests/caps-api/fs-checks/versioned/watchFile.js +64 -0
  119. package/build/tests/caps-api/fs-checks/versioned/writeBytes.d.ts +2 -0
  120. package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +128 -0
  121. package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.d.ts +2 -0
  122. package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.js +111 -0
  123. package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.d.ts +2 -0
  124. package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.js +107 -0
  125. package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.d.ts +2 -0
  126. package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +50 -0
  127. package/build/tests/caps-api/keyrings.js +69 -0
  128. package/build/tests/caps-api/mailerid.d.ts +1 -0
  129. package/build/tests/caps-api/mailerid.js +59 -0
  130. package/build/tests/caps-api/startup/signin-empty-cache.d.ts +1 -0
  131. package/build/tests/caps-api/startup/signin-empty-cache.js +108 -0
  132. package/build/tests/caps-api/startup/signin-with-cache.d.ts +1 -0
  133. package/build/tests/caps-api/startup/signin-with-cache.js +83 -0
  134. package/build/tests/caps-api/startup/signup-with-token.d.ts +1 -0
  135. package/build/tests/caps-api/startup/signup-with-token.js +53 -0
  136. package/build/tests/caps-api/startup/signup.d.ts +1 -0
  137. package/build/tests/caps-api/startup/signup.js +86 -0
  138. package/build/tests/caps-api/storage.d.ts +1 -0
  139. package/build/tests/caps-api/storage.js +225 -0
  140. package/build/tests/computer.3nweb.core/id-manager.d.ts +1 -0
  141. package/build/tests/computer.3nweb.core/id-manager.js +78 -0
  142. package/build/tests/computer.3nweb.core/inbox/msg-indexing.d.ts +1 -0
  143. package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +145 -0
  144. package/build/tests/computer.3nweb.core/keyrings.d.ts +1 -0
  145. package/build/tests/computer.3nweb.core/keyrings.js +64 -0
  146. package/build/tests/computer.3nweb.core/test-utils.d.ts +21 -0
  147. package/build/tests/computer.3nweb.core/test-utils.js +92 -0
  148. package/build/tests/jasmine.d.ts +1 -0
  149. package/build/tests/jasmine.js +45 -0
  150. package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
  151. package/build/tests/libs-for-tests/bytes-equal.js +32 -0
  152. package/build/tests/libs-for-tests/caps-ipc-wrap.d.ts +11 -0
  153. package/build/tests/libs-for-tests/caps-ipc-wrap.js +55 -0
  154. package/build/tests/libs-for-tests/core-runner.d.ts +39 -0
  155. package/build/tests/libs-for-tests/core-runner.js +231 -0
  156. package/build/tests/libs-for-tests/jasmine-utils.d.ts +13 -0
  157. package/build/tests/libs-for-tests/jasmine-utils.js +110 -0
  158. package/build/tests/libs-for-tests/json-equal.d.ts +1 -0
  159. package/build/tests/libs-for-tests/json-equal.js +78 -0
  160. package/build/tests/libs-for-tests/services-runner.d.ts +18 -0
  161. package/build/tests/libs-for-tests/services-runner.js +64 -0
  162. package/build/tests/libs-for-tests/setups.d.ts +51 -0
  163. package/build/tests/libs-for-tests/setups.js +305 -0
  164. package/build/tests/libs-for-tests/spec-module.d.ts +16 -0
  165. package/build/tests/libs-for-tests/spec-module.js +92 -0
  166. package/build/tests/libs-for-tests/startup.d.ts +1 -0
  167. package/build/tests/libs-for-tests/startup.js +29 -0
  168. package/build/tests/libs-for-tests/watching.d.ts +7 -0
  169. package/build/tests/libs-for-tests/watching.js +33 -0
  170. package/build/tests/units/canonical-address.d.ts +1 -0
  171. package/build/tests/units/canonical-address.js +41 -0
  172. package/build/tests/units/device-fs.d.ts +1 -0
  173. package/build/tests/units/device-fs.js +70 -0
  174. package/build/tests/units/folder-node-serialization.d.ts +1 -0
  175. package/build/tests/units/folder-node-serialization.js +74 -0
  176. package/build/tests/units/mid-sigs-NaCl-Ed.d.ts +1 -0
  177. package/build/tests/units/mid-sigs-NaCl-Ed.js +123 -0
  178. package/build/tests/units/number-line.d.ts +1 -0
  179. package/build/tests/units/number-line.js +63 -0
  180. package/build/tests/units/obj-folders.d.ts +1 -0
  181. package/build/tests/units/obj-folders.js +152 -0
  182. package/package.json +11 -3
  183. package/postinstall.js +1 -1
  184. package/build/cryptors.d.ts +0 -1
  185. package/build/cryptors.js +0 -34
  186. package/build/lib-client/cryptor/cryptor-in-worker.d.ts +0 -20
  187. package/build/lib-client/cryptor/cryptor-in-worker.js +0 -357
  188. package/build/lib-client/cryptor/cryptor-wasm.js +0 -1
  189. package/build/lib-client/cryptor/cryptor.d.ts +0 -30
  190. package/build/lib-client/cryptor/cryptor.js +0 -44
  191. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  192. package/build/lib-client/cryptor/in-proc-js.d.ts +0 -2
  193. package/build/lib-client/cryptor/in-proc-js.js +0 -57
  194. package/build/lib-client/cryptor/in-proc-wasm.d.ts +0 -2
  195. package/build/lib-client/cryptor/in-proc-wasm.js +0 -176
  196. package/build/lib-client/cryptor/serialization-for-wasm.d.ts +0 -35
  197. package/build/lib-client/cryptor/serialization-for-wasm.js +0 -57
  198. package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +0 -5
  199. package/build/lib-client/cryptor/wasm-mp1-modules.js +0 -78
  200. package/build/lib-client/cryptor/worker-js.js +0 -131
  201. package/build/lib-client/cryptor/worker-wasm.js +0 -37
  202. package/build/protos/cryptor.proto.js +0 -1804
  203. /package/build/lib-client/{cryptor/cryptor-work-labels.d.ts → cryptor-work-labels.d.ts} +0 -0
  204. /package/build/lib-client/{cryptor/cryptor-work-labels.js → cryptor-work-labels.js} +0 -0
  205. /package/build/{lib-client/cryptor/worker-js.d.ts → tests/caps-api/asmail.d.ts} +0 -0
  206. /package/build/{lib-client/cryptor/worker-wasm.d.ts → tests/caps-api/keyrings.d.ts} +0 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ const json_equal_1 = require("../../../libs-for-tests/json-equal");
21
+ exports.specs = {
22
+ description: '.v.readJSONFile',
23
+ its: []
24
+ };
25
+ let it = { expectation: 'fails to read non-existent file' };
26
+ it.func = async function (s) {
27
+ const { testFS } = s;
28
+ let fName = 'unknown-file';
29
+ expect(await testFS.checkFilePresence(fName)).toBe(false);
30
+ await testFS.v.readJSONFile(fName)
31
+ .then(() => {
32
+ fail('reading json must fail, when file does not exist');
33
+ }, (err) => {
34
+ expect(err.notFound).toBe(true);
35
+ if (!err.notFound) {
36
+ throw err;
37
+ }
38
+ });
39
+ };
40
+ exports.specs.its.push(it);
41
+ it = { expectation: 'reads json file' };
42
+ it.func = async function (s) {
43
+ const { testFS } = s;
44
+ let original = { a: 'foo', b: true, 'df-df': 23 };
45
+ let fName = 'file1';
46
+ let v1 = await testFS.v.writeJSONFile(fName, original);
47
+ let { json, version } = await testFS.v.readJSONFile(fName);
48
+ expect((0, json_equal_1.deepEqual)(json, original)).withContext('file read should produce original json').toBe(true);
49
+ expect(version).withContext('file version at reading should exactly the same as that on respective write').toBe(v1);
50
+ let v2 = await testFS.v.writeBytes(fName, new Uint8Array(0));
51
+ expect(v2).toBeGreaterThan(v1);
52
+ await testFS.readJSONFile(fName)
53
+ .then(() => {
54
+ fail('reading empty file should fail, as empty is not valid json');
55
+ }, (exc) => {
56
+ expect(exc).toBeTruthy();
57
+ });
58
+ };
59
+ exports.specs.its.push(it);
60
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ exports.specs = {
21
+ description: '.v.readTxtFile',
22
+ its: []
23
+ };
24
+ let it = { expectation: 'fails to read non-existent file' };
25
+ it.func = async function (s) {
26
+ const { testFS } = s;
27
+ let fName = 'unknown-file';
28
+ expect(await testFS.checkFilePresence(fName)).toBe(false);
29
+ await testFS.v.readTxtFile(fName)
30
+ .then(() => {
31
+ fail('reading text must fail, when file does not exist');
32
+ }, (err) => {
33
+ expect(err.notFound).toBe(true);
34
+ if (!err.notFound) {
35
+ throw err;
36
+ }
37
+ });
38
+ };
39
+ exports.specs.its.push(it);
40
+ it = { expectation: 'reads json file' };
41
+ it.func = async function (s) {
42
+ const { testFS } = s;
43
+ let original = 'Should I be at BlackHat conference or working?';
44
+ let fName = 'file1';
45
+ let v1 = await testFS.v.writeTxtFile(fName, original);
46
+ let { txt, version } = await testFS.v.readTxtFile(fName);
47
+ expect(txt).withContext('file read should produce original text').toBe(original);
48
+ expect(version).withContext('file version at reading should exactly the same as that on respective write').toBe(v1);
49
+ let v2 = await testFS.v.writeBytes(fName, new Uint8Array(0));
50
+ expect(v2).toBeGreaterThan(v1);
51
+ ({ txt, version } = await testFS.v.readTxtFile(fName));
52
+ expect(txt).withContext('empty file should be read as an empty string').toBe('');
53
+ expect(version).withContext('file version at reading should exactly the same as that on respective write').toBe(v2);
54
+ };
55
+ exports.specs.its.push(it);
56
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016, 2018, 2020 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ exports.specs = {
21
+ description: '.stat',
22
+ its: []
23
+ };
24
+ let it = { expectation: 'fails to read non-existent path' };
25
+ it.func = async function (s) {
26
+ const { testFS } = s;
27
+ const fName = 'unknown-file';
28
+ expect(await testFS.checkFilePresence(fName)).toBe(false);
29
+ await testFS.stat(fName)
30
+ .then(() => {
31
+ fail('stat-ing must fail, when path does not exist');
32
+ }, (err) => {
33
+ expect(err.notFound).toBe(true);
34
+ if (!err.notFound) {
35
+ throw err;
36
+ }
37
+ });
38
+ };
39
+ exports.specs.its.push(it);
40
+ it = { expectation: 'stats file' };
41
+ it.func = async function (s) {
42
+ const { testFS } = s;
43
+ const original = 'Should I be at BlackHat conference or working?';
44
+ const originalFileSize = original.length;
45
+ const fName = 'file1';
46
+ await testFS.writeTxtFile(fName, original);
47
+ let stat = await testFS.stat(fName);
48
+ expect(typeof stat).toBe('object');
49
+ expect(stat).not.toBeNull();
50
+ expect(stat.isFile).withContext('flag indicating that path points to file').toBe(true);
51
+ expect(stat.size).withContext('file size').toBe(originalFileSize);
52
+ expect(typeof stat.version).toBe('number');
53
+ const fstVersion = stat.version;
54
+ const sndTxt = 'I better work!';
55
+ const sndVersionFileSize = sndTxt.length;
56
+ await testFS.writeTxtFile(fName, sndTxt);
57
+ stat = await testFS.stat(fName);
58
+ expect(stat.isFile).withContext('flag indicating that path points to file').toBe(true);
59
+ expect(stat.size).withContext('file size').toBe(sndVersionFileSize);
60
+ expect(stat.version).withContext('second version of the file').toBe(fstVersion + 1);
61
+ };
62
+ exports.specs.its.push(it);
63
+ it = { expectation: 'stats folder' };
64
+ it.func = async function (s) {
65
+ const { testFS } = s;
66
+ const fName = 'folder1';
67
+ await testFS.makeFolder(fName);
68
+ let stat = await testFS.stat(fName);
69
+ expect(typeof stat).toBe('object');
70
+ expect(stat).not.toBeNull();
71
+ expect(stat.isFolder).withContext('flag indicating that path points to folder').toBe(true);
72
+ expect(typeof stat.version).toBe('number');
73
+ const fstVersion = stat.version;
74
+ await testFS.writeTxtFile(`${fName}/some-file`, '');
75
+ stat = await testFS.stat(fName);
76
+ expect(stat.isFolder).withContext('flag indicating that path points to folder').toBe(true);
77
+ expect(stat.version).withContext('second version of the folder').toBe(fstVersion + 1);
78
+ };
79
+ exports.specs.its.push(it);
80
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2022 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ const deferred_1 = require("../../../../lib-common/processes/deferred");
21
+ exports.specs = {
22
+ description: '.watchFile',
23
+ its: []
24
+ };
25
+ let it = { expectation: 'fails to watch non-existent path' };
26
+ it.func = async function (s) {
27
+ const { testFS } = s;
28
+ const fName = 'unknown-file';
29
+ expect(await testFS.checkFilePresence(fName)).toBe(false);
30
+ const expectedExc = (0, deferred_1.defer)();
31
+ const sub = testFS.watchFile(fName, {
32
+ next: () => expectedExc.reject('watching must fail, when path does not exist'),
33
+ complete: () => expectedExc.reject('watching must fail, when path does not exist'),
34
+ error: exc => expectedExc.resolve(exc)
35
+ });
36
+ const exc = await expectedExc.promise;
37
+ expect(exc.type).toBe('file');
38
+ expect(exc.notFound).toBe(true);
39
+ };
40
+ exports.specs.its.push(it);
41
+ it = { expectation: 'gets file change event' };
42
+ it.func = async function (s) {
43
+ const { testFS } = s;
44
+ const fName = 'file to watch';
45
+ await testFS.writeTxtFile(fName, '');
46
+ const expectedEv = (0, deferred_1.defer)();
47
+ const unsub = testFS.watchFile(fName, {
48
+ next: ev => {
49
+ if (ev.type === 'file-change') {
50
+ expectedEv.resolve(ev);
51
+ }
52
+ },
53
+ complete: () => expectedEv.reject(`Early completion`),
54
+ error: err => expectedEv.reject(err)
55
+ });
56
+ // change file to get file
57
+ await testFS.writeTxtFile(fName, 'new value');
58
+ const changeEvent = await expectedEv.promise;
59
+ expect(changeEvent.src).toBe('local');
60
+ expect(typeof changeEvent.newVersion).toBe('number');
61
+ unsub();
62
+ };
63
+ exports.specs.its.push(it);
64
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016 - 2018, 2020, 2022 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ const random_node_1 = require("../../../../lib-common/random-node");
21
+ const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
22
+ exports.specs = {
23
+ description: '.v.writeBytes',
24
+ its: []
25
+ };
26
+ let it = { expectation: 'if not allowed to create, fails for missing file' };
27
+ it.func = async function (s) {
28
+ const { testFS } = s;
29
+ await testFS.v.writeBytes('non-existing-file', (0, random_node_1.bytesSync)(123), {})
30
+ .then(() => {
31
+ fail('should fail for missing file');
32
+ }, (e) => {
33
+ expect(e.notFound).toBe(true);
34
+ });
35
+ };
36
+ exports.specs.its.push(it);
37
+ it = { expectation: 'creates file in existing folder' };
38
+ it.func = async function (s) {
39
+ const { testFS } = s;
40
+ let path = 'file1';
41
+ let content = (0, random_node_1.bytesSync)(2 * 1024);
42
+ expect(await testFS.checkFilePresence(path)).toBe(false);
43
+ let v = await testFS.v.writeBytes(path, content);
44
+ expect(await testFS.checkFilePresence(path)).toBe(true);
45
+ let { bytes, version } = await testFS.v.readBytes(path);
46
+ expect((0, bytes_equal_1.bytesEqual)(content, bytes)).toBe(true);
47
+ expect(version).toBe(v);
48
+ };
49
+ exports.specs.its.push(it);
50
+ it = { expectation: 'creates parent folder(s) on the way' };
51
+ it.func = async function (s) {
52
+ const { testFS } = s;
53
+ let fName = 'file2';
54
+ let grParent = 'grand-parent';
55
+ let parent2 = 'grand-parent/parent2';
56
+ let path = `${parent2}/${fName}`;
57
+ expect(await testFS.checkFolderPresence(grParent)).toBe(false);
58
+ expect(await testFS.checkFolderPresence(parent2)).toBe(false);
59
+ expect(await testFS.checkFolderPresence(path)).toBe(false);
60
+ let content = (0, random_node_1.bytesSync)(2 * 1024);
61
+ let v = await testFS.v.writeBytes(path, content);
62
+ expect(await testFS.checkFolderPresence(grParent)).toBe(true);
63
+ expect(await testFS.checkFolderPresence(parent2)).toBe(true);
64
+ expect(await testFS.checkFilePresence(path)).toBe(true);
65
+ let { bytes, version } = await testFS.v.readBytes(path);
66
+ expect((0, bytes_equal_1.bytesEqual)(content, bytes)).toBe(true);
67
+ expect(version).toBe(v);
68
+ };
69
+ exports.specs.its.push(it);
70
+ it = { expectation: 'over-writes existing file with a non-exclusive call' };
71
+ it.func = async function (s) {
72
+ const { testFS } = s;
73
+ let path = 'file3';
74
+ // setup initial file
75
+ let initBytes = (0, random_node_1.bytesSync)(123);
76
+ let v1 = await testFS.v.writeBytes(path, initBytes);
77
+ expect(await testFS.checkFilePresence(path)).toBe(true);
78
+ let { bytes, version } = await testFS.v.readBytes(path);
79
+ expect((0, bytes_equal_1.bytesEqual)(initBytes, bytes)).toBe(true);
80
+ expect(version).toBe(v1);
81
+ // write new file content
82
+ let newContent = (0, random_node_1.bytesSync)(3223);
83
+ let v2 = await testFS.v.writeBytes(path, newContent);
84
+ expect(await testFS.checkFilePresence(path)).toBe(true);
85
+ expect(v2).toBeGreaterThan(v1);
86
+ ({ bytes, version } = await testFS.v.readBytes(path));
87
+ expect(version).toBe(v2);
88
+ expect((0, bytes_equal_1.bytesEqual)(newContent, bytes)).toBe(true);
89
+ };
90
+ exports.specs.its.push(it);
91
+ it = { expectation: 'exclusive-create write throws when file already exists' };
92
+ it.func = async function (s) {
93
+ const { testFS } = s;
94
+ let path = 'file4';
95
+ // setup initial file
96
+ let initBytes = (0, random_node_1.bytesSync)(123);
97
+ let v = await testFS.v.writeBytes(path, initBytes);
98
+ expect(await testFS.checkFilePresence(path)).toBe(true);
99
+ // try an exclusive write
100
+ let newContent = (0, random_node_1.bytesSync)(3223);
101
+ await testFS.writeBytes(path, newContent, { create: true, exclusive: true })
102
+ .then(() => {
103
+ fail('exclusive-create write operation must fail, when file exists.');
104
+ }, (exc) => {
105
+ expect(exc.alreadyExists).toBe(true);
106
+ });
107
+ let { bytes, version } = await testFS.v.readBytes(path);
108
+ expect((0, bytes_equal_1.bytesEqual)(initBytes, bytes)).withContext('initial file content stays intact').toBe(true);
109
+ expect(version).withContext('initial file version stays intact').toBe(v);
110
+ };
111
+ exports.specs.its.push(it);
112
+ it = { expectation: 'writes 4K-even content' };
113
+ it.func = async function (s) {
114
+ const { testFS } = s;
115
+ const kb4 = 4 * 1024;
116
+ for (const [fName, contentLen] of [
117
+ ['file-20kb', 5 * kb4],
118
+ ['file-4kb', kb4],
119
+ ['file-16kb', 4 * kb4],
120
+ ]) {
121
+ const content = (0, random_node_1.bytesSync)(contentLen);
122
+ await testFS.v.writeBytes(fName, content);
123
+ expect((0, bytes_equal_1.bytesEqual)((await testFS.v.readBytes(fName)).bytes, content))
124
+ .toBeTrue();
125
+ }
126
+ };
127
+ exports.specs.its.push(it);
128
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ const json_equal_1 = require("../../../libs-for-tests/json-equal");
21
+ exports.specs = {
22
+ description: '.v.writeJSONFile',
23
+ its: []
24
+ };
25
+ let it = { expectation: 'if not allowed to create, fails for missing file' };
26
+ it.func = async function (s) {
27
+ const { testFS } = s;
28
+ let json = { a: 1, b: 2 };
29
+ await testFS.v.writeJSONFile('non-existing-file', json, {})
30
+ .then(() => {
31
+ fail('should fail for missing file');
32
+ }, (e) => {
33
+ expect(e.notFound).toBe(true);
34
+ });
35
+ };
36
+ exports.specs.its.push(it);
37
+ it = { expectation: 'creates file in existing folder' };
38
+ it.func = async function (s) {
39
+ const { testFS } = s;
40
+ let path = 'file1';
41
+ let initJson = { a: 1, b: 2 };
42
+ expect(await testFS.checkFilePresence(path)).toBe(false);
43
+ let v = await testFS.v.writeJSONFile(path, initJson);
44
+ expect(await testFS.checkFilePresence(path)).toBe(true);
45
+ let { json, version } = await testFS.v.readJSONFile(path);
46
+ expect((0, json_equal_1.deepEqual)(initJson, json)).toBe(true);
47
+ expect(version).toBe(v);
48
+ };
49
+ exports.specs.its.push(it);
50
+ it = { expectation: 'creates parent folder(s) on the way' };
51
+ it.func = async function (s) {
52
+ const { testFS } = s;
53
+ let fName = 'file2';
54
+ let grParent = 'grand-parent';
55
+ let parent2 = 'grand-parent/parent2';
56
+ let path = `${parent2}/${fName}`;
57
+ expect(await testFS.checkFolderPresence(grParent)).toBe(false);
58
+ expect(await testFS.checkFolderPresence(parent2)).toBe(false);
59
+ expect(await testFS.checkFolderPresence(path)).toBe(false);
60
+ let initJson = { a: 'foo', b: true, 'df-df': 23 };
61
+ let v = await testFS.v.writeJSONFile(path, initJson);
62
+ expect(await testFS.checkFolderPresence(grParent)).toBe(true);
63
+ expect(await testFS.checkFolderPresence(parent2)).toBe(true);
64
+ expect(await testFS.checkFilePresence(path)).toBe(true);
65
+ let { json, version } = await testFS.v.readJSONFile(path);
66
+ expect((0, json_equal_1.deepEqual)(initJson, json)).toBe(true);
67
+ expect(version).toBe(v);
68
+ };
69
+ exports.specs.its.push(it);
70
+ it = { expectation: 'over-writes existing file with a non-exclusive call' };
71
+ it.func = async function (s) {
72
+ const { testFS } = s;
73
+ let path = 'file3';
74
+ // setup initial file
75
+ let initJson = { a: 'foo', b: true, 'df-df': 23 };
76
+ let v1 = await testFS.v.writeJSONFile(path, initJson);
77
+ expect(await testFS.checkFilePresence(path)).toBe(true);
78
+ let { json, version } = await testFS.v.readJSONFile(path);
79
+ expect((0, json_equal_1.deepEqual)(initJson, json)).toBe(true);
80
+ expect(version).toBe(v1);
81
+ // write new file content
82
+ let newJson = null;
83
+ let v2 = await testFS.v.writeJSONFile(path, newJson);
84
+ expect(await testFS.checkFilePresence(path)).toBe(true);
85
+ ({ json, version } = await testFS.v.readJSONFile(path));
86
+ expect((0, json_equal_1.deepEqual)(newJson, json)).toBe(true);
87
+ expect(version).toBe(v2);
88
+ };
89
+ exports.specs.its.push(it);
90
+ it = { expectation: 'exclusive-create write throws when file already exists' };
91
+ it.func = async function (s) {
92
+ const { testFS } = s;
93
+ let path = 'file4';
94
+ // setup initial file
95
+ let initJson = { a: 'foo', b: true, 'df-df': 23 };
96
+ let v = await testFS.v.writeJSONFile(path, initJson);
97
+ expect(await testFS.checkFilePresence(path)).toBe(true);
98
+ // try an exclusive write
99
+ let newJson = null;
100
+ await testFS.writeJSONFile(path, newJson, { create: true, exclusive: true })
101
+ .then(() => {
102
+ fail('exclusive-create write operation must fail, when file exists.');
103
+ }, (exc) => {
104
+ expect(exc.alreadyExists).toBe(true);
105
+ });
106
+ let { json, version } = await testFS.v.readJSONFile(path);
107
+ expect((0, json_equal_1.deepEqual)(initJson, json)).withContext('initial file content stays intact').toBe(true);
108
+ expect(version).withContext('initial file version stays intact').toBe(v);
109
+ };
110
+ exports.specs.its.push(it);
111
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ exports.specs = {
21
+ description: '.v.writeTxtFile',
22
+ its: []
23
+ };
24
+ let it = { expectation: 'if not allowed to create, fails for missing file' };
25
+ it.func = async function (s) {
26
+ const { testFS } = s;
27
+ let txt = 'Should I be at BlackHat conference or working?';
28
+ await testFS.v.writeTxtFile('non-existing-file', txt, {})
29
+ .then(() => {
30
+ fail('should fail for missing file');
31
+ }, (e) => {
32
+ expect(e.notFound).toBe(true);
33
+ });
34
+ };
35
+ exports.specs.its.push(it);
36
+ it = { expectation: 'creates file in existing folder' };
37
+ it.func = async function (s) {
38
+ const { testFS } = s;
39
+ let path = 'file1';
40
+ let txt = 'Should I be at BlackHat conference or working?';
41
+ expect(await testFS.checkFilePresence(path)).toBe(false);
42
+ await testFS.writeTxtFile(path, txt);
43
+ expect(await testFS.checkFilePresence(path)).toBe(true);
44
+ expect((await testFS.v.readTxtFile(path)).txt).toBe(txt);
45
+ };
46
+ exports.specs.its.push(it);
47
+ it = { expectation: 'creates parent folder(s) on the way' };
48
+ it.func = async function (s) {
49
+ const { testFS } = s;
50
+ let fName = 'file2';
51
+ let grParent = 'grand-parent';
52
+ let parent2 = 'grand-parent/parent2';
53
+ let path = `${parent2}/${fName}`;
54
+ expect(await testFS.checkFolderPresence(grParent)).toBe(false);
55
+ expect(await testFS.checkFolderPresence(parent2)).toBe(false);
56
+ expect(await testFS.checkFolderPresence(path)).toBe(false);
57
+ let txt = 'Should I be at BlackHat conference or working?';
58
+ await testFS.writeTxtFile(path, txt);
59
+ expect(await testFS.checkFolderPresence(grParent)).toBe(true);
60
+ expect(await testFS.checkFolderPresence(parent2)).toBe(true);
61
+ expect(await testFS.checkFilePresence(path)).toBe(true);
62
+ expect((await testFS.v.readTxtFile(path)).txt).toBe(txt);
63
+ };
64
+ exports.specs.its.push(it);
65
+ it = { expectation: 'over-writes existing file with a non-exclusive call' };
66
+ it.func = async function (s) {
67
+ const { testFS } = s;
68
+ let path = 'file3';
69
+ // setup initial file
70
+ let initTxt = 'Should I be at BlackHat conference or working?';
71
+ let v1 = await testFS.v.writeTxtFile(path, initTxt);
72
+ expect(await testFS.checkFilePresence(path)).toBe(true);
73
+ let { txt, version } = await testFS.v.readTxtFile(path);
74
+ expect(txt).toBe(initTxt);
75
+ expect(version).toBe(v1);
76
+ // write new file content
77
+ let newTxt = 'Work gives tangible benefits.\nRetire and go anywhere.';
78
+ let v2 = await testFS.v.writeTxtFile(path, newTxt);
79
+ expect(await testFS.checkFilePresence(path)).toBe(true);
80
+ expect(v2).toBeGreaterThan(v1);
81
+ ({ txt, version } = await testFS.v.readTxtFile(path));
82
+ expect(txt).toBe(newTxt);
83
+ expect(version).toBe(v2);
84
+ };
85
+ exports.specs.its.push(it);
86
+ it = { expectation: 'exclusive-create write throws when file already exists' };
87
+ it.func = async function (s) {
88
+ const { testFS } = s;
89
+ let path = 'file4';
90
+ // setup initial file
91
+ let initTxt = 'Should I be at BlackHat conference or working?';
92
+ let v = await testFS.v.writeTxtFile(path, initTxt);
93
+ expect(await testFS.checkFilePresence(path)).toBe(true);
94
+ // try an exclusive write
95
+ let newTxt = 'Work gives tangible benefits.\nRetire and go anywhere.';
96
+ await testFS.writeTxtFile(path, newTxt, { create: true, exclusive: true })
97
+ .then(() => {
98
+ fail('exclusive-create write operation must fail, when file exists.');
99
+ }, (exc) => {
100
+ expect(exc.alreadyExists).toBe(true);
101
+ });
102
+ let { txt, version } = await testFS.v.readTxtFile(path);
103
+ expect(txt).withContext('initial file content stays intact').toBe(initTxt);
104
+ expect(version).withContext('initial file version stays intact').toBe(v);
105
+ };
106
+ exports.specs.its.push(it);
107
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;