core-3nweb-client-lib 0.44.12 → 0.45.1

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 (209) 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/doh.d.ts +2 -0
  10. package/build/lib-client/doh.js +68 -0
  11. package/build/lib-client/key-derivation.d.ts +1 -1
  12. package/build/lib-client/request-utils.js +1 -1
  13. package/build/lib-client/service-checks.js +3 -11
  14. package/build/lib-client/service-locator.d.ts +10 -2
  15. package/build/lib-client/service-locator.js +40 -27
  16. package/build/lib-client/xsp-fs/node-persistence.js +1 -1
  17. package/build/lib-index.d.ts +1 -0
  18. package/build/lib-index.js +3 -1
  19. package/build/tests/caps-api/asmail/specs/events.d.ts +2 -0
  20. package/build/tests/caps-api/asmail/specs/events.js +63 -0
  21. package/build/tests/caps-api/asmail/specs/send-to-wrong-address.d.ts +2 -0
  22. package/build/tests/caps-api/asmail/specs/send-to-wrong-address.js +68 -0
  23. package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.d.ts +2 -0
  24. package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +259 -0
  25. package/build/tests/caps-api/asmail/specs/send-without-attachments.d.ts +2 -0
  26. package/build/tests/caps-api/asmail/specs/send-without-attachments.js +90 -0
  27. package/build/tests/caps-api/asmail/test-utils.d.ts +12 -0
  28. package/build/tests/caps-api/asmail/test-utils.js +60 -0
  29. package/build/tests/caps-api/asmail.js +86 -0
  30. package/build/tests/caps-api/file-sink-checks/different-cases.d.ts +2 -0
  31. package/build/tests/caps-api/file-sink-checks/different-cases.js +47 -0
  32. package/build/tests/caps-api/file-sink-checks/splice.d.ts +2 -0
  33. package/build/tests/caps-api/file-sink-checks/splice.js +122 -0
  34. package/build/tests/caps-api/file-sink-checks/truncate.d.ts +2 -0
  35. package/build/tests/caps-api/file-sink-checks/truncate.js +122 -0
  36. package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.d.ts +2 -0
  37. package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.js +82 -0
  38. package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.d.ts +2 -0
  39. package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.js +50 -0
  40. package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.d.ts +2 -0
  41. package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.js +73 -0
  42. package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.d.ts +2 -0
  43. package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.js +75 -0
  44. package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.d.ts +2 -0
  45. package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +96 -0
  46. package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.d.ts +2 -0
  47. package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +67 -0
  48. package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.d.ts +2 -0
  49. package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.js +77 -0
  50. package/build/tests/caps-api/fs-checks/not-versioned/link.d.ts +2 -0
  51. package/build/tests/caps-api/fs-checks/not-versioned/link.js +115 -0
  52. package/build/tests/caps-api/fs-checks/not-versioned/listFolder.d.ts +2 -0
  53. package/build/tests/caps-api/fs-checks/not-versioned/listFolder.js +129 -0
  54. package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.d.ts +2 -0
  55. package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.js +73 -0
  56. package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.d.ts +2 -0
  57. package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.js +95 -0
  58. package/build/tests/caps-api/fs-checks/not-versioned/move.d.ts +2 -0
  59. package/build/tests/caps-api/fs-checks/not-versioned/move.js +127 -0
  60. package/build/tests/caps-api/fs-checks/not-versioned/readBytes.d.ts +2 -0
  61. package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +80 -0
  62. package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.d.ts +2 -0
  63. package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.js +59 -0
  64. package/build/tests/caps-api/fs-checks/not-versioned/readLink.d.ts +2 -0
  65. package/build/tests/caps-api/fs-checks/not-versioned/readLink.js +39 -0
  66. package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.d.ts +2 -0
  67. package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.js +54 -0
  68. package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.d.ts +2 -0
  69. package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.js +55 -0
  70. package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.d.ts +2 -0
  71. package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.js +55 -0
  72. package/build/tests/caps-api/fs-checks/not-versioned/select.d.ts +2 -0
  73. package/build/tests/caps-api/fs-checks/not-versioned/select.js +119 -0
  74. package/build/tests/caps-api/fs-checks/not-versioned/stat.d.ts +2 -0
  75. package/build/tests/caps-api/fs-checks/not-versioned/stat.js +96 -0
  76. package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.d.ts +2 -0
  77. package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.js +126 -0
  78. package/build/tests/caps-api/fs-checks/not-versioned/writableFile.d.ts +2 -0
  79. package/build/tests/caps-api/fs-checks/not-versioned/writableFile.js +79 -0
  80. package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.d.ts +2 -0
  81. package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.js +90 -0
  82. package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.d.ts +2 -0
  83. package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +137 -0
  84. package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.d.ts +2 -0
  85. package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.js +101 -0
  86. package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.d.ts +2 -0
  87. package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.js +100 -0
  88. package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.d.ts +2 -0
  89. package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +187 -0
  90. package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.d.ts +2 -0
  91. package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +70 -0
  92. package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.d.ts +2 -0
  93. package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +53 -0
  94. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.d.ts +2 -0
  95. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +194 -0
  96. package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.d.ts +2 -0
  97. package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +396 -0
  98. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.d.ts +2 -0
  99. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +229 -0
  100. package/build/tests/caps-api/fs-checks/test-utils.d.ts +34 -0
  101. package/build/tests/caps-api/fs-checks/test-utils.js +95 -0
  102. package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.d.ts +2 -0
  103. package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +73 -0
  104. package/build/tests/caps-api/fs-checks/versioned/getByteSink.d.ts +2 -0
  105. package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +122 -0
  106. package/build/tests/caps-api/fs-checks/versioned/getByteSource.d.ts +2 -0
  107. package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +71 -0
  108. package/build/tests/caps-api/fs-checks/versioned/listFolder.d.ts +2 -0
  109. package/build/tests/caps-api/fs-checks/versioned/listFolder.js +109 -0
  110. package/build/tests/caps-api/fs-checks/versioned/listVersions.d.ts +2 -0
  111. package/build/tests/caps-api/fs-checks/versioned/listVersions.js +48 -0
  112. package/build/tests/caps-api/fs-checks/versioned/readBytes.d.ts +2 -0
  113. package/build/tests/caps-api/fs-checks/versioned/readBytes.js +90 -0
  114. package/build/tests/caps-api/fs-checks/versioned/readJSONFile.d.ts +2 -0
  115. package/build/tests/caps-api/fs-checks/versioned/readJSONFile.js +60 -0
  116. package/build/tests/caps-api/fs-checks/versioned/readTxtFile.d.ts +2 -0
  117. package/build/tests/caps-api/fs-checks/versioned/readTxtFile.js +56 -0
  118. package/build/tests/caps-api/fs-checks/versioned/stat.d.ts +2 -0
  119. package/build/tests/caps-api/fs-checks/versioned/stat.js +80 -0
  120. package/build/tests/caps-api/fs-checks/versioned/watchFile.d.ts +2 -0
  121. package/build/tests/caps-api/fs-checks/versioned/watchFile.js +64 -0
  122. package/build/tests/caps-api/fs-checks/versioned/writeBytes.d.ts +2 -0
  123. package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +128 -0
  124. package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.d.ts +2 -0
  125. package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.js +111 -0
  126. package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.d.ts +2 -0
  127. package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.js +107 -0
  128. package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.d.ts +2 -0
  129. package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +50 -0
  130. package/build/tests/caps-api/keyrings.js +69 -0
  131. package/build/tests/caps-api/mailerid.d.ts +1 -0
  132. package/build/tests/caps-api/mailerid.js +59 -0
  133. package/build/tests/caps-api/startup/signin-empty-cache.d.ts +1 -0
  134. package/build/tests/caps-api/startup/signin-empty-cache.js +108 -0
  135. package/build/tests/caps-api/startup/signin-with-cache.d.ts +1 -0
  136. package/build/tests/caps-api/startup/signin-with-cache.js +83 -0
  137. package/build/tests/caps-api/startup/signup-with-token.d.ts +1 -0
  138. package/build/tests/caps-api/startup/signup-with-token.js +53 -0
  139. package/build/tests/caps-api/startup/signup.d.ts +1 -0
  140. package/build/tests/caps-api/startup/signup.js +86 -0
  141. package/build/tests/caps-api/storage.d.ts +1 -0
  142. package/build/tests/caps-api/storage.js +225 -0
  143. package/build/tests/computer.3nweb.core/id-manager.d.ts +1 -0
  144. package/build/tests/computer.3nweb.core/id-manager.js +78 -0
  145. package/build/tests/computer.3nweb.core/inbox/msg-indexing.d.ts +1 -0
  146. package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +145 -0
  147. package/build/tests/computer.3nweb.core/keyrings.d.ts +1 -0
  148. package/build/tests/computer.3nweb.core/keyrings.js +64 -0
  149. package/build/tests/computer.3nweb.core/test-utils.d.ts +21 -0
  150. package/build/tests/computer.3nweb.core/test-utils.js +92 -0
  151. package/build/tests/jasmine.d.ts +1 -0
  152. package/build/tests/jasmine.js +45 -0
  153. package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
  154. package/build/tests/libs-for-tests/bytes-equal.js +32 -0
  155. package/build/tests/libs-for-tests/caps-ipc-wrap.d.ts +11 -0
  156. package/build/tests/libs-for-tests/caps-ipc-wrap.js +55 -0
  157. package/build/tests/libs-for-tests/core-runner.d.ts +39 -0
  158. package/build/tests/libs-for-tests/core-runner.js +231 -0
  159. package/build/tests/libs-for-tests/jasmine-utils.d.ts +13 -0
  160. package/build/tests/libs-for-tests/jasmine-utils.js +110 -0
  161. package/build/tests/libs-for-tests/json-equal.d.ts +1 -0
  162. package/build/tests/libs-for-tests/json-equal.js +78 -0
  163. package/build/tests/libs-for-tests/services-runner.d.ts +18 -0
  164. package/build/tests/libs-for-tests/services-runner.js +64 -0
  165. package/build/tests/libs-for-tests/setups.d.ts +51 -0
  166. package/build/tests/libs-for-tests/setups.js +305 -0
  167. package/build/tests/libs-for-tests/spec-module.d.ts +16 -0
  168. package/build/tests/libs-for-tests/spec-module.js +92 -0
  169. package/build/tests/libs-for-tests/startup.d.ts +1 -0
  170. package/build/tests/libs-for-tests/startup.js +29 -0
  171. package/build/tests/libs-for-tests/watching.d.ts +7 -0
  172. package/build/tests/libs-for-tests/watching.js +33 -0
  173. package/build/tests/units/canonical-address.d.ts +1 -0
  174. package/build/tests/units/canonical-address.js +41 -0
  175. package/build/tests/units/device-fs.d.ts +1 -0
  176. package/build/tests/units/device-fs.js +70 -0
  177. package/build/tests/units/folder-node-serialization.d.ts +1 -0
  178. package/build/tests/units/folder-node-serialization.js +74 -0
  179. package/build/tests/units/mid-sigs-NaCl-Ed.d.ts +1 -0
  180. package/build/tests/units/mid-sigs-NaCl-Ed.js +123 -0
  181. package/build/tests/units/number-line.d.ts +1 -0
  182. package/build/tests/units/number-line.js +63 -0
  183. package/build/tests/units/obj-folders.d.ts +1 -0
  184. package/build/tests/units/obj-folders.js +152 -0
  185. package/package.json +11 -3
  186. package/postinstall.js +1 -1
  187. package/build/cryptors.d.ts +0 -1
  188. package/build/cryptors.js +0 -34
  189. package/build/lib-client/cryptor/cryptor-in-worker.d.ts +0 -20
  190. package/build/lib-client/cryptor/cryptor-in-worker.js +0 -357
  191. package/build/lib-client/cryptor/cryptor-wasm.js +0 -1
  192. package/build/lib-client/cryptor/cryptor.d.ts +0 -30
  193. package/build/lib-client/cryptor/cryptor.js +0 -44
  194. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  195. package/build/lib-client/cryptor/in-proc-js.d.ts +0 -2
  196. package/build/lib-client/cryptor/in-proc-js.js +0 -57
  197. package/build/lib-client/cryptor/in-proc-wasm.d.ts +0 -2
  198. package/build/lib-client/cryptor/in-proc-wasm.js +0 -176
  199. package/build/lib-client/cryptor/serialization-for-wasm.d.ts +0 -35
  200. package/build/lib-client/cryptor/serialization-for-wasm.js +0 -57
  201. package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +0 -5
  202. package/build/lib-client/cryptor/wasm-mp1-modules.js +0 -78
  203. package/build/lib-client/cryptor/worker-js.js +0 -131
  204. package/build/lib-client/cryptor/worker-wasm.js +0 -37
  205. package/build/protos/cryptor.proto.js +0 -1804
  206. /package/build/lib-client/{cryptor/cryptor-work-labels.d.ts → cryptor-work-labels.d.ts} +0 -0
  207. /package/build/lib-client/{cryptor/cryptor-work-labels.js → cryptor-work-labels.js} +0 -0
  208. /package/build/{lib-client/cryptor/worker-js.d.ts → tests/caps-api/asmail.d.ts} +0 -0
  209. /package/build/{lib-client/cryptor/worker-wasm.d.ts → tests/caps-api/keyrings.d.ts} +0 -0
