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,45 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016, 2020 - 2022, 2025 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
+ const jasmine = require("jasmine");
20
+ const jas = new jasmine({});
21
+ const specsFromCLI = [];
22
+ for (let i = 2; i < process.argv.length; i += 1) {
23
+ specsFromCLI.push(process.argv[i]);
24
+ }
25
+ const ALL_SPECS = [
26
+ 'units/*.js',
27
+ 'caps-api/startup/*.js',
28
+ 'caps-api/keyrings.js',
29
+ 'caps-api/mailerid.js',
30
+ 'caps-api/storage.js',
31
+ 'caps-api/asmail.js',
32
+ // 'computer.3nweb.core/*.js',
33
+ 'computer.3nweb.core/id-manager.js',
34
+ // 'computer.3nweb.core/inbox/*.js'
35
+ ];
36
+ jas.loadConfig({
37
+ spec_dir: 'build/tests',
38
+ spec_files: ((specsFromCLI.length > 0) ? specsFromCLI : ALL_SPECS),
39
+ random: false,
40
+ failSpecWithNoExpectations: false,
41
+ });
42
+ jas.configureDefaultReporter({
43
+ showColors: true
44
+ });
45
+ jas.execute();
@@ -0,0 +1 @@
1
+ export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016 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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.bytesEqual = bytesEqual;
19
+ function bytesEqual(a, b) {
20
+ if (a.BYTES_PER_ELEMENT !== b.BYTES_PER_ELEMENT) {
21
+ return false;
22
+ }
23
+ if (a.length !== b.length) {
24
+ return false;
25
+ }
26
+ for (let i = 0; i < a.length; i += 1) {
27
+ if (a[i] !== b[i]) {
28
+ return false;
29
+ }
30
+ }
31
+ return true;
32
+ }
@@ -0,0 +1,11 @@
1
+ type StartupW3N = web3n.startup.W3N;
2
+ type CommonW3N = web3n.caps.common.W3N;
3
+ export declare function wrapStartupW3N(coreW3N: StartupW3N): {
4
+ clientW3N: StartupW3N;
5
+ close: () => void;
6
+ };
7
+ export declare function wrapCommonW3N(coreW3N: CommonW3N): {
8
+ clientW3N: CommonW3N;
9
+ close: () => void;
10
+ };
11
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2020 - 2021, 2024 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.wrapStartupW3N = wrapStartupW3N;
20
+ exports.wrapCommonW3N = wrapCommonW3N;
21
+ const rxjs_1 = require("rxjs");
22
+ const operators_1 = require("rxjs/operators");
23
+ const ipc_1 = require("../../ipc");
24
+ function makePipe() {
25
+ const fromCore = new rxjs_1.Subject();
26
+ const toClient = fromCore.asObservable().pipe((0, operators_1.map)(msg => ipc_1.msgProtoType.pack(msg)), (0, operators_1.delay)(1), (0, operators_1.map)(buf => ipc_1.msgProtoType.unpack(buf)));
27
+ const fromClient = new rxjs_1.Subject();
28
+ const toCore = fromClient.asObservable().pipe((0, operators_1.map)(msg => ipc_1.msgProtoType.pack(msg)), (0, operators_1.delay)(1), (0, operators_1.map)(buf => ipc_1.msgProtoType.unpack(buf)));
29
+ const coreSide = ipc_1.ObjectsConnector.makeCoreSide(fromCore, toCore);
30
+ const listObjInCore = path => {
31
+ const lst = coreSide.exposedServices.listObj(path);
32
+ if (lst) {
33
+ return lst;
34
+ }
35
+ else {
36
+ throw (0, ipc_1.makeIPCException)({ objectNotFound: true });
37
+ }
38
+ };
39
+ const clientSide = ipc_1.ObjectsConnector.makeClientSide(fromClient, toClient, listObjInCore);
40
+ return { coreSide, clientSide };
41
+ }
42
+ function wrapStartupW3N(coreW3N) {
43
+ const { clientSide, coreSide } = makePipe();
44
+ (0, ipc_1.exposeStartupW3N)(coreSide, coreW3N);
45
+ const clientW3N = (0, ipc_1.makeStartupW3Nclient)(clientSide);
46
+ const close = () => coreSide.close();
47
+ return { clientW3N, close };
48
+ }
49
+ function wrapCommonW3N(coreW3N) {
50
+ const { clientSide, coreSide } = makePipe();
51
+ (0, ipc_1.exposeW3N)(coreSide, coreW3N);
52
+ const clientW3N = (0, ipc_1.makeW3Nclient)(clientSide);
53
+ const close = () => coreSide.close();
54
+ return { clientW3N, close };
55
+ }
@@ -0,0 +1,39 @@
1
+ import { Core } from "../../lib-index";
2
+ export declare const testApp: {
3
+ appDomain: string;
4
+ capsRequested: web3n.caps.common.RequestedCAPs;
5
+ };
6
+ export interface User {
7
+ userId: string;
8
+ pass: string;
9
+ }
10
+ type CommonW3N = web3n.caps.common.W3N;
11
+ type StartupW3N = web3n.startup.W3N;
12
+ export declare class CoreRunner {
13
+ readonly signUpUrl: string;
14
+ runningCore: Core | undefined;
15
+ user: User;
16
+ private appCaps;
17
+ private coreNum;
18
+ readonly dataFolder: string;
19
+ constructor(signUpUrl: string);
20
+ get core(): Core;
21
+ private setNewCore;
22
+ close(): Promise<void>;
23
+ cleanup(showLogs: boolean): Promise<void>;
24
+ removeDataFolder(): Promise<void>;
25
+ restart(rmCache: boolean, loginUser: boolean): Promise<void>;
26
+ loginUser(): Promise<void>;
27
+ createUser(userId: string): Promise<User>;
28
+ startCore(capsViaIPC?: boolean): {
29
+ w3n: StartupW3N;
30
+ coreInit: Promise<string>;
31
+ coreAppsInit: Promise<void>;
32
+ closeIPC: () => void;
33
+ };
34
+ setupTestAppCaps(): void;
35
+ get rawAppCaps(): CommonW3N;
36
+ get appCapsViaIPC(): CommonW3N;
37
+ makeAndLoginNewCore(): Promise<CoreRunner>;
38
+ }
39
+ export {};
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2020 - 2022, 2025 - 2026 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.CoreRunner = exports.testApp = void 0;
20
+ const lib_index_1 = require("../../lib-index");
21
+ const path_1 = require("path");
22
+ const async_fs_node_1 = require("../../lib-common/async-fs-node");
23
+ const random_node_1 = require("../../lib-common/random-node");
24
+ const app_files_1 = require("../../core/app-files");
25
+ const log_to_file_1 = require("../../lib-client/logging/log-to-file");
26
+ const error_1 = require("../../lib-common/exceptions/error");
27
+ const assert_1 = require("../../lib-common/assert");
28
+ const caps_ipc_wrap_1 = require("./caps-ipc-wrap");
29
+ const service_locator_1 = require("../../lib-client/service-locator");
30
+ const dns_1 = require("dns");
31
+ const napi_nacl_1 = require("napi-nacl");
32
+ exports.testApp = {
33
+ appDomain: 'test.3nweb.app',
34
+ capsRequested: {
35
+ keyrings: 'all',
36
+ mailerid: true,
37
+ mail: {
38
+ receivingFrom: 'all',
39
+ sendingTo: 'all'
40
+ },
41
+ storage: {
42
+ appFS: [
43
+ {
44
+ domain: "test.3nweb.app",
45
+ storage: "synced-n-local"
46
+ }, {
47
+ domain: "mail.test.3nweb.app",
48
+ storage: "synced-n-local"
49
+ }, {
50
+ domain: "contacts.test.3nweb.app",
51
+ storage: "synced-n-local"
52
+ }
53
+ ],
54
+ userFS: 'all',
55
+ sysFS: 'all'
56
+ },
57
+ logToPlatform: true
58
+ }
59
+ };
60
+ let numOfRunningCores = 0;
61
+ const DATA_FOLDER = (0, path_1.join)(__dirname, '..', '..', '..', 'test-data');
62
+ class CoreRunner {
63
+ constructor(signUpUrl) {
64
+ this.signUpUrl = signUpUrl;
65
+ this.runningCore = undefined;
66
+ this.user = undefined;
67
+ this.appCaps = undefined;
68
+ numOfRunningCores += 1;
69
+ this.coreNum = numOfRunningCores;
70
+ this.dataFolder = `${DATA_FOLDER}-${this.coreNum}-${Date.now()}`;
71
+ this.setNewCore();
72
+ Object.seal(this);
73
+ }
74
+ get core() {
75
+ (0, assert_1.assert)(!!this.runningCore);
76
+ return this.runningCore;
77
+ }
78
+ setNewCore() {
79
+ if (this.appCaps) {
80
+ this.appCaps.close();
81
+ this.appCaps = undefined;
82
+ }
83
+ this.runningCore = lib_index_1.Core.make({ dataDir: this.dataFolder, signUpUrl: this.signUpUrl }, lib_index_1.makeNetClient, (0, service_locator_1.makeServiceLocator)({
84
+ resolveTxt: domain => new Promise((resolve, reject) => (0, dns_1.resolveTxt)(domain, (err, texts) => {
85
+ if (err) {
86
+ reject(err);
87
+ }
88
+ else {
89
+ resolve(texts);
90
+ }
91
+ }))
92
+ }), napi_nacl_1.makeNativeCryptor);
93
+ }
94
+ async close() {
95
+ if (this.appCaps) {
96
+ this.appCaps.close();
97
+ this.appCaps = undefined;
98
+ // XXX
99
+ // - should we do this.setNewCore() ?
100
+ }
101
+ if (this.runningCore) {
102
+ await this.runningCore.close();
103
+ this.runningCore = undefined;
104
+ }
105
+ }
106
+ async cleanup(showLogs) {
107
+ if (showLogs) {
108
+ await showLogsFrom(this.dataFolder);
109
+ }
110
+ await this.removeDataFolder();
111
+ }
112
+ async removeDataFolder() {
113
+ await (0, async_fs_node_1.rmDirWithContent)(this.dataFolder).catch((exc) => {
114
+ if (!exc.notFound) {
115
+ throw exc;
116
+ }
117
+ });
118
+ }
119
+ async restart(rmCache, loginUser) {
120
+ await this.close();
121
+ if (rmCache) {
122
+ await this.cleanup(false);
123
+ }
124
+ this.setNewCore();
125
+ if (loginUser) {
126
+ (0, assert_1.assert)(!!this.user);
127
+ await this.loginUser();
128
+ }
129
+ }
130
+ async loginUser() {
131
+ if (!this.runningCore) {
132
+ this.setNewCore();
133
+ }
134
+ const { capsForStartup: caps, coreInit, coreAppsInit } = this.core.start();
135
+ const usersOnDisk = await caps.signIn.getUsersOnDisk();
136
+ let isLogged;
137
+ if (usersOnDisk.find(userOnDisk => (userOnDisk === this.user.userId))) {
138
+ isLogged = await caps.signIn.useExistingStorage(this.user.userId, this.user.pass, () => { });
139
+ }
140
+ else {
141
+ const userExists = await caps.signIn.startLoginToRemoteStorage(this.user.userId);
142
+ if (!userExists) {
143
+ throw new Error(`Attempt to login ${this.user.userId} fails, cause server doesn't recongize this user.`);
144
+ }
145
+ isLogged = await caps.signIn.completeLoginAndLocalSetup(this.user.pass, () => { });
146
+ }
147
+ if (!isLogged) {
148
+ throw new Error(`Cannot create user ${this.user.userId}. It may already exists.`);
149
+ }
150
+ await coreInit;
151
+ await coreAppsInit;
152
+ }
153
+ async createUser(userId) {
154
+ if (this.user) {
155
+ throw new Error('App already has associated user.');
156
+ }
157
+ const { capsForStartup: caps, coreInit, coreAppsInit } = this.core.start();
158
+ const pass = await (0, random_node_1.stringOfB64Chars)(16);
159
+ await caps.signUp.createUserParams(pass, () => { });
160
+ const isCreated = await caps.signUp.addUser(userId);
161
+ if (!isCreated) {
162
+ throw new Error(`Cannot create user ${userId}. It may already exists.`);
163
+ }
164
+ await coreInit;
165
+ await coreAppsInit;
166
+ this.user = { userId, pass };
167
+ return this.user;
168
+ }
169
+ startCore(capsViaIPC = true) {
170
+ const { capsForStartup: rawW3N, coreInit, coreAppsInit } = this.core.start();
171
+ if (capsViaIPC) {
172
+ const { clientW3N: w3n, close: closeIPC } = (0, caps_ipc_wrap_1.wrapStartupW3N)(rawW3N);
173
+ return { w3n, coreInit, coreAppsInit, closeIPC };
174
+ }
175
+ else {
176
+ return { w3n: rawW3N, coreInit, coreAppsInit, closeIPC: () => { } };
177
+ }
178
+ }
179
+ setupTestAppCaps() {
180
+ (0, assert_1.assert)(!this.appCaps, `Expect that app CAPs not to be set.`);
181
+ const { caps, close: closeCAPs } = this.core.makeCAPsForApp(exports.testApp.appDomain, exports.testApp.capsRequested);
182
+ const { clientW3N, close } = (0, caps_ipc_wrap_1.wrapCommonW3N)(caps);
183
+ this.appCaps = {
184
+ raw: caps,
185
+ ipc: clientW3N,
186
+ close: () => {
187
+ closeCAPs();
188
+ close();
189
+ }
190
+ };
191
+ }
192
+ get rawAppCaps() {
193
+ (0, assert_1.assert)(!!this.appCaps, `Expect that app CAPs is set.`);
194
+ return this.appCaps.raw;
195
+ }
196
+ get appCapsViaIPC() {
197
+ (0, assert_1.assert)(!!this.appCaps, `Expect that app CAPs is set.`);
198
+ return this.appCaps.ipc;
199
+ }
200
+ async makeAndLoginNewCore() {
201
+ const r = new CoreRunner(this.signUpUrl);
202
+ r.user = this.user;
203
+ await r.loginUser();
204
+ r.setupTestAppCaps();
205
+ return r;
206
+ }
207
+ }
208
+ exports.CoreRunner = CoreRunner;
209
+ Object.freeze(CoreRunner.prototype);
210
+ Object.freeze(CoreRunner);
211
+ async function showLogsFrom(dataFolder) {
212
+ const logsFolder = (0, path_1.join)(dataFolder, app_files_1.UTIL_DIR, log_to_file_1.LOGS_FOLDER);
213
+ try {
214
+ const logFiles = await (0, async_fs_node_1.readdir)(logsFolder);
215
+ if (logFiles.length === 0) {
216
+ return;
217
+ }
218
+ console.log(`\n---------------------------\nLogs from directory ${logsFolder}\n`);
219
+ for (const file of logFiles) {
220
+ const log = await (0, async_fs_node_1.readFile)((0, path_1.join)(logsFolder, file), { encoding: 'utf8' })
221
+ .catch(err => `Error occured in reading log file ${file}:\n${(0, error_1.stringifyErr)(err)}`);
222
+ console.log(`Log file ${file}:\n${log}\n---------------------------`);
223
+ }
224
+ }
225
+ catch (err) {
226
+ if (!err.notFound) {
227
+ console.log(`Error occured in reading log folder:\n${(0, error_1.stringifyErr)(err)}`);
228
+ }
229
+ }
230
+ }
231
+ Object.freeze(exports);
@@ -0,0 +1,13 @@
1
+ export declare function itCond(expectation: string, assertion?: () => Promise<void>, timeout?: number, setup?: {
2
+ isUp: boolean;
3
+ }): void;
4
+ export declare function xitCond(expectation: string, assertion?: () => Promise<void>, timeout?: number, setup?: {
5
+ isUp: boolean;
6
+ }): void;
7
+ export declare function fitCond(expectation: string, assertion?: () => Promise<void>, timeout?: number, setup?: {
8
+ isUp: boolean;
9
+ }): void;
10
+ export declare function beforeAllWithTimeoutLog(action: () => Promise<void>, timeout?: number): void;
11
+ export declare function beforeEachWithTimeoutLog(action: () => Promise<void>, timeout?: number): void;
12
+ export declare function afterAllCond(action: () => Promise<void>, timeout?: number): void;
13
+ export declare function afterEachCond(action: () => Promise<void>, timeout?: number): void;
@@ -0,0 +1,110 @@
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.itCond = itCond;
20
+ exports.xitCond = xitCond;
21
+ exports.fitCond = fitCond;
22
+ exports.beforeAllWithTimeoutLog = beforeAllWithTimeoutLog;
23
+ exports.beforeEachWithTimeoutLog = beforeEachWithTimeoutLog;
24
+ exports.afterAllCond = afterAllCond;
25
+ exports.afterEachCond = afterEachCond;
26
+ const error_1 = require("../../lib-common/exceptions/error");
27
+ const timeout_1 = require("../../lib-common/processes/timeout");
28
+ function itCond(expectation, assertion, timeout, setup) {
29
+ if (assertion) {
30
+ it(expectation, callbackFor(assertion, setup), timeout);
31
+ }
32
+ else {
33
+ it(expectation);
34
+ }
35
+ }
36
+ function callbackFor(assertion, setup) {
37
+ return async () => {
38
+ if (setup && !setup.isUp) {
39
+ fail(`Test setup is not up`);
40
+ }
41
+ else {
42
+ try {
43
+ await assertion();
44
+ }
45
+ catch (err) {
46
+ if (typeof err === 'string') {
47
+ fail(err);
48
+ }
49
+ else if (err.runtimeException) {
50
+ fail((0, error_1.stringifyErr)(err));
51
+ }
52
+ else {
53
+ throw err;
54
+ }
55
+ }
56
+ }
57
+ };
58
+ }
59
+ function xitCond(expectation, assertion, timeout, setup) {
60
+ if (assertion) {
61
+ xit(expectation, callbackFor(assertion, setup), timeout);
62
+ }
63
+ else {
64
+ xit(expectation);
65
+ }
66
+ }
67
+ function fitCond(expectation, assertion, timeout, setup) {
68
+ if (assertion) {
69
+ fit(expectation, callbackFor(assertion, setup), timeout);
70
+ }
71
+ else {
72
+ fit(expectation);
73
+ }
74
+ }
75
+ function beforeAllWithTimeoutLog(action, timeout) {
76
+ beforeAll(callbackWithTimeout(action, true, timeout, 'beforeAll'), timeout);
77
+ }
78
+ const DEFAULT_TIMEOUT_INTERVAL = 5000;
79
+ function callbackWithTimeout(action, throwIfErr, timeout, actionType) {
80
+ const millisToSleep = ((timeout === undefined) ?
81
+ DEFAULT_TIMEOUT_INTERVAL : timeout);
82
+ const timeoutErr = {};
83
+ return async () => {
84
+ try {
85
+ await (0, timeout_1.callWithTimeout)(action, millisToSleep - 5, () => timeoutErr);
86
+ }
87
+ catch (err) {
88
+ if (err === timeoutErr) {
89
+ console.log(`\n>>> timeout in ${actionType}: action hasn't completed in ${millisToSleep - 5} milliseconds`);
90
+ }
91
+ else if (throwIfErr) {
92
+ console.log(`\n>>> ${actionType} threw`, err);
93
+ fail(err.runtimeException ?
94
+ (0, error_1.stringifyErr)(err) : err);
95
+ }
96
+ }
97
+ };
98
+ }
99
+ function beforeEachWithTimeoutLog(action, timeout) {
100
+ beforeEach(callbackWithTimeout(action, true, timeout, 'beforeEach'), timeout);
101
+ }
102
+ // Adjust this static flag to hide/show errors thrown in afterXXX()
103
+ const throwErrorInAfter = false;
104
+ function afterAllCond(action, timeout) {
105
+ afterAll(callbackWithTimeout(action, throwErrorInAfter, timeout, 'afterAll'), timeout);
106
+ }
107
+ function afterEachCond(action, timeout) {
108
+ afterEach(callbackWithTimeout(action, throwErrorInAfter, timeout, 'afterEach'), timeout);
109
+ }
110
+ Object.freeze(exports);
@@ -0,0 +1 @@
1
+ export declare function deepEqual(a: any, b: any, trimUndefinedObjFields?: boolean): boolean;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2015, 2025 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.deepEqual = deepEqual;
20
+ function deepEqual(a, b, trimUndefinedObjFields = true) {
21
+ let t = typeof a;
22
+ if (t !== typeof b) {
23
+ return false;
24
+ }
25
+ if (t !== 'object') {
26
+ return (a === b);
27
+ }
28
+ if (a === b) {
29
+ return true;
30
+ }
31
+ if ((a === null) || (b === null)) {
32
+ return false;
33
+ }
34
+ if (Array.isArray(a)) {
35
+ if (!Array.isArray(b)) {
36
+ return false;
37
+ }
38
+ let aArr = a;
39
+ let bArr = b;
40
+ if (aArr.length !== bArr.length) {
41
+ return false;
42
+ }
43
+ for (let i = 0; i < aArr.length; i += 1) {
44
+ if (!deepEqual(aArr[i], bArr[i])) {
45
+ return false;
46
+ }
47
+ }
48
+ }
49
+ else {
50
+ let aKeys = Object.keys(a);
51
+ let bKeys = Object.keys(b);
52
+ if (trimUndefinedObjFields) {
53
+ for (let i = 0; i < aKeys.length; i += 1) {
54
+ if (a[aKeys[i]] === undefined) {
55
+ aKeys.splice(i, 1);
56
+ i -= 1;
57
+ }
58
+ }
59
+ for (let i = 0; i < bKeys.length; i += 1) {
60
+ if (b[bKeys[i]] === undefined) {
61
+ bKeys.splice(i, 1);
62
+ i -= 1;
63
+ }
64
+ }
65
+ }
66
+ if (aKeys.length !== bKeys.length) {
67
+ return false;
68
+ }
69
+ for (let i = 0; i < aKeys.length; i += 1) {
70
+ let key = aKeys[i];
71
+ if (!deepEqual(a[key], b[key])) {
72
+ return false;
73
+ }
74
+ }
75
+ }
76
+ return true;
77
+ }
78
+ Object.freeze(exports);
@@ -0,0 +1,18 @@
1
+ export declare class ServicesRunner {
2
+ readonly port: number;
3
+ readonly domains: {
4
+ noTokenSignup: string[];
5
+ other: string[];
6
+ };
7
+ private stopFn;
8
+ readonly dataFolder: string;
9
+ private serverNum;
10
+ constructor(port: number, domains: {
11
+ noTokenSignup: string[];
12
+ other: string[];
13
+ });
14
+ start(): Promise<void>;
15
+ stop(cleanup?: boolean): Promise<void>;
16
+ private cleanup;
17
+ createSingleUserSignupCtx(userId: string): Promise<string>;
18
+ }