core-3nweb-client-lib 0.44.11 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/asmail/msg/opener.js +1 -1
- package/build/core/asmail/msg/packer.js +1 -1
- package/build/core/index.d.ts +2 -2
- package/build/core/keyring/correspondent-keys.js +1 -1
- package/build/core/keyring/index.js +1 -1
- package/build/core/startup/sign-in.d.ts +1 -1
- package/build/core/startup/sign-up.d.ts +1 -1
- package/build/core/storage/index.d.ts +1 -1
- package/build/lib-client/key-derivation.d.ts +1 -1
- package/build/lib-client/xsp-fs/attrs.d.ts +3 -2
- package/build/lib-client/xsp-fs/attrs.js +7 -6
- package/build/lib-client/xsp-fs/folder-node.js +1 -1
- package/build/lib-client/xsp-fs/node-in-fs.js +1 -0
- package/build/lib-client/xsp-fs/node-persistence.js +1 -1
- package/build/lib-client/xsp-fs/xsp-payload-v2.js +1 -1
- package/build/tests/caps-api/asmail/specs/events.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/events.js +63 -0
- package/build/tests/caps-api/asmail/specs/send-to-wrong-address.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-to-wrong-address.js +68 -0
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +259 -0
- package/build/tests/caps-api/asmail/specs/send-without-attachments.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-without-attachments.js +90 -0
- package/build/tests/caps-api/asmail/test-utils.d.ts +12 -0
- package/build/tests/caps-api/asmail/test-utils.js +60 -0
- package/build/tests/caps-api/asmail.js +86 -0
- package/build/tests/caps-api/file-sink-checks/different-cases.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/different-cases.js +47 -0
- package/build/tests/caps-api/file-sink-checks/splice.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/splice.js +122 -0
- package/build/tests/caps-api/file-sink-checks/truncate.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/truncate.js +122 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.js +82 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.js +50 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.js +73 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.js +75 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +96 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +67 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.js +77 -0
- package/build/tests/caps-api/fs-checks/not-versioned/link.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/link.js +115 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listFolder.js +129 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.js +73 -0
- package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.js +95 -0
- package/build/tests/caps-api/fs-checks/not-versioned/move.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/move.js +127 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +80 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.js +59 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readLink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readLink.js +39 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.js +54 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.js +55 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.js +55 -0
- package/build/tests/caps-api/fs-checks/not-versioned/select.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/select.js +119 -0
- package/build/tests/caps-api/fs-checks/not-versioned/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/stat.js +96 -0
- package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.js +126 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableFile.js +79 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.js +90 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +137 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.js +101 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.js +100 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +187 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +70 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +53 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +194 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +396 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +229 -0
- package/build/tests/caps-api/fs-checks/test-utils.d.ts +34 -0
- package/build/tests/caps-api/fs-checks/test-utils.js +95 -0
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +73 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +122 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +71 -0
- package/build/tests/caps-api/fs-checks/versioned/listFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/listFolder.js +109 -0
- package/build/tests/caps-api/fs-checks/versioned/listVersions.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/listVersions.js +48 -0
- package/build/tests/caps-api/fs-checks/versioned/readBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readBytes.js +90 -0
- package/build/tests/caps-api/fs-checks/versioned/readJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readJSONFile.js +60 -0
- package/build/tests/caps-api/fs-checks/versioned/readTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readTxtFile.js +56 -0
- package/build/tests/caps-api/fs-checks/versioned/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/stat.js +80 -0
- package/build/tests/caps-api/fs-checks/versioned/watchFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/watchFile.js +64 -0
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +128 -0
- package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.js +111 -0
- package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.js +107 -0
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +50 -0
- package/build/tests/caps-api/keyrings.js +69 -0
- package/build/tests/caps-api/mailerid.d.ts +1 -0
- package/build/tests/caps-api/mailerid.js +59 -0
- package/build/tests/caps-api/startup/signin-empty-cache.d.ts +1 -0
- package/build/tests/caps-api/startup/signin-empty-cache.js +108 -0
- package/build/tests/caps-api/startup/signin-with-cache.d.ts +1 -0
- package/build/tests/caps-api/startup/signin-with-cache.js +83 -0
- package/build/tests/caps-api/startup/signup-with-token.d.ts +1 -0
- package/build/tests/caps-api/startup/signup-with-token.js +53 -0
- package/build/tests/caps-api/startup/signup.d.ts +1 -0
- package/build/tests/caps-api/startup/signup.js +86 -0
- package/build/tests/caps-api/storage.d.ts +1 -0
- package/build/tests/caps-api/storage.js +225 -0
- package/build/tests/computer.3nweb.core/id-manager.d.ts +1 -0
- package/build/tests/computer.3nweb.core/id-manager.js +78 -0
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.d.ts +1 -0
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +145 -0
- package/build/tests/computer.3nweb.core/keyrings.d.ts +1 -0
- package/build/tests/computer.3nweb.core/keyrings.js +64 -0
- package/build/tests/computer.3nweb.core/test-utils.d.ts +21 -0
- package/build/tests/computer.3nweb.core/test-utils.js +92 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +45 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +32 -0
- package/build/tests/libs-for-tests/caps-ipc-wrap.d.ts +11 -0
- package/build/tests/libs-for-tests/caps-ipc-wrap.js +55 -0
- package/build/tests/libs-for-tests/core-runner.d.ts +39 -0
- package/build/tests/libs-for-tests/core-runner.js +231 -0
- package/build/tests/libs-for-tests/jasmine-utils.d.ts +13 -0
- package/build/tests/libs-for-tests/jasmine-utils.js +110 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/json-equal.js +78 -0
- package/build/tests/libs-for-tests/services-runner.d.ts +18 -0
- package/build/tests/libs-for-tests/services-runner.js +64 -0
- package/build/tests/libs-for-tests/setups.d.ts +51 -0
- package/build/tests/libs-for-tests/setups.js +305 -0
- package/build/tests/libs-for-tests/spec-module.d.ts +16 -0
- package/build/tests/libs-for-tests/spec-module.js +92 -0
- package/build/tests/libs-for-tests/startup.d.ts +1 -0
- package/build/tests/libs-for-tests/startup.js +29 -0
- package/build/tests/libs-for-tests/watching.d.ts +7 -0
- package/build/tests/libs-for-tests/watching.js +33 -0
- package/build/tests/units/canonical-address.d.ts +1 -0
- package/build/tests/units/canonical-address.js +41 -0
- package/build/tests/units/device-fs.d.ts +1 -0
- package/build/tests/units/device-fs.js +70 -0
- package/build/tests/units/folder-node-serialization.d.ts +1 -0
- package/build/tests/units/folder-node-serialization.js +74 -0
- package/build/tests/units/mid-sigs-NaCl-Ed.d.ts +1 -0
- package/build/tests/units/mid-sigs-NaCl-Ed.js +123 -0
- package/build/tests/units/number-line.d.ts +1 -0
- package/build/tests/units/number-line.js +63 -0
- package/build/tests/units/obj-folders.d.ts +1 -0
- package/build/tests/units/obj-folders.js +152 -0
- package/package.json +11 -3
- package/postinstall.js +1 -1
- package/build/cryptors.d.ts +0 -1
- package/build/cryptors.js +0 -34
- package/build/lib-client/cryptor/cryptor-in-worker.d.ts +0 -20
- package/build/lib-client/cryptor/cryptor-in-worker.js +0 -357
- package/build/lib-client/cryptor/cryptor-wasm.js +0 -1
- package/build/lib-client/cryptor/cryptor.d.ts +0 -30
- package/build/lib-client/cryptor/cryptor.js +0 -44
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.d.ts +0 -2
- package/build/lib-client/cryptor/in-proc-js.js +0 -57
- package/build/lib-client/cryptor/in-proc-wasm.d.ts +0 -2
- package/build/lib-client/cryptor/in-proc-wasm.js +0 -176
- package/build/lib-client/cryptor/serialization-for-wasm.d.ts +0 -35
- package/build/lib-client/cryptor/serialization-for-wasm.js +0 -57
- package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +0 -5
- package/build/lib-client/cryptor/wasm-mp1-modules.js +0 -78
- package/build/lib-client/cryptor/worker-js.js +0 -131
- package/build/lib-client/cryptor/worker-wasm.js +0 -37
- package/build/protos/cryptor.proto.js +0 -1804
- /package/build/lib-client/{cryptor/cryptor-work-labels.d.ts → cryptor-work-labels.d.ts} +0 -0
- /package/build/lib-client/{cryptor/cryptor-work-labels.js → cryptor-work-labels.js} +0 -0
- /package/build/{lib-client/cryptor/worker-js.d.ts → tests/caps-api/asmail.d.ts} +0 -0
- /package/build/{lib-client/cryptor/worker-wasm.d.ts → tests/caps-api/keyrings.d.ts} +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2018, 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
|
+
const jasmine_utils_1 = require("../libs-for-tests/jasmine-utils");
|
|
20
|
+
const setups_1 = require("../libs-for-tests/setups");
|
|
21
|
+
const spec_module_1 = require("../libs-for-tests/spec-module");
|
|
22
|
+
const path_1 = require("path");
|
|
23
|
+
const os_1 = require("os");
|
|
24
|
+
const storage_1 = require("../../core/storage");
|
|
25
|
+
const core_runner_1 = require("../libs-for-tests/core-runner");
|
|
26
|
+
const test_utils_1 = require("./fs-checks/test-utils");
|
|
27
|
+
const assert_1 = require("../../lib-common/assert");
|
|
28
|
+
const allowedAppFS = core_runner_1.testApp.capsRequested.storage.appFS
|
|
29
|
+
.map(s => (0, storage_1.reverseDomain)(s.domain));
|
|
30
|
+
describe('3NStorage', () => {
|
|
31
|
+
const s = (0, setups_1.setupWithUsers)(true);
|
|
32
|
+
let w3n;
|
|
33
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
34
|
+
if (!s.isUp) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
w3n = s.testAppCapsByUserIndex(0);
|
|
38
|
+
});
|
|
39
|
+
(0, jasmine_utils_1.itCond)('storage capability is present in test app', async () => {
|
|
40
|
+
expect(typeof w3n.storage).toBe('object');
|
|
41
|
+
}, undefined, s);
|
|
42
|
+
describe('.getAppSyncedFS', () => {
|
|
43
|
+
(0, jasmine_utils_1.itCond)('will not produce FS for domain (reversed), not associated with app', async () => {
|
|
44
|
+
await w3n.storage.getAppSyncedFS('com.app.unknown')
|
|
45
|
+
.then(() => {
|
|
46
|
+
fail('should not produce FS for an arbitrary app');
|
|
47
|
+
}, (e) => {
|
|
48
|
+
expect(e.runtimeException).toBe(true);
|
|
49
|
+
expect(e.type).toBe('storage');
|
|
50
|
+
expect(e.notAllowedToOpenFS).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
}, undefined, s);
|
|
53
|
+
(0, jasmine_utils_1.itCond)('produces FS for domains (reversed), associated with app', async () => {
|
|
54
|
+
for (const appDomain of allowedAppFS) {
|
|
55
|
+
const fs = await w3n.storage.getAppSyncedFS(appDomain);
|
|
56
|
+
expect(fs).toBeTruthy();
|
|
57
|
+
}
|
|
58
|
+
}, undefined, s);
|
|
59
|
+
(0, jasmine_utils_1.itCond)('concurrently produces FS for an app', async () => {
|
|
60
|
+
const appDomain = allowedAppFS[0];
|
|
61
|
+
const promises = [];
|
|
62
|
+
for (let i = 0; i < 10; i += 1) {
|
|
63
|
+
const promise = w3n.storage.getAppSyncedFS(appDomain);
|
|
64
|
+
promises.push(promise);
|
|
65
|
+
}
|
|
66
|
+
await Promise.all(promises)
|
|
67
|
+
.then((fss) => {
|
|
68
|
+
for (const fs of fss) {
|
|
69
|
+
expect(fs).toBeTruthy();
|
|
70
|
+
}
|
|
71
|
+
}, () => {
|
|
72
|
+
fail(`Fail to concurrently get app fs`);
|
|
73
|
+
});
|
|
74
|
+
}, undefined, s);
|
|
75
|
+
});
|
|
76
|
+
describe('.getAppLocalFS', () => {
|
|
77
|
+
(0, jasmine_utils_1.itCond)('will not produce FS for domain, not associated with app', async () => {
|
|
78
|
+
await w3n.storage.getAppLocalFS('com.app.unknown')
|
|
79
|
+
.then(() => {
|
|
80
|
+
fail('should not produce FS for an arbitrary app');
|
|
81
|
+
}, (e) => {
|
|
82
|
+
expect(e.runtimeException).toBe(true);
|
|
83
|
+
expect(e.type).toBe('storage');
|
|
84
|
+
expect(e.notAllowedToOpenFS).toBeTruthy();
|
|
85
|
+
});
|
|
86
|
+
}, undefined, s);
|
|
87
|
+
(0, jasmine_utils_1.itCond)('produces FS for domains (reversed), associated with app', async () => {
|
|
88
|
+
for (const appDomain of allowedAppFS) {
|
|
89
|
+
const fs = await w3n.storage.getAppLocalFS(appDomain);
|
|
90
|
+
expect(fs).toBeTruthy();
|
|
91
|
+
}
|
|
92
|
+
}, undefined, s);
|
|
93
|
+
(0, jasmine_utils_1.itCond)('concurrently produces FS for an app', async () => {
|
|
94
|
+
const appDomain = allowedAppFS[0];
|
|
95
|
+
const promises = [];
|
|
96
|
+
for (let i = 0; i < 10; i += 1) {
|
|
97
|
+
const promise = w3n.storage.getAppLocalFS(appDomain);
|
|
98
|
+
promises.push(promise);
|
|
99
|
+
}
|
|
100
|
+
await Promise.all(promises)
|
|
101
|
+
.then((fss) => {
|
|
102
|
+
for (const fs of fss) {
|
|
103
|
+
expect(fs).toBeTruthy();
|
|
104
|
+
}
|
|
105
|
+
}, () => {
|
|
106
|
+
fail(`Fail to concurrently get app fs`);
|
|
107
|
+
});
|
|
108
|
+
}, undefined, s);
|
|
109
|
+
});
|
|
110
|
+
describe('.getSysFS', () => {
|
|
111
|
+
(0, jasmine_utils_1.itCond)('produces collection of items in synced storage', async () => {
|
|
112
|
+
const sysItems = await w3n.storage.getSysFS('synced');
|
|
113
|
+
expect(sysItems.isCollection).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
(0, jasmine_utils_1.itCond)('produces device item, indicated by path', async () => {
|
|
116
|
+
const semiRandomDevFolder = __dirname;
|
|
117
|
+
const devItems = await w3n.storage.getSysFS('device', semiRandomDevFolder);
|
|
118
|
+
expect(devItems.isFolder).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('local FS is a web3n.files.WritableFS', () => {
|
|
122
|
+
const fsSetup = {};
|
|
123
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
124
|
+
if (!s.isUp) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
fsSetup.isUp = true;
|
|
128
|
+
fsSetup.testFS = await w3n.storage.getAppLocalFS(allowedAppFS[0]);
|
|
129
|
+
});
|
|
130
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
131
|
+
if (!s.isUp) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
await (0, test_utils_1.clearFS)(fsSetup.testFS);
|
|
135
|
+
});
|
|
136
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'not-versioned'), (((0, os_1.platform)() === 'win32') ? ['win-local-fs'] : undefined));
|
|
137
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'file-sink-checks'));
|
|
138
|
+
});
|
|
139
|
+
describe('local FS is a web3n.files.WritableFS with versioned API', () => {
|
|
140
|
+
const fsSetup = {};
|
|
141
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
142
|
+
if (!s.isUp) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
fsSetup.isUp = true;
|
|
146
|
+
fsSetup.testFS = await w3n.storage.getAppLocalFS(allowedAppFS[0]);
|
|
147
|
+
});
|
|
148
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
149
|
+
if (!s.isUp) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
await (0, test_utils_1.clearFS)(fsSetup.testFS);
|
|
153
|
+
});
|
|
154
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'versioned'));
|
|
155
|
+
});
|
|
156
|
+
function syncedFsSetup() {
|
|
157
|
+
const fsSetup = {};
|
|
158
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
159
|
+
if (!s.isUp) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
fsSetup.testFS = await w3n.storage.getAppSyncedFS(allowedAppFS[0]);
|
|
163
|
+
(0, assert_1.assert)(!!fsSetup.testFS.v.sync);
|
|
164
|
+
fsSetup.isUp = true;
|
|
165
|
+
});
|
|
166
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
167
|
+
if (!s.isUp) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
await (0, test_utils_1.clearFS)(fsSetup.testFS);
|
|
171
|
+
});
|
|
172
|
+
return fsSetup;
|
|
173
|
+
}
|
|
174
|
+
describe('synced FS is a web3n.files.WritableFS', () => {
|
|
175
|
+
const fsSetup = syncedFsSetup();
|
|
176
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'not-versioned'));
|
|
177
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'file-sink-checks'));
|
|
178
|
+
});
|
|
179
|
+
describe('synced FS is a web3n.files.WritableFS with versioned API', () => {
|
|
180
|
+
const fsSetup = syncedFsSetup();
|
|
181
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'versioned'));
|
|
182
|
+
});
|
|
183
|
+
describe('synced FS is a web3n.files.WritableFS with sync API', () => {
|
|
184
|
+
const fsSetup = syncedFsSetup();
|
|
185
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'sync-on-one-dev'));
|
|
186
|
+
});
|
|
187
|
+
describe('local to synced FS linking', () => {
|
|
188
|
+
const fsSetup = {};
|
|
189
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
190
|
+
if (!s.isUp) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
fsSetup.isUp = true;
|
|
194
|
+
const domain = allowedAppFS[0];
|
|
195
|
+
fsSetup.localTestFS = await w3n.storage.getAppLocalFS(domain);
|
|
196
|
+
fsSetup.syncedTestFS = await w3n.storage.getAppSyncedFS(domain);
|
|
197
|
+
});
|
|
198
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
199
|
+
if (!s.isUp) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
await (0, test_utils_1.clearFS)(fsSetup.localTestFS);
|
|
203
|
+
await (0, test_utils_1.clearFS)(fsSetup.syncedTestFS);
|
|
204
|
+
});
|
|
205
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'local-to-synced-linking'));
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
describe(`3NStorage`, () => {
|
|
209
|
+
describe('with two devices', () => {
|
|
210
|
+
const baseSetup = (0, setups_1.setupWithUsers)();
|
|
211
|
+
const testFolder = `multi-dev-testing`;
|
|
212
|
+
const { fsSetup, setupDevsAndFSs } = (0, test_utils_1.makeSetupWithTwoDevsFSs)(testFolder);
|
|
213
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
214
|
+
await setupDevsAndFSs(baseSetup);
|
|
215
|
+
}, 20000);
|
|
216
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
217
|
+
if (!baseSetup.isUp) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
await fsSetup.resetFS();
|
|
221
|
+
});
|
|
222
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'sync-with-two-devs'));
|
|
223
|
+
(0, spec_module_1.loadSpecs)(fsSetup, (0, path_1.join)(__dirname, 'fs-checks', 'with-core-restarts'));
|
|
224
|
+
});
|
|
225
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 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 key_storage_1 = require("../../core/id-manager/key-storage");
|
|
20
|
+
const random_node_1 = require("../../lib-common/random-node");
|
|
21
|
+
const jasmine_utils_1 = require("../libs-for-tests/jasmine-utils");
|
|
22
|
+
const json_equal_1 = require("../libs-for-tests/json-equal");
|
|
23
|
+
const setups_1 = require("../libs-for-tests/setups");
|
|
24
|
+
const test_utils_1 = require("./test-utils");
|
|
25
|
+
async function failOnErrLog(err) {
|
|
26
|
+
fail(err);
|
|
27
|
+
}
|
|
28
|
+
async function failOnWarning(msg) {
|
|
29
|
+
fail(msg);
|
|
30
|
+
}
|
|
31
|
+
describe('Key storage of IdManager', () => {
|
|
32
|
+
const baseSetup = (0, setups_1.setupWithUsers)();
|
|
33
|
+
const testFolder = `id-manager-test`;
|
|
34
|
+
const { fsSetup: setup, setupDevsAndFSs } = (0, test_utils_1.makeSetupWithTwoDevsFSs)(testFolder);
|
|
35
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
36
|
+
await setupDevsAndFSs(baseSetup);
|
|
37
|
+
}, 20000);
|
|
38
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
39
|
+
if (!setup.isUp) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await setup.resetFS();
|
|
43
|
+
});
|
|
44
|
+
(0, jasmine_utils_1.itCond)(`initializes with and without storage`, async () => {
|
|
45
|
+
const { dev2, dev1FS, dev2FS } = setup;
|
|
46
|
+
await dev2.stop();
|
|
47
|
+
const loginKeys = {
|
|
48
|
+
address: await (0, random_node_1.stringOfB64Chars)(50),
|
|
49
|
+
keys: [{
|
|
50
|
+
alg: await (0, random_node_1.stringOfB64Chars)(5),
|
|
51
|
+
k: await (0, random_node_1.stringOfB64Chars)(48),
|
|
52
|
+
kid: await (0, random_node_1.stringOfB64Chars)(15),
|
|
53
|
+
use: await (0, random_node_1.stringOfB64Chars)(6)
|
|
54
|
+
}]
|
|
55
|
+
};
|
|
56
|
+
const { store: storeOnDev1, setupManagerStorage } = key_storage_1.IdKeysStorage.makeWithoutStorage(failOnErrLog, failOnWarning);
|
|
57
|
+
await storeOnDev1.getSavedKey().then(() => fail(`Non-initialized storage should fail`), () => { });
|
|
58
|
+
const fsOnDev1 = dev1FS();
|
|
59
|
+
expect((await fsOnDev1.listFolder('')).length)
|
|
60
|
+
.withContext(`there are no files before setup`).toBe(0);
|
|
61
|
+
await setupManagerStorage(fsOnDev1, loginKeys);
|
|
62
|
+
expect((await fsOnDev1.listFolder('')).length)
|
|
63
|
+
.withContext(`setup write some file`).toBeGreaterThan(0);
|
|
64
|
+
expect((0, json_equal_1.deepEqual)(await storeOnDev1.getSavedKey(), loginKeys.keys[0]))
|
|
65
|
+
.withContext(`keys should be available after setup`).toBeTrue();
|
|
66
|
+
await dev2.start();
|
|
67
|
+
const fsOnDev2 = dev2FS();
|
|
68
|
+
expect((await fsOnDev2.listFolder('')).length)
|
|
69
|
+
.withContext(`dev2 should've missed all changes on dev1`).toBe(0);
|
|
70
|
+
expect((await fsOnDev2.v.sync.status('')).state)
|
|
71
|
+
.withContext(`dev2 should've missed all changes on dev1`).toBe('behind');
|
|
72
|
+
const storeOnDev2 = key_storage_1.IdKeysStorage.makeWithStorage(fsOnDev2, failOnErrLog, failOnWarning);
|
|
73
|
+
expect((0, json_equal_1.deepEqual)(await storeOnDev2.getSavedKey(), loginKeys.keys[0]))
|
|
74
|
+
.withContext(`on dev2 have key that was saved on dev1`).toBeTrue();
|
|
75
|
+
expect((await fsOnDev2.listFolder('')).length)
|
|
76
|
+
.withContext(`getting saved key updated state of fs`).toBeGreaterThan(0);
|
|
77
|
+
}, undefined, setup);
|
|
78
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 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
|
+
const msg_indexing_1 = require("../../../core/asmail/inbox/msg-indexing");
|
|
20
|
+
// import { MsgKeyInfo } from "../core/asmail/keyring";
|
|
21
|
+
const jasmine_utils_1 = require("../../libs-for-tests/jasmine-utils");
|
|
22
|
+
const setups_1 = require("../../libs-for-tests/setups");
|
|
23
|
+
const test_utils_1 = require("../test-utils");
|
|
24
|
+
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
25
|
+
const bytes_equal_1 = require("../../libs-for-tests/bytes-equal");
|
|
26
|
+
const sleep_1 = require("../../../lib-common/processes/sleep");
|
|
27
|
+
const msgs = [
|
|
28
|
+
{
|
|
29
|
+
m: {
|
|
30
|
+
msgType: 'mail',
|
|
31
|
+
msgId: 'F-vo1A4zInEBGq994-e3KvrE9a8QXLcr',
|
|
32
|
+
deliveryTS: 1664923830399
|
|
33
|
+
},
|
|
34
|
+
k: {
|
|
35
|
+
correspondent: 'johnmorrison@bank.com',
|
|
36
|
+
keyStatus: 'published_intro',
|
|
37
|
+
key: buffer_utils_1.base64.open('0Uz7wGW4P7hdik7fuStC+avi7iXk7AZ5B1KxJCxIOQk='),
|
|
38
|
+
msgKeyPackLen: 72
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
m: {
|
|
43
|
+
msgType: 'mail',
|
|
44
|
+
msgId: 'JYXfEEcg3-iX7UDjG3BU0Jha9DYX_Jt-',
|
|
45
|
+
deliveryTS: 1664923830658
|
|
46
|
+
},
|
|
47
|
+
k: {
|
|
48
|
+
correspondent: 'johnmorrison@bank.com',
|
|
49
|
+
keyStatus: 'published_intro',
|
|
50
|
+
key: buffer_utils_1.base64.open('gjArW3Mr3ACnoFds/wKFZJm+pp9De1TlNhWIkpyd4Ow='),
|
|
51
|
+
msgKeyPackLen: 72
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
m: {
|
|
56
|
+
msgType: 'mail',
|
|
57
|
+
msgId: 'BQ2HO6hs4-Kov1M4wxL8oeTw_UFlvI3G',
|
|
58
|
+
deliveryTS: 1664923831175
|
|
59
|
+
},
|
|
60
|
+
k: {
|
|
61
|
+
correspondent: 'johnmorrison@bank.com',
|
|
62
|
+
keyStatus: 'published_intro',
|
|
63
|
+
key: buffer_utils_1.base64.open('lGr0hEGHMDrWa+QMEfmcsu/VPZbalN3gF+8LRi8Ai54='),
|
|
64
|
+
msgKeyPackLen: 72
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
m: {
|
|
69
|
+
msgType: 'mail',
|
|
70
|
+
msgId: 'g5TWqqY11W32xv_ivoqGRsQmnEG1f3j0',
|
|
71
|
+
deliveryTS: 1664923832168
|
|
72
|
+
},
|
|
73
|
+
k: {
|
|
74
|
+
correspondent: 'johnmorrison@bank.com',
|
|
75
|
+
keyStatus: 'published_intro',
|
|
76
|
+
key: buffer_utils_1.base64.open('8O/Ts2kZ37Y0yaSqGiRscYxPRQJu6cvfNXTgHKSNtyw='),
|
|
77
|
+
msgKeyPackLen: 72
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
m: {
|
|
82
|
+
msgId: 'some message id',
|
|
83
|
+
deliveryTS: 1664923760381,
|
|
84
|
+
msgType: 'mail'
|
|
85
|
+
},
|
|
86
|
+
k: {
|
|
87
|
+
correspondent: 'bob@some.domain',
|
|
88
|
+
keyStatus: 'introductory',
|
|
89
|
+
msgKeyPackLen: 50,
|
|
90
|
+
key: buffer_utils_1.base64.open('sdafkjkljasfdsafjksadfkljasdf')
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
xdescribe(`Inbox MsgIndex`, () => {
|
|
95
|
+
const baseSetup = (0, setups_1.setupWithUsers)();
|
|
96
|
+
const testFolder = `inbox-indexing-test`;
|
|
97
|
+
let dev1Index;
|
|
98
|
+
const { fsSetup: setup, setupDevsAndFSs } = (0, test_utils_1.makeSetupWithTwoDevsFSs)(testFolder);
|
|
99
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
100
|
+
await setupDevsAndFSs(baseSetup);
|
|
101
|
+
}, 20000);
|
|
102
|
+
beforeEach(async () => {
|
|
103
|
+
dev1Index = await msg_indexing_1.MsgIndex.make(setup.dev1FS());
|
|
104
|
+
});
|
|
105
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
106
|
+
if (!setup.isUp) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
dev1Index.stopSyncing();
|
|
110
|
+
await setup.resetFS();
|
|
111
|
+
});
|
|
112
|
+
(0, jasmine_utils_1.itCond)(`is a container for message info`, async () => {
|
|
113
|
+
const m0 = msgs[0];
|
|
114
|
+
const m1 = msgs[1];
|
|
115
|
+
let lst = await dev1Index.listMsgs(undefined);
|
|
116
|
+
expect(Array.isArray(lst)).toBeTrue();
|
|
117
|
+
expect(lst.length).toBe(0);
|
|
118
|
+
await dev1Index.add(m0.m, m0.k);
|
|
119
|
+
await dev1Index.add(m1.m, m1.k);
|
|
120
|
+
const tsOfLast = m1.m.deliveryTS;
|
|
121
|
+
lst = await dev1Index.listMsgs(undefined);
|
|
122
|
+
expect(lst.length).toBe(2);
|
|
123
|
+
lst = await dev1Index.listMsgs(tsOfLast);
|
|
124
|
+
expect(lst.length).toBe(0);
|
|
125
|
+
await dev1Index.remove(m0.m.msgId);
|
|
126
|
+
lst = await dev1Index.listMsgs(undefined);
|
|
127
|
+
expect(lst.length).toBe(1);
|
|
128
|
+
const keyInfo = await dev1Index.getKeyFor(m1.m.msgId, m1.m.deliveryTS);
|
|
129
|
+
expect((0, bytes_equal_1.bytesEqual)(keyInfo.msgKey, m1.k.key))
|
|
130
|
+
.toBeTrue();
|
|
131
|
+
}, undefined, setup);
|
|
132
|
+
(0, jasmine_utils_1.itCond)(`work with race conditions on different devices`, async () => {
|
|
133
|
+
for (const m of msgs.slice(0, 2)) {
|
|
134
|
+
await dev1Index.add(m.m, m.k);
|
|
135
|
+
}
|
|
136
|
+
// sleep to allow time for propagation to dev2
|
|
137
|
+
await (0, sleep_1.sleep)(100);
|
|
138
|
+
const dev2Index = await msg_indexing_1.MsgIndex.make(setup.dev2FS());
|
|
139
|
+
let lst = await dev2Index.listMsgs(undefined);
|
|
140
|
+
expect(lst.length)
|
|
141
|
+
.withContext(``)
|
|
142
|
+
.toBe(2);
|
|
143
|
+
dev2Index.stopSyncing();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 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_utils_1 = require("../libs-for-tests/jasmine-utils");
|
|
20
|
+
const setups_1 = require("../libs-for-tests/setups");
|
|
21
|
+
const test_utils_1 = require("./test-utils");
|
|
22
|
+
const address = `address Bob Perkins @company.inc`;
|
|
23
|
+
const introPKeyFromServer = {
|
|
24
|
+
use: 'asmail-pub-key',
|
|
25
|
+
alg: 'NaCl-box-CXSP',
|
|
26
|
+
kid: 'EKnB33DQsmpq2RiL',
|
|
27
|
+
k: 'hDeWvNYajaAFUijY23SlXFKhIFOuMJLWtIBJYtiToEQ='
|
|
28
|
+
};
|
|
29
|
+
describe('ASMail keyring', () => {
|
|
30
|
+
const baseSetup = (0, setups_1.setupWithUsers)();
|
|
31
|
+
const testFolder = `keyring-test`;
|
|
32
|
+
let keyring;
|
|
33
|
+
const { fsSetup: setup, setupDevsAndFSs } = (0, test_utils_1.makeSetupWithTwoDevsFSs)(testFolder);
|
|
34
|
+
(0, jasmine_utils_1.beforeAllWithTimeoutLog)(async () => {
|
|
35
|
+
await setupDevsAndFSs(baseSetup);
|
|
36
|
+
}, 20000);
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
const fs = setup.dev1FS();
|
|
39
|
+
// keyring = await makeAndKeyRing(cryptor, fs, {
|
|
40
|
+
// find: kid => { throw Error(`publishedKeys.find() mock`); },
|
|
41
|
+
// update: async () => { throw Error(`publishedKeys.update() mock`); }
|
|
42
|
+
// });
|
|
43
|
+
});
|
|
44
|
+
(0, jasmine_utils_1.afterEachCond)(async () => {
|
|
45
|
+
if (!setup.isUp) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
await setup.resetFS();
|
|
49
|
+
});
|
|
50
|
+
(0, jasmine_utils_1.itCond)(`.generateKeysToSend()`, async () => {
|
|
51
|
+
// const {
|
|
52
|
+
// currentPair, encryptor, msgCount
|
|
53
|
+
// } = await keyring.generateKeysToSend(address, introPKeyFromServer);
|
|
54
|
+
// // DEBUG
|
|
55
|
+
// // console.log(`currentPair`, currentPair, `
|
|
56
|
+
// // msgCount`, msgCount);
|
|
57
|
+
// const {
|
|
58
|
+
// currentPair: cp, msgCount: count
|
|
59
|
+
// } = await keyring.generateKeysToSend(address);
|
|
60
|
+
// // DEBUG
|
|
61
|
+
// // console.log(`currentPair`, cp, `
|
|
62
|
+
// // msgCount`, count);
|
|
63
|
+
}, undefined, setup);
|
|
64
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MultiUserSetup } from "../libs-for-tests/setups";
|
|
2
|
+
import { SpecIt as GenericSpecIt } from "../libs-for-tests/spec-module";
|
|
3
|
+
type WritableFS = web3n.files.WritableFS;
|
|
4
|
+
export interface SetupWithTwoDevsFSs {
|
|
5
|
+
isUp: boolean;
|
|
6
|
+
dev1FS: () => WritableFS;
|
|
7
|
+
dev1LocalFS: () => WritableFS;
|
|
8
|
+
dev2: {
|
|
9
|
+
stop(): Promise<void>;
|
|
10
|
+
start(): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
dev2FS: () => WritableFS;
|
|
13
|
+
dev2LocalFS: () => WritableFS;
|
|
14
|
+
resetFS: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export type SpecItWithTwoDevsFSs = GenericSpecIt<SetupWithTwoDevsFSs>;
|
|
17
|
+
export declare function makeSetupWithTwoDevsFSs(testFolder: string): {
|
|
18
|
+
fsSetup: SetupWithTwoDevsFSs;
|
|
19
|
+
setupDevsAndFSs: (baseSetup: MultiUserSetup) => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 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
|
+
exports.makeSetupWithTwoDevsFSs = makeSetupWithTwoDevsFSs;
|
|
20
|
+
function makeSetupWithTwoDevsFSs(testFolder) {
|
|
21
|
+
const fsSetup = {};
|
|
22
|
+
const setupDevsAndFSs = async (baseSetup) => {
|
|
23
|
+
if (!baseSetup.isUp) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const w3n1 = baseSetup.testAppCapsByUserIndex(0);
|
|
27
|
+
const dev2 = await baseSetup.sndDevByUserIndex(0);
|
|
28
|
+
const dev1AppFS = await w3n1.storage.getAppSyncedFS();
|
|
29
|
+
const dev2AppFS = () => dev2.w3n.storage.getAppSyncedFS();
|
|
30
|
+
const dev1LocalAppFS = await w3n1.storage.getAppLocalFS();
|
|
31
|
+
const dev2LocalAppFS = () => dev2.w3n.storage.getAppLocalFS();
|
|
32
|
+
let dev1FS;
|
|
33
|
+
let dev2FS;
|
|
34
|
+
fsSetup.dev1FS = () => dev1FS;
|
|
35
|
+
fsSetup.dev2FS = () => dev2FS;
|
|
36
|
+
let dev1LocalFS;
|
|
37
|
+
let dev2LocalFS;
|
|
38
|
+
fsSetup.dev1LocalFS = () => dev1LocalFS;
|
|
39
|
+
fsSetup.dev2LocalFS = () => dev2LocalFS;
|
|
40
|
+
fsSetup.dev2 = {
|
|
41
|
+
start: async () => {
|
|
42
|
+
await dev2.start();
|
|
43
|
+
dev2FS = await (await dev2AppFS()).writableSubRoot(testFolder);
|
|
44
|
+
},
|
|
45
|
+
stop: async () => {
|
|
46
|
+
dev2FS = undefined;
|
|
47
|
+
await dev2.stop();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
fsSetup.resetFS = async () => {
|
|
51
|
+
await clearFS(dev1AppFS);
|
|
52
|
+
dev1FS = await dev1AppFS.writableSubRoot(testFolder, { create: true, exclusive: true });
|
|
53
|
+
await dev1AppFS.v.sync.upload(testFolder);
|
|
54
|
+
await dev1AppFS.v.sync.upload('');
|
|
55
|
+
const d2AppFS = await dev2AppFS();
|
|
56
|
+
const status = await d2AppFS.v.sync.status('');
|
|
57
|
+
if (status.state === 'behind') {
|
|
58
|
+
await d2AppFS.v.sync.adoptRemote('');
|
|
59
|
+
}
|
|
60
|
+
else if (status.state === 'conflicting') {
|
|
61
|
+
throw new Error(`Test file system on a second device has inconvenient conflicting sync state`);
|
|
62
|
+
}
|
|
63
|
+
dev2FS = await d2AppFS.writableSubRoot(testFolder, { create: false });
|
|
64
|
+
await clearFS(dev1LocalAppFS);
|
|
65
|
+
dev1LocalFS = await dev1LocalAppFS.writableSubRoot(testFolder, { create: true, exclusive: true });
|
|
66
|
+
const d2LocalAppFS = await dev2LocalAppFS();
|
|
67
|
+
dev2LocalFS = await d2LocalAppFS.writableSubRoot(testFolder, { create: true, exclusive: true });
|
|
68
|
+
};
|
|
69
|
+
await fsSetup.resetFS();
|
|
70
|
+
fsSetup.isUp = true;
|
|
71
|
+
};
|
|
72
|
+
return { fsSetup, setupDevsAndFSs };
|
|
73
|
+
}
|
|
74
|
+
async function clearFS(fs) {
|
|
75
|
+
let items = await fs.listFolder('');
|
|
76
|
+
let delTasks = [];
|
|
77
|
+
for (let f of items) {
|
|
78
|
+
if (f.isFile) {
|
|
79
|
+
delTasks.push(fs.deleteFile(f.name));
|
|
80
|
+
}
|
|
81
|
+
else if (f.isFolder) {
|
|
82
|
+
delTasks.push(fs.deleteFolder(f.name, true));
|
|
83
|
+
}
|
|
84
|
+
else if (f.isLink) {
|
|
85
|
+
delTasks.push(fs.deleteLink(f.name));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
throw new Error(`File system item is neither file, nor folder, nor link`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
await Promise.all(delTasks);
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|