core-3nweb-client-lib 0.25.6 → 0.27.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/README.md +2 -2
- package/build/api-defs/asmail.d.ts +1 -1
- package/build/api-defs/files.d.ts +282 -70
- package/build/core/app-files.js +7 -7
- package/build/core/asmail/config/common.js +4 -4
- package/build/core/asmail/config/index.js +2 -2
- package/build/core/asmail/config/published-intro-key.js +1 -1
- package/build/core/asmail/delivery/common.js +7 -7
- package/build/core/asmail/delivery/index.js +7 -6
- package/build/core/asmail/delivery/msg.js +8 -7
- package/build/core/asmail/delivery/per-recipient-wip.js +3 -3
- package/build/core/asmail/inbox/attachments/fs.js +11 -1
- package/build/core/asmail/inbox/cached-msgs.js +3 -3
- package/build/core/asmail/inbox/inbox-events.js +5 -4
- package/build/core/asmail/inbox/index.js +12 -12
- package/build/core/asmail/inbox/msg-downloader.js +3 -3
- package/build/core/asmail/inbox/msg-indexing.js +4 -4
- package/build/core/asmail/inbox/msg-on-disk.js +7 -7
- package/build/core/asmail/index.d.ts +3 -3
- package/build/core/asmail/index.js +13 -8
- package/build/core/asmail/key-verification.js +5 -5
- package/build/core/asmail/keyring/common.js +7 -6
- package/build/core/asmail/keyring/correspondent-keys.js +8 -7
- package/build/core/asmail/keyring/id-to-email-map.js +2 -1
- package/build/core/asmail/keyring/index.d.ts +7 -8
- package/build/core/asmail/keyring/index.js +15 -14
- package/build/core/asmail/keyring/keyring-storage.js +4 -3
- package/build/core/asmail/msg/opener.js +3 -3
- package/build/core/asmail/msg/packer.js +13 -13
- package/build/core/asmail/sending-params/own-params.js +4 -4
- package/build/core/asmail/sending-params/params-from-others.js +3 -3
- package/build/core/id-manager.js +8 -5
- package/build/core/index.d.ts +2 -1
- package/build/core/index.js +14 -14
- package/build/core/sign-in.d.ts +5 -4
- package/build/core/sign-in.js +12 -14
- package/build/core/sign-up.d.ts +1 -0
- package/build/core/sign-up.js +15 -11
- package/build/core/storage/common/json-saving.d.ts +21 -0
- package/build/core/storage/common/json-saving.js +82 -0
- package/build/core/storage/common/obj-info-file.d.ts +51 -0
- package/build/core/storage/common/obj-info-file.js +153 -5
- package/build/core/storage/common/utils.d.ts +2 -0
- package/build/core/storage/common/utils.js +32 -0
- package/build/core/storage/index.d.ts +3 -17
- package/build/core/storage/index.js +57 -77
- package/build/core/storage/local/obj-files-gc.d.ts +2 -0
- package/build/core/storage/local/obj-files-gc.js +53 -39
- package/build/core/storage/local/obj-files.d.ts +6 -9
- package/build/core/storage/local/obj-files.js +16 -19
- package/build/core/storage/local/obj-status.d.ts +20 -30
- package/build/core/storage/local/obj-status.js +46 -113
- package/build/core/storage/local/storage.d.ts +15 -5
- package/build/core/storage/local/storage.js +37 -18
- package/build/core/storage/synced/downloader.js +7 -6
- package/build/core/storage/synced/obj-files-gc.d.ts +6 -1
- package/build/core/storage/synced/obj-files-gc.js +106 -13
- package/build/core/storage/synced/obj-files.d.ts +46 -47
- package/build/core/storage/synced/obj-files.js +207 -154
- package/build/core/storage/synced/obj-status.d.ts +103 -42
- package/build/core/storage/synced/obj-status.js +525 -137
- package/build/core/storage/synced/remote-events.d.ts +11 -12
- package/build/core/storage/synced/remote-events.js +80 -57
- package/build/core/storage/synced/storage.d.ts +24 -5
- package/build/core/storage/synced/storage.js +123 -38
- package/build/core/storage/synced/upload-header-file.d.ts +4 -0
- package/build/core/storage/synced/upload-header-file.js +64 -0
- package/build/core/storage/synced/upsyncer.d.ts +15 -9
- package/build/core/storage/synced/upsyncer.js +219 -246
- package/build/core/storage/system-folders/apps-data.d.ts +16 -0
- package/build/core/storage/system-folders/apps-data.js +110 -0
- package/build/core/storage/system-folders/index.d.ts +18 -0
- package/build/core/storage/system-folders/index.js +77 -0
- package/build/core-ipc/common-caps.js +3 -3
- package/build/core-ipc/generic.js +8 -8
- package/build/core-ipc/startup-caps.js +2 -2
- package/build/cryptors.js +6 -2
- package/build/ipc-via-protobuf/asmail-cap.js +67 -83
- package/build/ipc-via-protobuf/bytes.js +16 -17
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -0
- package/build/ipc-via-protobuf/connector-clients-side.js +62 -25
- package/build/ipc-via-protobuf/connector-services-side.js +10 -10
- package/build/ipc-via-protobuf/connector.js +4 -4
- package/build/ipc-via-protobuf/file.d.ts +48 -12
- package/build/ipc-via-protobuf/file.js +476 -120
- package/build/ipc-via-protobuf/fs.d.ts +8 -0
- package/build/ipc-via-protobuf/fs.js +592 -159
- package/build/ipc-via-protobuf/log-cap.js +2 -2
- package/build/ipc-via-protobuf/mailerid.js +3 -3
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
- package/build/ipc-via-protobuf/startup-cap.js +23 -23
- package/build/ipc-via-protobuf/storage-cap.js +12 -12
- package/build/ipc.js +7 -2
- package/build/lib-client/3nstorage/exceptions.d.ts +12 -8
- package/build/lib-client/3nstorage/exceptions.js +31 -10
- package/build/lib-client/3nstorage/service.d.ts +16 -2
- package/build/lib-client/3nstorage/service.js +109 -39
- package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
- package/build/lib-client/3nstorage/util/file-based-json.js +1 -1
- package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +52 -14
- package/build/lib-client/3nstorage/xsp-fs/common.js +31 -16
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +18 -14
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
- package/build/lib-client/3nstorage/xsp-fs/file.js +74 -23
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +24 -11
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +599 -189
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +45 -9
- package/build/lib-client/3nstorage/xsp-fs/fs.js +326 -74
- package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -20
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +239 -106
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +18 -19
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +5 -5
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +56 -56
- package/build/lib-client/3nweb-signup.js +4 -4
- package/build/lib-client/asmail/recipient.js +15 -15
- package/build/lib-client/asmail/sender.js +22 -22
- package/build/lib-client/asmail/service-config.js +3 -3
- package/build/lib-client/cryptor/cryptor-in-worker.js +19 -17
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.js +4 -2
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.js +1 -1
- package/build/lib-client/cryptor/in-proc-wasm.js +7 -7
- package/build/lib-client/cryptor/worker-js.js +2 -2
- package/build/lib-client/cryptor/worker-wasm.js +2 -2
- package/build/lib-client/files-select.js +1 -1
- package/build/lib-client/files.d.ts +1 -1
- package/build/lib-client/files.js +71 -4
- package/build/lib-client/fs-collection.js +3 -2
- package/build/lib-client/fs-sync-utils.d.ts +5 -0
- package/build/lib-client/fs-sync-utils.js +61 -0
- package/build/lib-client/fs-view.d.ts +14 -0
- package/build/lib-client/fs-view.js +33 -0
- package/build/lib-client/key-derivation.js +1 -1
- package/build/lib-client/local-files/dev-file-sink.js +9 -9
- package/build/lib-client/local-files/dev-file-src.js +2 -2
- package/build/lib-client/local-files/device-fs.d.ts +1 -1
- package/build/lib-client/local-files/device-fs.js +56 -54
- package/build/lib-client/logging/log-to-file.d.ts +1 -1
- package/build/lib-client/logging/log-to-file.js +11 -11
- package/build/lib-client/mailer-id/login.js +7 -7
- package/build/lib-client/mailer-id/provisioner.js +12 -12
- package/build/lib-client/objs-on-disk/file-writing-proc.js +5 -5
- package/build/lib-client/objs-on-disk/obj-folders.js +33 -33
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
- package/build/lib-client/request-utils.d.ts +1 -0
- package/build/lib-client/request-utils.js +14 -14
- package/build/lib-client/server-events.d.ts +3 -3
- package/build/lib-client/server-events.js +12 -10
- package/build/lib-client/service-locator.js +10 -10
- package/build/lib-client/user-with-mid-session.js +7 -7
- package/build/lib-client/user-with-pkl-session.js +25 -25
- package/build/lib-client/ws-utils.js +3 -3
- package/build/lib-common/async-cryptor-wrap.js +4 -4
- package/build/lib-common/async-fs-node.d.ts +5 -3
- package/build/lib-common/async-fs-node.js +19 -18
- package/build/lib-common/byte-streaming/pipe.js +1 -1
- package/build/lib-common/byte-streaming/wrapping.js +17 -17
- package/build/lib-common/canonical-address.js +1 -1
- package/build/lib-common/exceptions/error.d.ts +1 -0
- package/build/lib-common/exceptions/error.js +7 -6
- package/build/lib-common/exceptions/file.js +10 -1
- package/build/lib-common/ipc/generic-ipc.js +2 -2
- package/build/lib-common/ipc/ws-ipc.js +2 -2
- package/build/lib-common/json-utils.js +2 -1
- package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
- package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
- package/build/lib-common/objs-on-disk/file-layout.js +130 -12
- package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
- package/build/lib-common/objs-on-disk/obj-file.js +99 -37
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/utils.js +4 -4
- package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
- package/build/lib-common/processes/deferred.d.ts +6 -0
- package/build/lib-common/processes/deferred.js +30 -0
- package/build/lib-common/processes/labelled-exec-pools.d.ts +33 -0
- package/build/lib-common/processes/labelled-exec-pools.js +141 -0
- package/build/lib-common/processes/pressure.d.ts +7 -0
- package/build/lib-common/processes/pressure.js +56 -0
- package/build/lib-common/processes/sleep.d.ts +1 -0
- package/build/lib-common/processes/sleep.js +26 -0
- package/build/lib-common/{processes.d.ts → processes/synced.d.ts} +0 -40
- package/build/lib-common/{processes.js → processes/synced.js} +187 -204
- package/build/lib-common/processes/timeout.d.ts +1 -0
- package/build/lib-common/processes/timeout.js +51 -0
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +100 -39
- package/build/lib-common/service-api/3nstorage/owner.js +85 -42
- package/build/lib-common/service-api/asmail/delivery.js +2 -2
- package/build/lib-common/service-api/asmail/retrieval.js +1 -1
- package/build/lib-common/timed-cache.d.ts +1 -0
- package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
- package/build/lib-common/timed-non-weak-cache.js +11 -0
- package/build/lib-common/utils-for-observables.d.ts +15 -1
- package/build/lib-common/utils-for-observables.js +70 -19
- package/build/lib-common/weak-cache.d.ts +1 -0
- package/build/lib-common/weak-cache.js +12 -1
- package/build/lib-index.d.ts +2 -1
- package/build/lib-index.js +10 -7
- package/build/protos/asmail.proto.js +12912 -7127
- package/build/protos/file.proto.js +4848 -2399
- package/build/protos/fs.proto.js +9230 -3445
- package/package.json +8 -7
- package/protos/file.proto +91 -11
- package/protos/fs.proto +107 -8
- package/build/core/storage/synced/upsync-status.d.ts +0 -41
- package/build/core/storage/synced/upsync-status.js +0 -158
|
@@ -17,16 +17,18 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.makeInProcessWasmCryptor = exports.makeInProcessCryptor = exports.makeInWorkerWasmCryptor = exports.makeInWorkerCryptor = void 0;
|
|
20
|
-
|
|
20
|
+
const makeInWorkerCryptor = (logErr, logWarning, maxThreads) => {
|
|
21
21
|
const mod = require('./cryptor-in-worker');
|
|
22
22
|
const makeInWorkerCryptor = mod.makeInWorkerCryptor;
|
|
23
23
|
return makeInWorkerCryptor(logErr, logWarning, maxThreads);
|
|
24
24
|
};
|
|
25
|
-
exports.
|
|
25
|
+
exports.makeInWorkerCryptor = makeInWorkerCryptor;
|
|
26
|
+
const makeInWorkerWasmCryptor = (logErr, logWarning, maxThreads) => {
|
|
26
27
|
const mod = require('./cryptor-in-worker');
|
|
27
28
|
const makeInWorkerWasmCryptor = mod.makeInWorkerWasmCryptor;
|
|
28
29
|
return makeInWorkerWasmCryptor(logErr, logWarning, maxThreads);
|
|
29
30
|
};
|
|
31
|
+
exports.makeInWorkerWasmCryptor = makeInWorkerWasmCryptor;
|
|
30
32
|
function makeInProcessCryptor() {
|
|
31
33
|
const mod = require('./in-proc-js');
|
|
32
34
|
const makeInProcessCryptor = mod.makeInProcessCryptor;
|
|
Binary file
|
|
@@ -31,7 +31,7 @@ function inNextTick(f) {
|
|
|
31
31
|
function makeInProcessCryptor() {
|
|
32
32
|
const arrFactory = ecma_nacl_1.arrays.makeFactory();
|
|
33
33
|
return {
|
|
34
|
-
scrypt: (passwd, salt, logN, r, p, dkLen, progressCB) => inNextTick(() => ecma_nacl_1.scrypt(passwd, salt, logN, r, p, dkLen, progressCB, arrFactory)),
|
|
34
|
+
scrypt: (passwd, salt, logN, r, p, dkLen, progressCB) => inNextTick(() => (0, ecma_nacl_1.scrypt)(passwd, salt, logN, r, p, dkLen, progressCB, arrFactory)),
|
|
35
35
|
box: {
|
|
36
36
|
calc_dhshared_key: (pk, sk) => inNextTick(() => ecma_nacl_1.box.calc_dhshared_key(pk, sk, arrFactory)),
|
|
37
37
|
generate_pubkey: sk => inNextTick(() => ecma_nacl_1.box.generate_pubkey(sk, arrFactory))
|
|
@@ -22,7 +22,7 @@ const fs_1 = require("fs");
|
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const protobuf_type_1 = require("../protobuf-type");
|
|
24
24
|
const cryptor_proto_1 = require("../../protos/cryptor.proto");
|
|
25
|
-
const
|
|
25
|
+
const deferred_1 = require("../../lib-common/processes/deferred");
|
|
26
26
|
const assert_1 = require("../../lib-common/assert");
|
|
27
27
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
28
28
|
function wasmBytes() {
|
|
@@ -35,9 +35,9 @@ function wasmBytes() {
|
|
|
35
35
|
const asarInd = __dirname.indexOf('app.asar');
|
|
36
36
|
const dirWithThis = ((asarInd < 0) ?
|
|
37
37
|
__dirname : `${__dirname.substring(0, asarInd + 8)}.unpacked${__dirname.substring(asarInd + 8)}`);
|
|
38
|
-
const wasmPath = path_1.join(dirWithThis, 'cryptor.wasm');
|
|
38
|
+
const wasmPath = (0, path_1.join)(dirWithThis, 'cryptor.wasm');
|
|
39
39
|
try {
|
|
40
|
-
return fs_1.readFileSync(wasmPath);
|
|
40
|
+
return (0, fs_1.readFileSync)(wasmPath);
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
43
|
// chances are that error is due to wasm file not being packaged, so, we
|
|
@@ -65,7 +65,7 @@ const replyType = protobuf_type_1.ProtoType.for(cryptor_proto_1.cryptor.Reply);
|
|
|
65
65
|
const boolValType = protobuf_type_1.ProtoType.for(cryptor_proto_1.cryptor.BoolVal);
|
|
66
66
|
const kpairType = protobuf_type_1.ProtoType.for(cryptor_proto_1.cryptor.Keypair);
|
|
67
67
|
function makeInProcessWasmCryptor() {
|
|
68
|
-
const wasmInstance = wasm_mp1_modules_1.startWasmFrom(wasmBytes());
|
|
68
|
+
const wasmInstance = (0, wasm_mp1_modules_1.startWasmFrom)(wasmBytes());
|
|
69
69
|
let deferred = undefined;
|
|
70
70
|
let interimSink = undefined;
|
|
71
71
|
async function call(req, interim) {
|
|
@@ -77,7 +77,7 @@ function makeInProcessWasmCryptor() {
|
|
|
77
77
|
}
|
|
78
78
|
catch (err) { }
|
|
79
79
|
}
|
|
80
|
-
deferred =
|
|
80
|
+
deferred = (0, deferred_1.defer)();
|
|
81
81
|
if (interim) {
|
|
82
82
|
interimSink = interim;
|
|
83
83
|
}
|
|
@@ -92,7 +92,7 @@ function makeInProcessWasmCryptor() {
|
|
|
92
92
|
return deferred.promise;
|
|
93
93
|
}
|
|
94
94
|
wasmInstance.setMsgListener(msg => {
|
|
95
|
-
assert_1.assert(!!deferred, `Deferred is expected to be available for this output from wasm`);
|
|
95
|
+
(0, assert_1.assert)(!!deferred, `Deferred is expected to be available for this output from wasm`);
|
|
96
96
|
try {
|
|
97
97
|
const reply = replyType.unpack(msg);
|
|
98
98
|
if (reply.res) {
|
|
@@ -101,7 +101,7 @@ function makeInProcessWasmCryptor() {
|
|
|
101
101
|
interimSink = undefined;
|
|
102
102
|
}
|
|
103
103
|
else if (reply.err) {
|
|
104
|
-
deferred.reject(error_1.errWithCause(toLocalErr(reply.err), `Error in cryptor`));
|
|
104
|
+
deferred.reject((0, error_1.errWithCause)(toLocalErr(reply.err), `Error in cryptor`));
|
|
105
105
|
deferred = undefined;
|
|
106
106
|
interimSink = undefined;
|
|
107
107
|
}
|
|
@@ -40,7 +40,7 @@ const funcs = {
|
|
|
40
40
|
const reply = { interim: n };
|
|
41
41
|
worker_threads_1.parentPort.postMessage(reply);
|
|
42
42
|
};
|
|
43
|
-
const res = ecma_nacl_1.scrypt(args[0], args[1], args[2], args[3], args[4], args[5], progressCB, arrFactory);
|
|
43
|
+
const res = (0, ecma_nacl_1.scrypt)(args[0], args[1], args[2], args[3], args[4], args[5], progressCB, arrFactory);
|
|
44
44
|
wipe(args[0]);
|
|
45
45
|
return { res };
|
|
46
46
|
// electron v.11.0.3 worker thread fails on memory move
|
|
@@ -117,7 +117,7 @@ function wrapError(err) {
|
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
119
|
exc.message = `Error occured in cryptor worker thread`;
|
|
120
|
-
exc.cause = error_1.stringifyErr(err);
|
|
120
|
+
exc.cause = (0, error_1.stringifyErr)(err);
|
|
121
121
|
}
|
|
122
122
|
return exc;
|
|
123
123
|
}
|
|
@@ -24,8 +24,8 @@ if (!worker_threads_1.parentPort) {
|
|
|
24
24
|
throw new Error(`Missing expected parentPort. Is this called within WebWorker process?`);
|
|
25
25
|
}
|
|
26
26
|
const wasmFName = 'cryptor.wasm';
|
|
27
|
-
const wasmModPath = path_1.join(worker_threads_1.workerData.loadDir, wasmFName);
|
|
28
|
-
const wasmInstance = wasm_mp1_modules_1.startWasmFrom(fs_1.readFileSync(wasmModPath));
|
|
27
|
+
const wasmModPath = (0, path_1.join)(worker_threads_1.workerData.loadDir, wasmFName);
|
|
28
|
+
const wasmInstance = (0, wasm_mp1_modules_1.startWasmFrom)((0, fs_1.readFileSync)(wasmModPath));
|
|
29
29
|
wasmInstance.setMsgListener(msg => worker_threads_1.parentPort.postMessage(msg));
|
|
30
30
|
worker_threads_1.parentPort.on('message', (msg) => {
|
|
31
31
|
try {
|
|
@@ -22,7 +22,7 @@ async function selectInFS(fs, path, criteria) {
|
|
|
22
22
|
// besides limiting fs to path, turning fs into readonly subroot ensures
|
|
23
23
|
// that fs object is a wrapped view and doesn't leak internals,
|
|
24
24
|
fs = await fs.readonlySubRoot(path);
|
|
25
|
-
const items = fs_collection_1.makeFSCollection();
|
|
25
|
+
const items = (0, fs_collection_1.makeFSCollection)();
|
|
26
26
|
const iterCB = (parentPath, entry) => {
|
|
27
27
|
if (match(entry, criteria)) {
|
|
28
28
|
if (criteria.action === 'include') {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare type FS = web3n.files.FS;
|
|
2
|
+
declare type FSType = web3n.files.FSType;
|
|
2
3
|
declare type ReadonlyFS = web3n.files.ReadonlyFS;
|
|
3
4
|
declare type WritableFS = web3n.files.WritableFS;
|
|
4
5
|
declare type File = web3n.files.File;
|
|
5
6
|
declare type ReadonlyFile = web3n.files.ReadonlyFile;
|
|
6
7
|
declare type WritableFile = web3n.files.WritableFile;
|
|
7
|
-
declare type FSType = web3n.files.FSType;
|
|
8
8
|
export interface LinkParameters<T> {
|
|
9
9
|
storageType: FSType;
|
|
10
10
|
readonly?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 -
|
|
3
|
+
Copyright (C) 2016 - 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -69,7 +69,24 @@ function wrapWritableFileVersionedAPI(vImpl) {
|
|
|
69
69
|
readTxt: vImpl.readTxt.bind(vImpl),
|
|
70
70
|
writeBytes: vImpl.writeBytes.bind(vImpl),
|
|
71
71
|
writeJSON: vImpl.writeJSON.bind(vImpl),
|
|
72
|
-
writeTxt: vImpl.writeTxt.bind(vImpl)
|
|
72
|
+
writeTxt: vImpl.writeTxt.bind(vImpl),
|
|
73
|
+
archiveCurrent: vImpl.archiveCurrent.bind(vImpl),
|
|
74
|
+
listVersions: vImpl.listVersions.bind(vImpl),
|
|
75
|
+
sync: wrapWritableFileSyncAPI(vImpl.sync)
|
|
76
|
+
};
|
|
77
|
+
return Object.freeze(w);
|
|
78
|
+
}
|
|
79
|
+
function wrapWritableFileSyncAPI(sImpl) {
|
|
80
|
+
if (!sImpl) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const w = {
|
|
84
|
+
status: sImpl.status.bind(sImpl),
|
|
85
|
+
updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
|
|
86
|
+
download: sImpl.download.bind(sImpl),
|
|
87
|
+
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
88
|
+
upload: sImpl.upload.bind(sImpl),
|
|
89
|
+
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
73
90
|
};
|
|
74
91
|
return Object.freeze(w);
|
|
75
92
|
}
|
|
@@ -106,7 +123,22 @@ function wrapReadonlyFileVersionedAPI(vImpl) {
|
|
|
106
123
|
getByteSource: vImpl.getByteSource.bind(vImpl),
|
|
107
124
|
readBytes: vImpl.readBytes.bind(vImpl),
|
|
108
125
|
readJSON: vImpl.readJSON.bind(vImpl),
|
|
109
|
-
readTxt: vImpl.readTxt.bind(vImpl)
|
|
126
|
+
readTxt: vImpl.readTxt.bind(vImpl),
|
|
127
|
+
listVersions: vImpl.listVersions.bind(vImpl),
|
|
128
|
+
sync: wrapReadonlyFileSyncAPI(vImpl.sync)
|
|
129
|
+
};
|
|
130
|
+
return Object.freeze(w);
|
|
131
|
+
}
|
|
132
|
+
function wrapReadonlyFileSyncAPI(sImpl) {
|
|
133
|
+
if (!sImpl) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const w = {
|
|
137
|
+
status: sImpl.status.bind(sImpl),
|
|
138
|
+
updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
|
|
139
|
+
download: sImpl.download.bind(sImpl),
|
|
140
|
+
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
141
|
+
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
110
142
|
};
|
|
111
143
|
return Object.freeze(w);
|
|
112
144
|
}
|
|
@@ -187,6 +219,25 @@ function wrapWritableFSVersionedAPI(vImpl) {
|
|
|
187
219
|
readTxtFile: vImpl.readTxtFile.bind(vImpl),
|
|
188
220
|
writeJSONFile: vImpl.writeJSONFile.bind(vImpl),
|
|
189
221
|
writeTxtFile: vImpl.writeTxtFile.bind(vImpl),
|
|
222
|
+
archiveCurrent: vImpl.archiveCurrent.bind(vImpl),
|
|
223
|
+
listVersions: vImpl.listVersions.bind(vImpl),
|
|
224
|
+
sync: wrapWritableFSSyncAPI(vImpl.sync)
|
|
225
|
+
};
|
|
226
|
+
return Object.freeze(w);
|
|
227
|
+
}
|
|
228
|
+
function wrapWritableFSSyncAPI(sImpl) {
|
|
229
|
+
if (!sImpl) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const w = {
|
|
233
|
+
status: sImpl.status.bind(sImpl),
|
|
234
|
+
updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
|
|
235
|
+
download: sImpl.download.bind(sImpl),
|
|
236
|
+
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
237
|
+
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
238
|
+
diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
|
|
239
|
+
upload: sImpl.upload.bind(sImpl),
|
|
240
|
+
adoptRemoteFolderItem: sImpl.adoptRemoteFolderItem.bind(sImpl),
|
|
190
241
|
};
|
|
191
242
|
return Object.freeze(w);
|
|
192
243
|
}
|
|
@@ -230,7 +281,23 @@ function wrapReadonlyFSVersionedAPI(vImpl) {
|
|
|
230
281
|
readBytes: vImpl.readBytes.bind(vImpl),
|
|
231
282
|
listFolder: vImpl.listFolder.bind(vImpl),
|
|
232
283
|
readJSONFile: vImpl.readJSONFile.bind(vImpl),
|
|
233
|
-
readTxtFile: vImpl.readTxtFile.bind(vImpl)
|
|
284
|
+
readTxtFile: vImpl.readTxtFile.bind(vImpl),
|
|
285
|
+
listVersions: vImpl.listVersions.bind(vImpl),
|
|
286
|
+
sync: wrapReadonlyFSSyncAPI(vImpl.sync)
|
|
287
|
+
};
|
|
288
|
+
return Object.freeze(w);
|
|
289
|
+
}
|
|
290
|
+
function wrapReadonlyFSSyncAPI(sImpl) {
|
|
291
|
+
if (!sImpl) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const w = {
|
|
295
|
+
status: sImpl.status.bind(sImpl),
|
|
296
|
+
updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
|
|
297
|
+
download: sImpl.download.bind(sImpl),
|
|
298
|
+
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
299
|
+
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
300
|
+
diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
|
|
234
301
|
};
|
|
235
302
|
return Object.freeze(w);
|
|
236
303
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017 - 2018 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017 - 2018, 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.makeFSCollection = exports.readonlyWrapFSCollection = void 0;
|
|
20
20
|
const rxjs_1 = require("rxjs");
|
|
21
|
+
const utils_for_observables_1 = require("../lib-common/utils-for-observables");
|
|
21
22
|
class FSItemsCollection {
|
|
22
23
|
constructor() {
|
|
23
24
|
this.items = new Map();
|
|
@@ -69,7 +70,7 @@ class FSItemsCollection {
|
|
|
69
70
|
return allItems;
|
|
70
71
|
}
|
|
71
72
|
watch(observer) {
|
|
72
|
-
const sub = this.change$.subscribe(observer);
|
|
73
|
+
const sub = this.change$.subscribe((0, utils_for_observables_1.toRxObserver)(observer));
|
|
73
74
|
return () => sub.unsubscribe();
|
|
74
75
|
}
|
|
75
76
|
wrap() {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare type WritableFS = web3n.files.WritableFS;
|
|
2
|
+
export declare function getRemoteFolderChanges(fs: WritableFS): Promise<void>;
|
|
3
|
+
export declare function getOrMakeAndUploadFolderIn(fs: WritableFS, folder: string): Promise<WritableFS>;
|
|
4
|
+
export declare function uploadFolderChangesIfAny(fs: WritableFS): Promise<void>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.uploadFolderChangesIfAny = exports.getOrMakeAndUploadFolderIn = exports.getRemoteFolderChanges = void 0;
|
|
20
|
+
const exceptions_1 = require("./3nstorage/exceptions");
|
|
21
|
+
async function getRemoteFolderChanges(fs) {
|
|
22
|
+
const { state } = await fs.v.sync.updateStatusInfo('');
|
|
23
|
+
if (state === 'behind') {
|
|
24
|
+
await fs.v.sync.adoptRemote('');
|
|
25
|
+
}
|
|
26
|
+
else if (state === 'conflicting') {
|
|
27
|
+
const path = ((typeof fs.name === 'string') ? fs.name : '');
|
|
28
|
+
throw (0, exceptions_1.makeFSSyncException)(path, {
|
|
29
|
+
conflict: true,
|
|
30
|
+
message: `Getting remote changes can't settle conflict in this function`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.getRemoteFolderChanges = getRemoteFolderChanges;
|
|
35
|
+
async function getOrMakeAndUploadFolderIn(fs, folder) {
|
|
36
|
+
try {
|
|
37
|
+
const childFolder = await fs.writableSubRoot(folder, { create: false });
|
|
38
|
+
return childFolder;
|
|
39
|
+
}
|
|
40
|
+
catch (exc) {
|
|
41
|
+
if ((exc.type === 'file')
|
|
42
|
+
&& exc.notFound) {
|
|
43
|
+
const childFolder = await fs.writableSubRoot(folder);
|
|
44
|
+
await fs.v.sync.upload(folder);
|
|
45
|
+
return childFolder;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw exc;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.getOrMakeAndUploadFolderIn = getOrMakeAndUploadFolderIn;
|
|
53
|
+
async function uploadFolderChangesIfAny(fs) {
|
|
54
|
+
const { state } = await fs.v.sync.updateStatusInfo('');
|
|
55
|
+
if ((state === 'synced') || (state === 'behind')) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
await fs.v.sync.upload('');
|
|
59
|
+
}
|
|
60
|
+
exports.uploadFolderChangesIfAny = uploadFolderChangesIfAny;
|
|
61
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare type ReadonlyFS = web3n.files.ReadonlyFS;
|
|
2
|
+
declare type WritableFS = web3n.files.WritableFS;
|
|
3
|
+
declare type WritableFile = web3n.files.WritableFile;
|
|
4
|
+
export interface FSReadView extends ReadonlyFS {
|
|
5
|
+
}
|
|
6
|
+
export interface FSWriteView extends WritableFS {
|
|
7
|
+
rollbackWrite(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare type FSWrite = FSReadView | FSWriteView;
|
|
10
|
+
export interface FileWriteView extends WritableFile {
|
|
11
|
+
rollbackWrite(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function readonlyFSView(fs: ReadonlyFS, state: any): Promise<FSReadView>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.readonlyFSView = void 0;
|
|
20
|
+
async function readonlyFSView(fs, state) {
|
|
21
|
+
// XXX
|
|
22
|
+
// Notes:
|
|
23
|
+
// - state info with objId->version can't expose objId to user here,
|
|
24
|
+
// keeping it on core's side.
|
|
25
|
+
// ! Hiding objId is incompatible with idea of having syncWall info
|
|
26
|
+
// accessible, if/when objId is used in it.
|
|
27
|
+
// - Map path->num-id-within-given-sync-wall
|
|
28
|
+
// - When anything is changed within FSWriteView, it is added to map,
|
|
29
|
+
// as being part of sync wall.
|
|
30
|
+
throw new Error('Function not implemented.');
|
|
31
|
+
}
|
|
32
|
+
exports.readonlyFSView = readonlyFSView;
|
|
33
|
+
Object.freeze(exports);
|
|
@@ -46,7 +46,7 @@ async function deriveMidKeyPair(cryptor, pass, derivParams, progressCB, use = ''
|
|
|
46
46
|
const saltBytes = buffer_utils_1.base64.open(derivParams.salt);
|
|
47
47
|
const skey = await cryptor.scrypt(passBytes, saltBytes, derivParams.logN, derivParams.r, derivParams.p, ecma_nacl_1.box.KEY_LENGTH, progressCB);
|
|
48
48
|
const pkey = await cryptor.box.generate_pubkey(skey);
|
|
49
|
-
const pkeyJSON = jwkeys_1.keyToJson({
|
|
49
|
+
const pkeyJSON = (0, jwkeys_1.keyToJson)({
|
|
50
50
|
k: pkey,
|
|
51
51
|
alg: ecma_nacl_1.box.JWK_ALG_NAME,
|
|
52
52
|
use: use,
|
|
@@ -29,9 +29,9 @@ class DevFileByteSink {
|
|
|
29
29
|
Object.seal(this);
|
|
30
30
|
}
|
|
31
31
|
static make(path, pathPrefixMaskLen, stat) {
|
|
32
|
-
assert_1.assert(Number.isInteger(stat.size) && (stat.size >= 0));
|
|
32
|
+
(0, assert_1.assert)(Number.isInteger(stat.size) && (stat.size >= 0));
|
|
33
33
|
const sink = new DevFileByteSink(path, pathPrefixMaskLen, stat.size);
|
|
34
|
-
return wrapping_1.wrapAndSyncFileSink(sink);
|
|
34
|
+
return (0, wrapping_1.wrapAndSyncFileSink)(sink);
|
|
35
35
|
}
|
|
36
36
|
async done() { }
|
|
37
37
|
async getSize() {
|
|
@@ -44,12 +44,12 @@ class DevFileByteSink {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
async truncate(size) {
|
|
47
|
-
assert_1.assert(Number.isInteger(size) && (size >= 0), `Invalid parameters given`);
|
|
47
|
+
(0, assert_1.assert)(Number.isInteger(size) && (size >= 0), `Invalid parameters given`);
|
|
48
48
|
await fs.truncate(this.path, size);
|
|
49
49
|
this.size = size;
|
|
50
50
|
}
|
|
51
51
|
async splice(pos, del, bytes) {
|
|
52
|
-
assert_1.assert(Number.isInteger(pos) && (pos >= 0)
|
|
52
|
+
(0, assert_1.assert)(Number.isInteger(pos) && (pos >= 0)
|
|
53
53
|
&& Number.isInteger(del) && (del >= 0), `Invalid parameters given`);
|
|
54
54
|
const ins = (bytes ? bytes.length : 0);
|
|
55
55
|
if ((del === 0) && (ins === 0)) {
|
|
@@ -74,10 +74,10 @@ class DevFileByteSink {
|
|
|
74
74
|
let fd = undefined;
|
|
75
75
|
try {
|
|
76
76
|
fd = await fs.open(this.path, 'r+');
|
|
77
|
-
await fs.writeFromBuf(fd, pos, buffer_utils_1.toBuffer(bytes));
|
|
77
|
+
await fs.writeFromBuf(fd, pos, (0, buffer_utils_1.toBuffer)(bytes));
|
|
78
78
|
}
|
|
79
79
|
catch (e) {
|
|
80
|
-
throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
|
|
80
|
+
throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
|
|
81
81
|
}
|
|
82
82
|
finally {
|
|
83
83
|
if (fd !== undefined) {
|
|
@@ -89,7 +89,7 @@ class DevFileByteSink {
|
|
|
89
89
|
if (delta === 0) {
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
assert_1.assert(Number.isInteger(pos) && (pos >= 0)
|
|
92
|
+
(0, assert_1.assert)(Number.isInteger(pos) && (pos >= 0)
|
|
93
93
|
&& Number.isInteger(delta) && Number.isInteger(initFileLen)
|
|
94
94
|
&& (pos <= initFileLen), `Invalid parameters given`);
|
|
95
95
|
if (delta > 0) {
|
|
@@ -120,7 +120,7 @@ class DevFileByteSink {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
catch (e) {
|
|
123
|
-
throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
|
|
123
|
+
throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
|
|
124
124
|
}
|
|
125
125
|
finally {
|
|
126
126
|
if (fd !== undefined) {
|
|
@@ -149,7 +149,7 @@ class DevFileByteSink {
|
|
|
149
149
|
await fs.ftruncate(fd, pos + bytesToMove);
|
|
150
150
|
}
|
|
151
151
|
catch (e) {
|
|
152
|
-
throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
|
|
152
|
+
throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
|
|
153
153
|
}
|
|
154
154
|
finally {
|
|
155
155
|
if (fd !== undefined) {
|
|
@@ -29,7 +29,7 @@ class DevFileByteSource {
|
|
|
29
29
|
}
|
|
30
30
|
static make(path, pathPrefixMaskLen, stat) {
|
|
31
31
|
const src = new DevFileByteSource(path, pathPrefixMaskLen, stat);
|
|
32
|
-
return wrapping_1.wrapAndSyncSource(src);
|
|
32
|
+
return (0, wrapping_1.wrapAndSyncSource)(src);
|
|
33
33
|
}
|
|
34
34
|
async getSize() {
|
|
35
35
|
return { size: this.size, isEndless: false };
|
|
@@ -54,7 +54,7 @@ class DevFileByteSource {
|
|
|
54
54
|
return buf;
|
|
55
55
|
}
|
|
56
56
|
catch (e) {
|
|
57
|
-
throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
|
|
57
|
+
throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
|
|
58
58
|
}
|
|
59
59
|
finally {
|
|
60
60
|
if (fd !== undefined) {
|
|
@@ -81,7 +81,7 @@ export declare class DeviceFS implements WritableFS, Linkable {
|
|
|
81
81
|
writableFile(path: string, flags?: web3n.files.FileFlags): Promise<WritableFile>;
|
|
82
82
|
watchFolder(path: string, observer: Observer<FolderEvent>): () => void;
|
|
83
83
|
watchFile(path: string, observer: Observer<FileEvent>): () => void;
|
|
84
|
-
watchTree(path: string, observer: Observer<FolderEvent | FileEvent>): () => void;
|
|
84
|
+
watchTree(path: string, depth: number | undefined, observer: Observer<FolderEvent | FileEvent>): () => void;
|
|
85
85
|
copyFile(src: string, dst: string, overwrite?: boolean): Promise<void>;
|
|
86
86
|
copyFolder(src: string, dst: string, mergeAndOverwrite?: boolean): Promise<void>;
|
|
87
87
|
saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;
|