@@ -0,0 +1,67 @@
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 random_node_1 = require("../../../../lib-common/random-node");
21
+ const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
22
+ exports.specs = {
23
+ description: '.getByteSource',
24
+ its: []
25
+ };
26
+ let it = { expectation: 'fails to read non-existent file' };
27
+ it.func = async function (s) {
28
+ const { testFS } = s;
29
+ await testFS.getByteSource('non-existing-file')
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: 'reads file bytes with seeking available' };
38
+ it.func = async function (s) {
39
+ const { testFS } = s;
40
+ const original = (0, random_node_1.bytesSync)(12 * 1024 + 3);
41
+ let fName = 'file1';
42
+ await testFS.writeBytes(fName, original);
43
+ let src = await testFS.getByteSource(fName);
44
+ expect(await src.getPosition()).toBe(0);
45
+ let chunk = await src.readNext(200);
46
+ expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(0, 200))).toBe(true);
47
+ await src.seek(3000);
48
+ expect(await src.getPosition()).withContext('seek method changes position in file.').toBe(3000);
49
+ chunk = await src.readNext(200);
50
+ expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(3000, 3200))).toBe(true);
51
+ await src.seek(11000);
52
+ expect(await src.getPosition()).withContext('seek method changes position in file.').toBe(11000);
53
+ chunk = await src.readNext(200);
54
+ expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(11000, 11200))).toBe(true);
55
+ chunk = await src.readAt(1000, 200);
56
+ expect(await src.getPosition()).toBe(1200);
57
+ expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(1000, 1200))).toBe(true);
58
+ chunk = await src.readNext(undefined);
59
+ expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(1200))).withContext('read should be from current position to file\'s end').toBe(true);
60
+ expect(typeof (await src.readNext(100))).withContext('undefined is returned, when there are no more bytes to read').toBe('undefined');
61
+ fName = 'file2';
62
+ await testFS.writeBytes(fName, new Uint8Array(0));
63
+ src = await testFS.getByteSource(fName);
64
+ expect(typeof (await src.readNext(100))).withContext('reading empty file should produce undefined').toBe('undefined');
65
+ };
66
+ exports.specs.its.push(it);
67
+ 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,77 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 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: '.getXAttr',
22
+ its: []
23
+ };
24
+ let it = {
25
+ expectation: 'fails to read xattr for non-existent path',
26
+ notIncludedIn: 'device-fs'
27
+ };
28
+ it.func = async function (s) {
29
+ const { testFS } = s;
30
+ let fName = 'unknown-file';
31
+ await testFS.getXAttr(fName, 'attribute name')
32
+ .then(() => {
33
+ fail('stat-ing must fail, when path does not exist');
34
+ }, (err) => {
35
+ expect(err.notFound).toBe(true);
36
+ if (!err.notFound) {
37
+ throw err;
38
+ }
39
+ });
40
+ };
41
+ exports.specs.its.push(it);
42
+ it = {
43
+ expectation: 'reads extended attribute',
44
+ notIncludedIn: 'device-fs'
45
+ };
46
+ it.func = async function (s) {
47
+ const { testFS } = s;
48
+ async function testforPath(path) {
49
+ let attrValue = await testFS.getXAttr(path, 'unknown attribute');
50
+ expect((attrValue === null) || (attrValue === undefined)).withContext('value of attribute that is not present').toBe(true);
51
+ const attr1Name = 'attribute name 1';
52
+ const attr1Value = 'some string value';
53
+ const attr2Name = 'attr2';
54
+ const attr2Value = 1234;
55
+ await testFS.updateXAttrs(path, {
56
+ set: {
57
+ [attr1Name]: attr1Value,
58
+ [attr2Name]: attr2Value
59
+ }
60
+ });
61
+ attrValue = await testFS.getXAttr(path, attr1Name);
62
+ expect(attrValue).toBe(attr1Value);
63
+ attrValue = await testFS.getXAttr(path, attr2Name);
64
+ expect(attrValue).toBe(attr2Value);
65
+ }
66
+ const file = 'file1';
67
+ await testFS.writeTxtFile(file, '');
68
+ await testforPath(file);
69
+ const file2 = 'file2';
70
+ await testFS.writeTxtFile(file2, 'non-empty');
71
+ await testforPath(file2);
72
+ const folder = 'folder1';
73
+ await testFS.makeFolder(folder);
74
+ await testforPath(folder);
75
+ };
76
+ exports.specs.its.push(it);
77
+ 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,115 @@
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: '.link, when linking in the same storage,',
22
+ its: []
23
+ };
24
+ let it = {
25
+ expectation: 'links readonly file',
26
+ notIncludedIn: 'win-local-fs'
27
+ };
28
+ it.func = async function (s) {
29
+ const { testFS } = s;
30
+ const original = 'Should I be at BlackHat conference or working?';
31
+ const fName = 'file1';
32
+ await testFS.writeTxtFile(fName, original);
33
+ let file = await testFS.readonlyFile(fName);
34
+ const linkPath = 'link1';
35
+ await testFS.link(linkPath, file);
36
+ const link = await testFS.readLink(linkPath);
37
+ expect(link.isFile).toBe(true, 'this link should be for a file');
38
+ expect(link.readonly).toBe(true, 'target extractable via this link should be readonly');
39
+ file = (await link.target());
40
+ expect(!!file).withContext('target should be instantiated').toBe(true);
41
+ expect(file.writable).toBe(false);
42
+ expect(await file.readTxt()).toBe(original);
43
+ };
44
+ exports.specs.its.push(it);
45
+ it = {
46
+ expectation: 'links writable file',
47
+ notIncludedIn: 'win-local-fs'
48
+ };
49
+ it.func = async function (s) {
50
+ const { testFS } = s;
51
+ const original = 'Should I be at BlackHat conference or working?';
52
+ const fName = 'file2';
53
+ await testFS.writeTxtFile(fName, original);
54
+ let file = await testFS.writableFile(fName);
55
+ const linkPath = 'link2';
56
+ await testFS.link(linkPath, file);
57
+ const link = await testFS.readLink(linkPath);
58
+ expect(link.isFile).withContext('this link should be for a file').toBe(true);
59
+ expect(link.readonly).withContext('this link should be writable').toBe(false);
60
+ file = (await link.target());
61
+ expect(!!file).withContext('target should be instantiated').toBe(true);
62
+ expect(file.writable).toBe(true);
63
+ expect(await file.readTxt()).toBe(original);
64
+ const newTxt = 'I better work. A-a-a!!!';
65
+ await file.writeTxt(newTxt);
66
+ expect(await file.readTxt()).toBe(newTxt);
67
+ };
68
+ exports.specs.its.push(it);
69
+ it = {
70
+ expectation: 'links writable folder',
71
+ notIncludedIn: 'win-local-fs'
72
+ };
73
+ it.func = async function (s) {
74
+ const { testFS } = s;
75
+ const original = 'Should I be at BlackHat conference or working?';
76
+ const folderName = 'folder1';
77
+ const fName = 'file1';
78
+ await testFS.writeTxtFile(`${folderName}/${fName}`, original);
79
+ let folder = await testFS.writableSubRoot(folderName);
80
+ const linkPath = 'link3';
81
+ await testFS.link(linkPath, folder);
82
+ const link = await testFS.readLink(linkPath);
83
+ expect(link.isFolder).withContext('this link should be for a folder').toBe(true);
84
+ expect(link.readonly).withContext('this link should be writable').toBe(false);
85
+ folder = (await link.target());
86
+ expect(!!folder).withContext('target should be instantiated').toBe(true);
87
+ expect(folder.writable).toBe(true);
88
+ expect(await folder.readTxtFile(fName)).toBe(original);
89
+ const newTxt = 'I better work. A-a-a!!!';
90
+ await folder.writeTxtFile(fName, newTxt);
91
+ expect(await folder.readTxtFile(fName)).toBe(newTxt);
92
+ };
93
+ exports.specs.its.push(it);
94
+ it = {
95
+ expectation: 'creates enslosing folder',
96
+ notIncludedIn: 'win-local-fs'
97
+ };
98
+ it.func = async function (s) {
99
+ const { testFS } = s;
100
+ const original = 'Should I be at BlackHat conference or working?';
101
+ const fPath = 'folder1/file1';
102
+ await testFS.writeTxtFile(fPath, original);
103
+ let file = await testFS.readonlyFile(fPath);
104
+ const linkFolder = `link's folder`;
105
+ expect(await testFS.checkFolderPresence(linkFolder)).toBe(false);
106
+ const linkPath = `${linkFolder}/link`;
107
+ await testFS.link(linkPath, file);
108
+ expect(await testFS.checkFolderPresence(linkFolder)).toBe(true);
109
+ const link = await testFS.readLink(linkPath);
110
+ expect(link.isFile).withContext('this link should be for a file').toBe(true);
111
+ file = (await link.target());
112
+ expect(!!file).withContext('target should be instantiated').toBe(true);
113
+ expect(await file.readTxt()).toBe(original);
114
+ };
115
+ exports.specs.its.push(it);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,129 @@
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: '.listFolder',
23
+ its: []
24
+ };
25
+ let it = { expectation: 'lists root' };
26
+ it.func = async function (s) {
27
+ const { testFS } = s;
28
+ let lst = await testFS.listFolder('');
29
+ expect(Array.isArray(lst)).toBe(true);
30
+ expect(lst.length).toBe(0);
31
+ await testFS.makeFolder('folder1');
32
+ await testFS.writeTxtFile('file1', '');
33
+ await testFS.writeTxtFile('folder1/file2', '');
34
+ lst = await testFS.listFolder('');
35
+ expect(lst.length).toBe(2);
36
+ for (let entry of lst) {
37
+ if (entry.isFile) {
38
+ expect(entry.name).toBe('file1');
39
+ }
40
+ else if (entry.isFolder) {
41
+ expect(entry.name).toBe('folder1');
42
+ }
43
+ else {
44
+ fail(`folder listing has unknown type: ${JSON.stringify(entry, null, 2)}`);
45
+ }
46
+ }
47
+ let lst2 = await testFS.listFolder('.');
48
+ expect((0, json_equal_1.deepEqual)(lst2, lst)).toBe(true);
49
+ lst2 = await testFS.listFolder('/');
50
+ expect((0, json_equal_1.deepEqual)(lst2, lst)).toBe(true);
51
+ lst2 = await testFS.listFolder('../../');
52
+ expect((0, json_equal_1.deepEqual)(lst2, lst)).toBe(true);
53
+ };
54
+ exports.specs.its.push(it);
55
+ it = { expectation: 'fails to list non-existing folder' };
56
+ it.func = async function (s) {
57
+ const { testFS } = s;
58
+ let fName = 'non-existing-folder';
59
+ expect(await testFS.checkFolderPresence(fName)).toBe(false);
60
+ await testFS.listFolder(fName)
61
+ .then(() => {
62
+ fail('listing should fail for non-existing folder');
63
+ }, (exc) => {
64
+ expect(exc.notFound).toBe(true);
65
+ });
66
+ await testFS.writeTxtFile(fName, '123');
67
+ expect(await testFS.checkFilePresence(fName)).toBe(true);
68
+ await testFS.listFolder(fName)
69
+ .then(() => {
70
+ fail('listing should fail on path that points to file');
71
+ }, (exc) => {
72
+ expect(exc.notDirectory).toBe(true);
73
+ });
74
+ };
75
+ exports.specs.its.push(it);
76
+ it = { expectation: 'lists folder without links' };
77
+ it.func = async function (s) {
78
+ const { testFS } = s;
79
+ let fName = 'f1/f2';
80
+ await testFS.makeFolder('f1/f2');
81
+ await testFS.writeTxtFile(fName + '/file1', '');
82
+ await testFS.writeTxtFile(fName + '/folder1/file2', '');
83
+ let lst = await testFS.listFolder(fName);
84
+ expect(Array.isArray(lst)).toBe(true);
85
+ expect(lst.length).toBe(2);
86
+ for (let entry of lst) {
87
+ if (entry.isFile) {
88
+ expect(entry.name).toBe('file1');
89
+ }
90
+ else if (entry.isFolder) {
91
+ expect(entry.name).toBe('folder1');
92
+ }
93
+ else {
94
+ fail(`folder listing has unknown type: ${JSON.stringify(entry, null, 2)}`);
95
+ }
96
+ }
97
+ };
98
+ exports.specs.its.push(it);
99
+ it = {
100
+ expectation: 'lists folder with links',
101
+ notIncludedIn: 'win-local-fs'
102
+ };
103
+ it.func = async function (s) {
104
+ const { testFS } = s;
105
+ let fName = 'f1/f2';
106
+ await testFS.makeFolder('f1/f2');
107
+ await testFS.writeTxtFile(fName + '/file1', '');
108
+ await testFS.writeTxtFile(fName + '/folder1/file2', '');
109
+ await testFS.link(fName + '/link1', await testFS.readonlyFile(fName + '/folder1/file2'));
110
+ let lst = await testFS.listFolder(fName);
111
+ expect(Array.isArray(lst)).toBe(true);
112
+ expect(lst.length).toBe(3);
113
+ for (let entry of lst) {
114
+ if (entry.isFile) {
115
+ expect(entry.name).toBe('file1');
116
+ }
117
+ else if (entry.isFolder) {
118
+ expect(entry.name).toBe('folder1');
119
+ }
120
+ else if (entry.isLink) {
121
+ expect(entry.name).toBe('link1');
122
+ }
123
+ else {
124
+ fail(`folder listing has unknown type: ${JSON.stringify(entry, null, 2)}`);
125
+ }
126
+ }
127
+ };
128
+ exports.specs.its.push(it);
129
+ 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,73 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 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: '.listXAttrs',
22
+ its: []
23
+ };
24
+ let it = {
25
+ expectation: 'fails to read xattrs for non-existent path',
26
+ notIncludedIn: 'device-fs'
27
+ };
28
+ it.func = async function (s) {
29
+ const { testFS } = s;
30
+ let fName = 'unknown-file';
31
+ await testFS.listXAttrs(fName)
32
+ .then(() => {
33
+ fail('stat-ing must fail, when path does not exist');
34
+ }, (err) => {
35
+ expect(err.notFound).toBe(true);
36
+ if (!err.notFound) {
37
+ throw err;
38
+ }
39
+ });
40
+ };
41
+ exports.specs.its.push(it);
42
+ it = {
43
+ expectation: 'lists extended attributes',
44
+ notIncludedIn: 'device-fs'
45
+ };
46
+ it.func = async function (s) {
47
+ const { testFS } = s;
48
+ async function testforPath(path) {
49
+ let xattrNames = await testFS.listXAttrs(path);
50
+ expect(Array.isArray(xattrNames)).toBe(true);
51
+ expect(xattrNames.length).toBe(0);
52
+ const attr1Name = 'attribute name 1';
53
+ const attr2Name = 'attr2';
54
+ await testFS.updateXAttrs(path, {
55
+ set: {
56
+ [attr1Name]: 'some string value',
57
+ [attr2Name]: 1234
58
+ }
59
+ });
60
+ xattrNames = await testFS.listXAttrs(path);
61
+ expect(xattrNames.length).toBe(2);
62
+ expect(xattrNames).toContain(attr1Name);
63
+ expect(xattrNames).toContain(attr2Name);
64
+ }
65
+ const file = 'file1';
66
+ await testFS.writeTxtFile(file, '');
67
+ await testforPath(file);
68
+ const folder = 'folder1';
69
+ await testFS.makeFolder(folder);
70
+ await testforPath(folder);
71
+ };
72
+ exports.specs.its.push(it);
73
+ 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,95 @@
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: '.makeFolder',
22
+ its: []
23
+ };
24
+ let it = { expectation: 'creates in existing parent' };
25
+ it.func = async function (s) {
26
+ const { testFS } = s;
27
+ let fName = 'folder';
28
+ expect(await testFS.checkFolderPresence(fName)).toBe(false);
29
+ await testFS.makeFolder(fName);
30
+ expect(await testFS.checkFolderPresence(fName)).toBe(true);
31
+ };
32
+ exports.specs.its.push(it);
33
+ it = {
34
+ expectation: 'is a no-op, when folder exists, and a call is not exclusive'
35
+ };
36
+ it.func = async function (s) {
37
+ const { testFS } = s;
38
+ for (let fName of ['folder2', 'parent2/folder2']) {
39
+ expect(await testFS.checkFolderPresence(fName)).toBe(false);
40
+ await testFS.makeFolder(fName);
41
+ expect(await testFS.checkFolderPresence(fName)).toBe(true);
42
+ await testFS.makeFolder(fName)
43
+ .catch(() => {
44
+ fail('non exclusive creation should not throw');
45
+ });
46
+ expect(await testFS.checkFolderPresence(fName)).toBe(true);
47
+ }
48
+ };
49
+ exports.specs.its.push(it);
50
+ it = { expectation: 'exclusive creation fails if folder exists' };
51
+ it.func = async function (s) {
52
+ const { testFS } = s;
53
+ for (let fName of ['folder3', 'parent3/folder3']) {
54
+ expect(await testFS.checkFolderPresence(fName)).toBe(false);
55
+ await testFS.makeFolder(fName);
56
+ expect(await testFS.checkFolderPresence(fName)).toBe(true);
57
+ await testFS.makeFolder(fName, true)
58
+ .then(() => {
59
+ fail('Exclusive creation of folder fails to throw.');
60
+ }, (e) => {
61
+ if (!e.alreadyExists) {
62
+ fail('incorrect exception');
63
+ }
64
+ });
65
+ }
66
+ };
67
+ exports.specs.its.push(it);
68
+ it = { expectation: 'creates parent folder(s) on the way' };
69
+ it.func = async function (s) {
70
+ const { testFS } = s;
71
+ let fName = 'folder';
72
+ let grParent = 'grand-parent';
73
+ let parent2 = 'grand-parent/parent2';
74
+ let path = `${parent2}/${fName}`;
75
+ expect(await testFS.checkFolderPresence(grParent)).toBe(false);
76
+ expect(await testFS.checkFolderPresence(parent2)).toBe(false);
77
+ expect(await testFS.checkFolderPresence(path)).toBe(false);
78
+ await testFS.makeFolder(path);
79
+ expect(await testFS.checkFolderPresence(path)).toBe(true);
80
+ };
81
+ exports.specs.its.push(it);
82
+ it = { expectation: 'can handle concurrent creation' };
83
+ it.func = async function (s) {
84
+ const { testFS } = s;
85
+ let path = 'concurrent/a/b/c/d/e/f/g/h';
86
+ expect(await testFS.checkFolderPresence(path)).toBe(false);
87
+ let concurrentTasks = [];
88
+ for (let i = 0; i < 10; i += 1) {
89
+ concurrentTasks.push(testFS.makeFolder(path));
90
+ }
91
+ await Promise.all(concurrentTasks);
92
+ expect(await testFS.checkFolderPresence(path)).toBe(true);
93
+ };
94
+ exports.specs.its.push(it);
95
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;