core-3nweb-client-lib 0.44.12 → 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 (201) 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/node-persistence.js +1 -1
  11. package/build/tests/caps-api/asmail/specs/events.d.ts +2 -0
  12. package/build/tests/caps-api/asmail/specs/events.js +63 -0
  13. package/build/tests/caps-api/asmail/specs/send-to-wrong-address.d.ts +2 -0
  14. package/build/tests/caps-api/asmail/specs/send-to-wrong-address.js +68 -0
  15. package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.d.ts +2 -0
  16. package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +259 -0
  17. package/build/tests/caps-api/asmail/specs/send-without-attachments.d.ts +2 -0
  18. package/build/tests/caps-api/asmail/specs/send-without-attachments.js +90 -0
  19. package/build/tests/caps-api/asmail/test-utils.d.ts +12 -0
  20. package/build/tests/caps-api/asmail/test-utils.js +60 -0
  21. package/build/tests/caps-api/asmail.js +86 -0
  22. package/build/tests/caps-api/file-sink-checks/different-cases.d.ts +2 -0
  23. package/build/tests/caps-api/file-sink-checks/different-cases.js +47 -0
  24. package/build/tests/caps-api/file-sink-checks/splice.d.ts +2 -0
  25. package/build/tests/caps-api/file-sink-checks/splice.js +122 -0
  26. package/build/tests/caps-api/file-sink-checks/truncate.d.ts +2 -0
  27. package/build/tests/caps-api/file-sink-checks/truncate.js +122 -0
  28. package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.d.ts +2 -0
  29. package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.js +82 -0
  30. package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.d.ts +2 -0
  31. package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.js +50 -0
  32. package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.d.ts +2 -0
  33. package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.js +73 -0
  34. package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.d.ts +2 -0
  35. package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.js +75 -0
  36. package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.d.ts +2 -0
  37. package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +96 -0
  38. package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.d.ts +2 -0
  39. package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +67 -0
  40. package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.d.ts +2 -0
  41. package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.js +77 -0
  42. package/build/tests/caps-api/fs-checks/not-versioned/link.d.ts +2 -0
  43. package/build/tests/caps-api/fs-checks/not-versioned/link.js +115 -0
  44. package/build/tests/caps-api/fs-checks/not-versioned/listFolder.d.ts +2 -0
  45. package/build/tests/caps-api/fs-checks/not-versioned/listFolder.js +129 -0
  46. package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.d.ts +2 -0
  47. package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.js +73 -0
  48. package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.d.ts +2 -0
  49. package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.js +95 -0
  50. package/build/tests/caps-api/fs-checks/not-versioned/move.d.ts +2 -0
  51. package/build/tests/caps-api/fs-checks/not-versioned/move.js +127 -0
  52. package/build/tests/caps-api/fs-checks/not-versioned/readBytes.d.ts +2 -0
  53. package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +80 -0
  54. package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.d.ts +2 -0
  55. package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.js +59 -0
  56. package/build/tests/caps-api/fs-checks/not-versioned/readLink.d.ts +2 -0
  57. package/build/tests/caps-api/fs-checks/not-versioned/readLink.js +39 -0
  58. package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.d.ts +2 -0
  59. package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.js +54 -0
  60. package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.d.ts +2 -0
  61. package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.js +55 -0
  62. package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.d.ts +2 -0
  63. package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.js +55 -0
  64. package/build/tests/caps-api/fs-checks/not-versioned/select.d.ts +2 -0
  65. package/build/tests/caps-api/fs-checks/not-versioned/select.js +119 -0
  66. package/build/tests/caps-api/fs-checks/not-versioned/stat.d.ts +2 -0
  67. package/build/tests/caps-api/fs-checks/not-versioned/stat.js +96 -0
  68. package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.d.ts +2 -0
  69. package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.js +126 -0
  70. package/build/tests/caps-api/fs-checks/not-versioned/writableFile.d.ts +2 -0
  71. package/build/tests/caps-api/fs-checks/not-versioned/writableFile.js +79 -0
  72. package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.d.ts +2 -0
  73. package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.js +90 -0
  74. package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.d.ts +2 -0
  75. package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +137 -0
  76. package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.d.ts +2 -0
  77. package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.js +101 -0
  78. package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.d.ts +2 -0
  79. package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.js +100 -0
  80. package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.d.ts +2 -0
  81. package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +187 -0
  82. package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.d.ts +2 -0
  83. package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +70 -0
  84. package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.d.ts +2 -0
  85. package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +53 -0
  86. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.d.ts +2 -0
  87. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +194 -0
  88. package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.d.ts +2 -0
  89. package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +396 -0
  90. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.d.ts +2 -0
  91. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +229 -0
  92. package/build/tests/caps-api/fs-checks/test-utils.d.ts +34 -0
  93. package/build/tests/caps-api/fs-checks/test-utils.js +95 -0
  94. package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.d.ts +2 -0
  95. package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +73 -0
  96. package/build/tests/caps-api/fs-checks/versioned/getByteSink.d.ts +2 -0
  97. package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +122 -0
  98. package/build/tests/caps-api/fs-checks/versioned/getByteSource.d.ts +2 -0
  99. package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +71 -0
  100. package/build/tests/caps-api/fs-checks/versioned/listFolder.d.ts +2 -0
  101. package/build/tests/caps-api/fs-checks/versioned/listFolder.js +109 -0
  102. package/build/tests/caps-api/fs-checks/versioned/listVersions.d.ts +2 -0
  103. package/build/tests/caps-api/fs-checks/versioned/listVersions.js +48 -0
  104. package/build/tests/caps-api/fs-checks/versioned/readBytes.d.ts +2 -0
  105. package/build/tests/caps-api/fs-checks/versioned/readBytes.js +90 -0
  106. package/build/tests/caps-api/fs-checks/versioned/readJSONFile.d.ts +2 -0
  107. package/build/tests/caps-api/fs-checks/versioned/readJSONFile.js +60 -0
  108. package/build/tests/caps-api/fs-checks/versioned/readTxtFile.d.ts +2 -0
  109. package/build/tests/caps-api/fs-checks/versioned/readTxtFile.js +56 -0
  110. package/build/tests/caps-api/fs-checks/versioned/stat.d.ts +2 -0
  111. package/build/tests/caps-api/fs-checks/versioned/stat.js +80 -0
  112. package/build/tests/caps-api/fs-checks/versioned/watchFile.d.ts +2 -0
  113. package/build/tests/caps-api/fs-checks/versioned/watchFile.js +64 -0
  114. package/build/tests/caps-api/fs-checks/versioned/writeBytes.d.ts +2 -0
  115. package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +128 -0
  116. package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.d.ts +2 -0
  117. package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.js +111 -0
  118. package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.d.ts +2 -0
  119. package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.js +107 -0
  120. package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.d.ts +2 -0
  121. package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +50 -0
  122. package/build/tests/caps-api/keyrings.js +69 -0
  123. package/build/tests/caps-api/mailerid.d.ts +1 -0
  124. package/build/tests/caps-api/mailerid.js +59 -0
  125. package/build/tests/caps-api/startup/signin-empty-cache.d.ts +1 -0
  126. package/build/tests/caps-api/startup/signin-empty-cache.js +108 -0
  127. package/build/tests/caps-api/startup/signin-with-cache.d.ts +1 -0
  128. package/build/tests/caps-api/startup/signin-with-cache.js +83 -0
  129. package/build/tests/caps-api/startup/signup-with-token.d.ts +1 -0
  130. package/build/tests/caps-api/startup/signup-with-token.js +53 -0
  131. package/build/tests/caps-api/startup/signup.d.ts +1 -0
  132. package/build/tests/caps-api/startup/signup.js +86 -0
  133. package/build/tests/caps-api/storage.d.ts +1 -0
  134. package/build/tests/caps-api/storage.js +225 -0
  135. package/build/tests/computer.3nweb.core/id-manager.d.ts +1 -0
  136. package/build/tests/computer.3nweb.core/id-manager.js +78 -0
  137. package/build/tests/computer.3nweb.core/inbox/msg-indexing.d.ts +1 -0
  138. package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +145 -0
  139. package/build/tests/computer.3nweb.core/keyrings.d.ts +1 -0
  140. package/build/tests/computer.3nweb.core/keyrings.js +64 -0
  141. package/build/tests/computer.3nweb.core/test-utils.d.ts +21 -0
  142. package/build/tests/computer.3nweb.core/test-utils.js +92 -0
  143. package/build/tests/jasmine.d.ts +1 -0
  144. package/build/tests/jasmine.js +45 -0
  145. package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
  146. package/build/tests/libs-for-tests/bytes-equal.js +32 -0
  147. package/build/tests/libs-for-tests/caps-ipc-wrap.d.ts +11 -0
  148. package/build/tests/libs-for-tests/caps-ipc-wrap.js +55 -0
  149. package/build/tests/libs-for-tests/core-runner.d.ts +39 -0
  150. package/build/tests/libs-for-tests/core-runner.js +231 -0
  151. package/build/tests/libs-for-tests/jasmine-utils.d.ts +13 -0
  152. package/build/tests/libs-for-tests/jasmine-utils.js +110 -0
  153. package/build/tests/libs-for-tests/json-equal.d.ts +1 -0
  154. package/build/tests/libs-for-tests/json-equal.js +78 -0
  155. package/build/tests/libs-for-tests/services-runner.d.ts +18 -0
  156. package/build/tests/libs-for-tests/services-runner.js +64 -0
  157. package/build/tests/libs-for-tests/setups.d.ts +51 -0
  158. package/build/tests/libs-for-tests/setups.js +305 -0
  159. package/build/tests/libs-for-tests/spec-module.d.ts +16 -0
  160. package/build/tests/libs-for-tests/spec-module.js +92 -0
  161. package/build/tests/libs-for-tests/startup.d.ts +1 -0
  162. package/build/tests/libs-for-tests/startup.js +29 -0
  163. package/build/tests/libs-for-tests/watching.d.ts +7 -0
  164. package/build/tests/libs-for-tests/watching.js +33 -0
  165. package/build/tests/units/canonical-address.d.ts +1 -0
  166. package/build/tests/units/canonical-address.js +41 -0
  167. package/build/tests/units/device-fs.d.ts +1 -0
  168. package/build/tests/units/device-fs.js +70 -0
  169. package/build/tests/units/folder-node-serialization.d.ts +1 -0
  170. package/build/tests/units/folder-node-serialization.js +74 -0
  171. package/build/tests/units/mid-sigs-NaCl-Ed.d.ts +1 -0
  172. package/build/tests/units/mid-sigs-NaCl-Ed.js +123 -0
  173. package/build/tests/units/number-line.d.ts +1 -0
  174. package/build/tests/units/number-line.js +63 -0
  175. package/build/tests/units/obj-folders.d.ts +1 -0
  176. package/build/tests/units/obj-folders.js +152 -0
  177. package/package.json +11 -3
  178. package/postinstall.js +1 -1
  179. package/build/cryptors.d.ts +0 -1
  180. package/build/cryptors.js +0 -34
  181. package/build/lib-client/cryptor/cryptor-in-worker.d.ts +0 -20
  182. package/build/lib-client/cryptor/cryptor-in-worker.js +0 -357
  183. package/build/lib-client/cryptor/cryptor-wasm.js +0 -1
  184. package/build/lib-client/cryptor/cryptor.d.ts +0 -30
  185. package/build/lib-client/cryptor/cryptor.js +0 -44
  186. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  187. package/build/lib-client/cryptor/in-proc-js.d.ts +0 -2
  188. package/build/lib-client/cryptor/in-proc-js.js +0 -57
  189. package/build/lib-client/cryptor/in-proc-wasm.d.ts +0 -2
  190. package/build/lib-client/cryptor/in-proc-wasm.js +0 -176
  191. package/build/lib-client/cryptor/serialization-for-wasm.d.ts +0 -35
  192. package/build/lib-client/cryptor/serialization-for-wasm.js +0 -57
  193. package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +0 -5
  194. package/build/lib-client/cryptor/wasm-mp1-modules.js +0 -78
  195. package/build/lib-client/cryptor/worker-js.js +0 -131
  196. package/build/lib-client/cryptor/worker-wasm.js +0 -37
  197. package/build/protos/cryptor.proto.js +0 -1804
  198. /package/build/lib-client/{cryptor/cryptor-work-labels.d.ts → cryptor-work-labels.d.ts} +0 -0
  199. /package/build/lib-client/{cryptor/cryptor-work-labels.js → cryptor-work-labels.js} +0 -0
  200. /package/build/{lib-client/cryptor/worker-js.d.ts → tests/caps-api/asmail.d.ts} +0 -0
  201. /package/build/{lib-client/cryptor/worker-wasm.d.ts → tests/caps-api/keyrings.d.ts} +0 -0
@@ -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
+ }
@@ -0,0 +1,64 @@
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.ServicesRunner = void 0;
20
+ const path_1 = require("path");
21
+ const async_fs_node_1 = require("../../lib-common/async-fs-node");
22
+ const serverMod = require("spec-3nweb-server");
23
+ const DATA_FOLDER = (0, path_1.join)(__dirname, '../../../test-server-data');
24
+ let numOfRunningServers = 0;
25
+ class ServicesRunner {
26
+ constructor(port, domains) {
27
+ this.port = port;
28
+ this.domains = domains;
29
+ this.stopFn = undefined;
30
+ numOfRunningServers += 1;
31
+ this.serverNum = numOfRunningServers;
32
+ this.dataFolder = `${DATA_FOLDER}-${this.serverNum}-${Date.now()}`;
33
+ Object.seal(this);
34
+ }
35
+ async start() {
36
+ const { stop } = await serverMod.mock.startOnLocalhost(this.dataFolder, this.port, this.domains);
37
+ this.stopFn = stop;
38
+ }
39
+ async stop(cleanup = true) {
40
+ if (!this.stopFn) {
41
+ return;
42
+ }
43
+ await this.stopFn();
44
+ this.stopFn = undefined;
45
+ if (cleanup) {
46
+ await this.cleanup();
47
+ }
48
+ }
49
+ async cleanup() {
50
+ numOfRunningServers -= 1;
51
+ await (0, async_fs_node_1.rmDirWithContent)(this.dataFolder).catch((exc) => {
52
+ if (!exc.notFound) {
53
+ throw exc;
54
+ }
55
+ });
56
+ }
57
+ createSingleUserSignupCtx(userId) {
58
+ return serverMod.addSingleUserSignup(this.dataFolder, userId);
59
+ }
60
+ }
61
+ exports.ServicesRunner = ServicesRunner;
62
+ Object.freeze(ServicesRunner.prototype);
63
+ Object.freeze(ServicesRunner);
64
+ Object.freeze(exports);
@@ -0,0 +1,51 @@
1
+ import { CoreRunner, User } from "./core-runner";
2
+ export interface Setup {
3
+ runner: CoreRunner;
4
+ signupDomains: string[];
5
+ isUp: boolean;
6
+ server: {
7
+ createSingleUserSignupCtx(userId: string): Promise<string>;
8
+ };
9
+ }
10
+ /**
11
+ * This creates a minimal working setup of core and server, and calls simple
12
+ * before and after methods, that do start and stop of everything.
13
+ * @param signupDomains are domains, for which server will create users without
14
+ * token and other.
15
+ * @return a setup object, for access to core, for restarting mid-test, etc.
16
+ */
17
+ export declare function minimalSetup(signupDomains?: {
18
+ noTokenSignup: string[];
19
+ other: string[];
20
+ }): Setup;
21
+ type CommonW3N = web3n.caps.common.W3N;
22
+ export interface MultiUserSetup {
23
+ users: User[];
24
+ runners: Map<string, CoreRunner>;
25
+ testAppCapsByUserIndex(i: number, viaIPC?: boolean): CommonW3N;
26
+ testAppCapsByUser(u: User, viaIPC?: boolean): CommonW3N;
27
+ sndDevByUserIndex(userNum: number, viaIPC?: boolean): Promise<DevForSetup>;
28
+ sndDevByUser(u: User, viaIPC?: boolean): Promise<DevForSetup>;
29
+ isUp: boolean;
30
+ }
31
+ /**
32
+ * This function creates users inside of usual
33
+ * @param users is a list of user ids to create. Default users are created,
34
+ * if no value given.
35
+ * Setup automatically sets DNS for domains from these ids.
36
+ * @return a setup object, for access to cores, for restarting mid-test, etc.
37
+ */
38
+ export declare function setupWithUsers(setupTestAppCaps?: boolean, users?: string[]): MultiUserSetup;
39
+ export declare function serviceWithMailerIdLogin(): {
40
+ serviceUrl: string;
41
+ isSessionValid: (sessionId: string) => Promise<boolean>;
42
+ };
43
+ export declare class DevForSetup {
44
+ private readonly runner;
45
+ private readonly viaIPC;
46
+ constructor(runner: CoreRunner, viaIPC?: boolean);
47
+ start(): Promise<void>;
48
+ stop(): Promise<void>;
49
+ get w3n(): web3n.caps.common.W3N;
50
+ }
51
+ export {};
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2020 - 2022, 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.DevForSetup = void 0;
20
+ exports.minimalSetup = minimalSetup;
21
+ exports.setupWithUsers = setupWithUsers;
22
+ exports.serviceWithMailerIdLogin = serviceWithMailerIdLogin;
23
+ const core_runner_1 = require("./core-runner");
24
+ const jasmine_utils_1 = require("./jasmine-utils");
25
+ const timeout_1 = require("../../lib-common/processes/timeout");
26
+ const services_runner_1 = require("./services-runner");
27
+ const assert_1 = require("../../lib-common/assert");
28
+ const request_utils_1 = require("../../lib-client/request-utils");
29
+ const retrieval_1 = require("../../lib-common/service-api/asmail/retrieval");
30
+ const sleep_1 = require("../../lib-common/processes/sleep");
31
+ const SERVICE_PORT = 8088;
32
+ const SIGNUP_URL = `https://localhost:${SERVICE_PORT}/signup/`;
33
+ function makeSetupObject(domains) {
34
+ const runner = new core_runner_1.CoreRunner(SIGNUP_URL);
35
+ const server = new services_runner_1.ServicesRunner(SERVICE_PORT, domains);
36
+ let isUp = false;
37
+ let isStopped = false;
38
+ const s = {
39
+ get runner() { return runner; },
40
+ get signupDomains() { return domains.noTokenSignup; },
41
+ get isUp() { return isUp; },
42
+ get server() {
43
+ return {
44
+ createSingleUserSignupCtx: (userId) => server.createSingleUserSignupCtx(userId)
45
+ };
46
+ }
47
+ };
48
+ async function setUp() {
49
+ try {
50
+ await server.start();
51
+ isUp = true;
52
+ }
53
+ catch (err) {
54
+ await setDown().catch(() => { });
55
+ throw err;
56
+ }
57
+ }
58
+ async function setDown() {
59
+ if (isStopped) {
60
+ return;
61
+ }
62
+ isUp = false;
63
+ isStopped = true;
64
+ await (0, sleep_1.sleep)(1000);
65
+ try {
66
+ try {
67
+ await runner.close()
68
+ .catch(err => {
69
+ console.error(`\n>>> error in closing core's runner`, err);
70
+ throw err;
71
+ });
72
+ }
73
+ finally {
74
+ await runner.cleanup(true)
75
+ .catch(err => {
76
+ console.error(`\n>>> error in cleanup of core's runner`, err);
77
+ throw err;
78
+ });
79
+ }
80
+ }
81
+ finally {
82
+ await server.stop()
83
+ .catch(err => {
84
+ console.error(`\n>>> error in stopping server`, err);
85
+ throw err;
86
+ });
87
+ }
88
+ }
89
+ return { s, setUp, setDown };
90
+ }
91
+ /**
92
+ * This creates a minimal working setup of core and server, and calls simple
93
+ * before and after methods, that do start and stop of everything.
94
+ * @param signupDomains are domains, for which server will create users without
95
+ * token and other.
96
+ * @return a setup object, for access to core, for restarting mid-test, etc.
97
+ */
98
+ function minimalSetup(signupDomains = {
99
+ noTokenSignup: ['company.inc', 'personal.net'],
100
+ other: []
101
+ }) {
102
+ const { s, setDown, setUp } = makeSetupObject(signupDomains);
103
+ (0, jasmine_utils_1.beforeAllWithTimeoutLog)(() => setUp());
104
+ (0, jasmine_utils_1.afterAllCond)(async () => {
105
+ if (s.isUp) {
106
+ await (0, timeout_1.callWithTimeout)(setDown, 5000, () => `Timeout when calling teardown of test setup`).catch(async (err) => {
107
+ console.log(`\n>>> error in teardown:`, err);
108
+ });
109
+ }
110
+ }, 6000);
111
+ return s;
112
+ }
113
+ function makeMultiUserSetupObject(domains) {
114
+ const runners = new Map();
115
+ const sndDevRunners = new Map();
116
+ const server = new services_runner_1.ServicesRunner(SERVICE_PORT, domains);
117
+ const users = [];
118
+ let isUp = false;
119
+ let isStopped = false;
120
+ function testAppCapsByUser(u, viaIPC = true) {
121
+ const r = runners.get(u.userId);
122
+ (0, assert_1.assert)(!!r, `Core runner is missing for user ${u.userId}`);
123
+ if (viaIPC) {
124
+ return r.appCapsViaIPC;
125
+ }
126
+ else {
127
+ return r.rawAppCaps;
128
+ }
129
+ }
130
+ function testAppCapsByUserIndex(i, viaIPC) {
131
+ const u = users[i];
132
+ (0, assert_1.assert)(!!u, `Given index ${i} is not pointing to existing user`);
133
+ return testAppCapsByUser(u, viaIPC);
134
+ }
135
+ async function sndDevByUser(u, viaIPC = true) {
136
+ let r = sndDevRunners.get(u.userId);
137
+ if (!r) {
138
+ const mainR = runners.get(u.userId);
139
+ (0, assert_1.assert)(!!mainR, `Core runner is missing for user ${u.userId}`);
140
+ r = await mainR.makeAndLoginNewCore();
141
+ sndDevRunners.set(u.userId, r);
142
+ }
143
+ return new DevForSetup(r, viaIPC);
144
+ }
145
+ function sndDevByUserIndex(i, viaIPC = true) {
146
+ const u = users[i];
147
+ (0, assert_1.assert)(!!u, `Given index ${i} is not pointing to existing user`);
148
+ return sndDevByUser(u, viaIPC);
149
+ }
150
+ const s = {
151
+ runners,
152
+ users,
153
+ get isUp() { return isUp; },
154
+ testAppCapsByUser,
155
+ testAppCapsByUserIndex,
156
+ sndDevByUser,
157
+ sndDevByUserIndex
158
+ };
159
+ async function createUser(userId) {
160
+ const runner = new core_runner_1.CoreRunner(SIGNUP_URL);
161
+ const user = await runner.createUser(userId)
162
+ .catch(async (err) => {
163
+ await runner.cleanup(true);
164
+ throw err;
165
+ });
166
+ runners.set(user.userId, runner);
167
+ users.push(user);
168
+ return user;
169
+ }
170
+ async function setUp(users) {
171
+ try {
172
+ await server.start();
173
+ const makingUsers = users.map(address => createUser(address));
174
+ await Promise.all(makingUsers);
175
+ isUp = true;
176
+ }
177
+ catch (err) {
178
+ await setDown().catch(() => { });
179
+ throw err;
180
+ }
181
+ }
182
+ async function setDown() {
183
+ if (isStopped) {
184
+ return;
185
+ }
186
+ isUp = false;
187
+ isStopped = true;
188
+ await (0, sleep_1.sleep)(1000);
189
+ try {
190
+ for (const iter of [runners.values(), sndDevRunners.values()]) {
191
+ for (const runner of iter) {
192
+ try {
193
+ await runner.close()
194
+ .catch(err => {
195
+ console.error(`\n>>> error in closing core's runner`, err);
196
+ throw err;
197
+ });
198
+ }
199
+ finally {
200
+ await runner.cleanup(true)
201
+ .catch(err => {
202
+ console.error(`\n>>> error in cleanup of core's runner`, err);
203
+ throw err;
204
+ });
205
+ }
206
+ }
207
+ }
208
+ }
209
+ finally {
210
+ await server.stop()
211
+ .catch(err => {
212
+ console.error(`\n>>> error in stopping server`, err);
213
+ throw err;
214
+ });
215
+ }
216
+ }
217
+ return { s, setUp, setDown };
218
+ }
219
+ /**
220
+ * This function creates users inside of usual
221
+ * @param users is a list of user ids to create. Default users are created,
222
+ * if no value given.
223
+ * Setup automatically sets DNS for domains from these ids.
224
+ * @return a setup object, for access to cores, for restarting mid-test, etc.
225
+ */
226
+ function setupWithUsers(setupTestAppCaps = true, users = ['Bob Marley @rock.cafe']) {
227
+ if (users.length === 0) {
228
+ throw new Error('No user given to setup.');
229
+ }
230
+ const { s, setDown, setUp } = makeMultiUserSetupObject({
231
+ noTokenSignup: users.map(domainFromUserId),
232
+ other: []
233
+ });
234
+ (0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
235
+ await setUp(users);
236
+ if (setupTestAppCaps) {
237
+ for (const runner of s.runners.values()) {
238
+ runner.setupTestAppCaps();
239
+ }
240
+ }
241
+ }, users.length * 7000);
242
+ (0, jasmine_utils_1.afterAllCond)(async () => {
243
+ if (s.isUp) {
244
+ await (0, timeout_1.callWithTimeout)(setDown, 5000, () => `Timeout when calling teardown of test setup`).catch(async (err) => {
245
+ console.log(`\n>>> error in teardown:`, err);
246
+ });
247
+ }
248
+ }, 6000);
249
+ return s;
250
+ }
251
+ function domainFromUserId(userId) {
252
+ const indAt = userId.indexOf('@');
253
+ if (indAt < 0) {
254
+ return userId;
255
+ }
256
+ else {
257
+ return userId.substring(indAt + 1);
258
+ }
259
+ }
260
+ function serviceWithMailerIdLogin() {
261
+ const testSrv = (new URL(SIGNUP_URL)).host;
262
+ const serviceUrl = `https://${testSrv}/asmail/retrieval/login/mailerid`;
263
+ const net = (0, request_utils_1.makeNetClient)();
264
+ async function isSessionValid(sessionId) {
265
+ const rep = await net.doBodylessRequest({
266
+ url: `https://${testSrv}/asmail/retrieval/${retrieval_1.listMsgs.genUrlEnd()}`,
267
+ method: 'GET',
268
+ responseType: 'json',
269
+ sessionId
270
+ });
271
+ if (rep.status === retrieval_1.listMsgs.SC.ok) {
272
+ return true;
273
+ }
274
+ else if (rep.status === 403) {
275
+ return false;
276
+ }
277
+ else {
278
+ throw Error(`Got ${rep.status} from service`);
279
+ }
280
+ }
281
+ return { serviceUrl, isSessionValid };
282
+ }
283
+ class DevForSetup {
284
+ constructor(runner, viaIPC = true) {
285
+ this.runner = runner;
286
+ this.viaIPC = viaIPC;
287
+ Object.seal(this);
288
+ }
289
+ async start() {
290
+ await this.runner.loginUser();
291
+ this.runner.setupTestAppCaps();
292
+ }
293
+ async stop() {
294
+ await this.runner.close();
295
+ }
296
+ get w3n() {
297
+ return (this.viaIPC ?
298
+ this.runner.appCapsViaIPC :
299
+ this.runner.rawAppCaps);
300
+ }
301
+ }
302
+ exports.DevForSetup = DevForSetup;
303
+ Object.freeze(DevForSetup.prototype);
304
+ Object.freeze(DevForSetup);
305
+ Object.freeze(exports);
@@ -0,0 +1,16 @@
1
+ export interface SpecIt<S> {
2
+ expectation: string;
3
+ disableIn?: DisableFlag | DisableFlag[];
4
+ notIncludedIn?: DisableFlag | DisableFlag[];
5
+ func?: (setup: S) => Promise<void>;
6
+ timeout?: number;
7
+ }
8
+ export type DisableFlag = 'device-fs' | 'win-local-fs';
9
+ export interface SpecDescribe {
10
+ description: string;
11
+ its: SpecIt<any>[];
12
+ focused?: boolean;
13
+ }
14
+ export declare function loadSpecs<S extends {
15
+ isUp: boolean;
16
+ }>(setup: S | undefined, folderWithModules: string, offFlags?: DisableFlag[]): void;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016, 2018, 2020, 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.loadSpecs = loadSpecs;
20
+ const jasmine_utils_1 = require("./jasmine-utils");
21
+ const path_1 = require("path");
22
+ const fs_1 = require("fs");
23
+ function readSpecs(folderWithModules) {
24
+ const specs = [];
25
+ const modulesWithSpecs = (0, fs_1.readdirSync)(folderWithModules)
26
+ .filter(fName => fName.endsWith('.js'));
27
+ for (const fName of modulesWithSpecs) {
28
+ const s = require((0, path_1.join)(folderWithModules, fName)).specs;
29
+ if (s) {
30
+ specs.push(s);
31
+ }
32
+ else {
33
+ console.error(`Module ${fName} is not exposing specs objects with tests`);
34
+ }
35
+ }
36
+ return specs;
37
+ }
38
+ function specFuncFor(it, offFlags) {
39
+ if (offFlags) {
40
+ if (it.notIncludedIn) {
41
+ if (Array.isArray(it.notIncludedIn)) {
42
+ for (const flag of it.notIncludedIn) {
43
+ if (offFlags.includes(flag)) {
44
+ return;
45
+ }
46
+ }
47
+ }
48
+ else {
49
+ if (offFlags.includes(it.notIncludedIn)) {
50
+ return;
51
+ }
52
+ }
53
+ }
54
+ if (it.disableIn) {
55
+ if (Array.isArray(it.disableIn)) {
56
+ for (const flag of it.disableIn) {
57
+ if (offFlags.includes(flag)) {
58
+ return jasmine_utils_1.xitCond;
59
+ }
60
+ }
61
+ }
62
+ else {
63
+ if (offFlags.includes(it.disableIn)) {
64
+ return jasmine_utils_1.xitCond;
65
+ }
66
+ }
67
+ }
68
+ }
69
+ return jasmine_utils_1.itCond;
70
+ }
71
+ function loadSpecs(setup, folderWithModules, offFlags) {
72
+ const specs = readSpecs(folderWithModules);
73
+ specs.forEach((d) => {
74
+ const describeFn = (d.focused ? fdescribe : describe);
75
+ const its = d.its
76
+ .map(it => ({ spec: specFuncFor(it, offFlags), it }))
77
+ .filter(({ spec }) => !!spec);
78
+ if (its.length > 0) {
79
+ describeFn(d.description, () => {
80
+ its.forEach(({ spec, it }) => {
81
+ spec(it.expectation, async function () {
82
+ if (!it.func || (setup && !setup.isUp)) {
83
+ return;
84
+ }
85
+ await it.func(setup);
86
+ }, it.timeout);
87
+ });
88
+ });
89
+ }
90
+ });
91
+ }
92
+ Object.freeze(exports);
@@ -0,0 +1 @@
1
+ export declare function checkKeyDerivNotifications(notifPerc: number[]): void;
@@ -0,0 +1,29 @@
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
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.checkKeyDerivNotifications = checkKeyDerivNotifications;
20
+ function checkKeyDerivNotifications(notifPerc) {
21
+ expect(notifPerc.length).toBeGreaterThan(0);
22
+ let prevP = -1;
23
+ for (let i = 0; i < notifPerc.length; i += 1) {
24
+ const p = notifPerc[i];
25
+ expect(p).toBeGreaterThan(prevP);
26
+ prevP = p;
27
+ }
28
+ }
29
+ Object.freeze(exports);
@@ -0,0 +1,7 @@
1
+ import { Subscriber } from 'rxjs';
2
+ export type WatchSetup<T> = (obs: Subscriber<T>) => (() => void);
3
+ export type FilterPredicate<T> = (ev: T) => boolean;
4
+ export declare function watchForEvents<T>(setupFn: WatchSetup<T>, numOfEvents: number, predicate?: FilterPredicate<T>, timeoutMillis?: number): {
5
+ collectedEvents: T[];
6
+ completion: Promise<void>;
7
+ };