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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2017, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2017, 2020, 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
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.StorageOwner = void 0;
|
|
19
20
|
/**
|
|
@@ -26,6 +27,7 @@ const service_locator_1 = require("../service-locator");
|
|
|
26
27
|
const keyGen = require("../key-derivation");
|
|
27
28
|
const exceptions_1 = require("./exceptions");
|
|
28
29
|
const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
|
|
30
|
+
const assert_1 = require("../../lib-common/assert");
|
|
29
31
|
class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
30
32
|
constructor(user, getSigner, mainUrlGetter, net) {
|
|
31
33
|
super(user, {
|
|
@@ -34,7 +36,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
34
36
|
canBeRedirected: true
|
|
35
37
|
}, getSigner, async () => {
|
|
36
38
|
const serviceUrl = await mainUrlGetter();
|
|
37
|
-
const info = await service_locator_1.storageInfoAt(this.net, serviceUrl);
|
|
39
|
+
const info = await (0, service_locator_1.storageInfoAt)(this.net, serviceUrl);
|
|
38
40
|
if (!info.owner) {
|
|
39
41
|
throw new Error(`Missing owner service url in 3NStorage information at ${serviceUrl}`);
|
|
40
42
|
}
|
|
@@ -50,11 +52,11 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
50
52
|
responseType: 'json'
|
|
51
53
|
});
|
|
52
54
|
if (rep.status !== api.sessionParams.SC.ok) {
|
|
53
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
55
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
54
56
|
}
|
|
55
57
|
const keyDerivParams = rep.data;
|
|
56
58
|
if (!keyGen.checkParams(rep.data)) {
|
|
57
|
-
throw request_utils_1.makeException(rep, 'Malformed response');
|
|
59
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed response');
|
|
58
60
|
}
|
|
59
61
|
return keyDerivParams;
|
|
60
62
|
}
|
|
@@ -65,11 +67,11 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
65
67
|
responseType: 'json'
|
|
66
68
|
});
|
|
67
69
|
if (rep.status !== api.sessionParams.SC.ok) {
|
|
68
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
70
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
69
71
|
}
|
|
70
72
|
if ((typeof rep.data.maxChunkSize !== 'number') ||
|
|
71
73
|
(rep.data.maxChunkSize < 64 * 1024)) {
|
|
72
|
-
throw request_utils_1.makeException(rep, 'Malformed response');
|
|
74
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed response');
|
|
73
75
|
}
|
|
74
76
|
this.maxChunkSize = rep.data.maxChunkSize;
|
|
75
77
|
}
|
|
@@ -97,10 +99,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
99
101
|
else if (rep.status === api.cancelTransaction.SC.missing) {
|
|
100
|
-
throw exceptions_1.makeUnknownTransactionExc(objId);
|
|
102
|
+
throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
|
|
101
103
|
}
|
|
102
104
|
else {
|
|
103
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
105
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
@@ -127,13 +129,13 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
127
129
|
});
|
|
128
130
|
if (rep.status === api.currentObj.SC.okGet) {
|
|
129
131
|
if (!(rep.data instanceof Uint8Array)) {
|
|
130
|
-
throw request_utils_1.makeException(rep, `Malformed response: body is not binary`);
|
|
132
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
|
|
131
133
|
}
|
|
132
|
-
const version = request_utils_1.extractIntHeader(rep, api.HTTP_HEADER.objVersion);
|
|
133
|
-
const segsTotalLen = request_utils_1.extractIntHeader(rep, api.HTTP_HEADER.objSegmentsLength);
|
|
134
|
-
const headerLen = request_utils_1.extractIntHeader(rep, api.HTTP_HEADER.objHeaderLength);
|
|
134
|
+
const version = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objVersion);
|
|
135
|
+
const segsTotalLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objSegmentsLength);
|
|
136
|
+
const headerLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objHeaderLength);
|
|
135
137
|
if (rep.data.length > (headerLen + segsTotalLen)) {
|
|
136
|
-
throw request_utils_1.makeException(rep, `Malformed response: body is too long`);
|
|
138
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed response: body is too long`);
|
|
137
139
|
}
|
|
138
140
|
return {
|
|
139
141
|
version, segsTotalLen,
|
|
@@ -142,10 +144,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
146
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
145
|
-
throw exceptions_1.makeObjNotFoundExc(objId);
|
|
147
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
146
148
|
}
|
|
147
149
|
else {
|
|
148
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
150
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
/**
|
|
@@ -172,15 +174,15 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
172
174
|
});
|
|
173
175
|
if (rep.status === api.currentObj.SC.okGet) {
|
|
174
176
|
if (!(rep.data instanceof Uint8Array)) {
|
|
175
|
-
throw request_utils_1.makeException(rep, `Malformed response: body is not binary`);
|
|
177
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
|
|
176
178
|
}
|
|
177
179
|
return rep.data;
|
|
178
180
|
}
|
|
179
181
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
180
|
-
throw exceptions_1.makeObjNotFoundExc(objId);
|
|
182
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
181
183
|
}
|
|
182
184
|
else {
|
|
183
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
185
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
184
186
|
}
|
|
185
187
|
}
|
|
186
188
|
/**
|
|
@@ -189,47 +191,117 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
189
191
|
* complete, or to a transaction id, which must be used for subsequent
|
|
190
192
|
* request(s).
|
|
191
193
|
* @param objId is object's id, with null value for root object
|
|
192
|
-
* @param bytes are bytes to upload
|
|
193
194
|
* @param fstReq is options object for the first request
|
|
194
195
|
* @param followReq is options object for subsequent request(s)
|
|
196
|
+
* @param bytes is an object with header, diff and segs bytes to upload
|
|
195
197
|
*/
|
|
196
|
-
async saveNewObjVersion(objId,
|
|
198
|
+
async saveNewObjVersion(objId, fstReq, followReq, { header, diff, segs }) {
|
|
197
199
|
let appPath;
|
|
198
200
|
if (fstReq) {
|
|
201
|
+
(0, assert_1.assert)(!!header);
|
|
202
|
+
const { create, ver, last } = fstReq;
|
|
203
|
+
const reqOpts = {
|
|
204
|
+
create, ver, last,
|
|
205
|
+
header: header.length,
|
|
206
|
+
diff: (diff ? diff.length : undefined)
|
|
207
|
+
};
|
|
199
208
|
appPath = (objId ?
|
|
200
|
-
api.currentObj.firstPutReqUrlEnd(objId,
|
|
201
|
-
api.currentRootObj.firstPutReqUrlEnd(
|
|
209
|
+
api.currentObj.firstPutReqUrlEnd(objId, reqOpts) :
|
|
210
|
+
api.currentRootObj.firstPutReqUrlEnd(reqOpts));
|
|
202
211
|
}
|
|
203
212
|
else if (followReq) {
|
|
213
|
+
const { ofs, trans, last } = followReq;
|
|
214
|
+
// XXX segs argument will introduce difference between these two
|
|
215
|
+
const reqOpts = {
|
|
216
|
+
ofs, trans, last
|
|
217
|
+
};
|
|
204
218
|
appPath = (objId ?
|
|
205
|
-
api.currentObj.secondPutReqUrlEnd(objId,
|
|
206
|
-
api.currentRootObj.secondPutReqUrlEnd(
|
|
219
|
+
api.currentObj.secondPutReqUrlEnd(objId, reqOpts) :
|
|
220
|
+
api.currentRootObj.secondPutReqUrlEnd(reqOpts));
|
|
207
221
|
}
|
|
208
222
|
else {
|
|
209
223
|
throw new Error(`Missing request options`);
|
|
210
224
|
}
|
|
225
|
+
// ordering body bytes in accordance with protocol expectation
|
|
226
|
+
const bytes = [];
|
|
227
|
+
if (diff) {
|
|
228
|
+
bytes.push(diff);
|
|
229
|
+
}
|
|
230
|
+
if (header) {
|
|
231
|
+
bytes.push(header);
|
|
232
|
+
}
|
|
233
|
+
if (segs) {
|
|
234
|
+
if (Array.isArray(segs)) {
|
|
235
|
+
bytes.push(...segs);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
bytes.push(segs);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
211
241
|
const rep = await this.doBinarySessionRequest({ appPath, method: 'PUT', responseType: 'json' }, bytes);
|
|
212
242
|
if (rep.status === api.currentObj.SC.okPut) {
|
|
213
243
|
return rep.data.transactionId;
|
|
214
244
|
}
|
|
245
|
+
else if (rep.status === api.currentObj.SC.objAlreadyExists) {
|
|
246
|
+
throw (0, exceptions_1.makeObjExistsExc)(objId, undefined, true);
|
|
247
|
+
}
|
|
215
248
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
216
|
-
throw exceptions_1.makeObjNotFoundExc(objId);
|
|
249
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
217
250
|
}
|
|
218
251
|
else if (rep.status === api.currentObj.SC.concurrentTransaction) {
|
|
219
|
-
throw exceptions_1.makeConcurrentTransExc(objId);
|
|
252
|
+
throw (0, exceptions_1.makeConcurrentTransExc)(objId);
|
|
220
253
|
}
|
|
221
254
|
else if (rep.status === api.currentObj.SC.unknownTransaction) {
|
|
222
|
-
throw exceptions_1.makeUnknownTransactionExc(objId);
|
|
255
|
+
throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
|
|
223
256
|
}
|
|
224
257
|
else if (rep.status === api.currentObj.SC.mismatchedObjVer) {
|
|
225
258
|
const curVer = rep.current_version;
|
|
226
259
|
if (!Number.isInteger(curVer)) {
|
|
227
260
|
throw new Error(`Got non-integer current object version value from a version mismatch reply ${curVer}`);
|
|
228
261
|
}
|
|
229
|
-
throw exceptions_1.makeVersionMismatchExc(objId, curVer);
|
|
262
|
+
throw (0, exceptions_1.makeVersionMismatchExc)(objId, curVer);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async archiveObjVersion(objId, currentVer) {
|
|
269
|
+
const rep = await this.doBodylessSessionRequest({
|
|
270
|
+
appPath: (objId ?
|
|
271
|
+
api.archiveObj.postAndDelReqUrlEnd(objId, currentVer) :
|
|
272
|
+
api.archiveRoot.postAndDelReqUrlEnd(currentVer)),
|
|
273
|
+
method: 'POST'
|
|
274
|
+
});
|
|
275
|
+
if (rep.status === api.archiveObj.SC.okPost) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
279
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
280
|
+
}
|
|
281
|
+
else if (rep.status === api.currentObj.SC.unknownObjVer) {
|
|
282
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, currentVer, true);
|
|
230
283
|
}
|
|
231
284
|
else {
|
|
232
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
285
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async getObjStatus(objId) {
|
|
289
|
+
const rep = await this.doBodylessSessionRequest({
|
|
290
|
+
appPath: (objId ?
|
|
291
|
+
api.objStatus.getReqUrlEnd(objId) :
|
|
292
|
+
api.rootStatus.getReqUrlEnd()),
|
|
293
|
+
method: 'GET',
|
|
294
|
+
responseType: 'json'
|
|
295
|
+
});
|
|
296
|
+
if (rep.status === api.objStatus.SC.ok) {
|
|
297
|
+
// XXX we may want to add sanity check(s)
|
|
298
|
+
return rep.data;
|
|
299
|
+
}
|
|
300
|
+
else if (rep.status === api.objStatus.SC.unknownObj) {
|
|
301
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
233
305
|
}
|
|
234
306
|
}
|
|
235
307
|
/**
|
|
@@ -241,29 +313,27 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
241
313
|
*/
|
|
242
314
|
async deleteObj(objId) {
|
|
243
315
|
const rep = await this.doBodylessSessionRequest({
|
|
244
|
-
appPath: api.currentObj.
|
|
316
|
+
appPath: api.currentObj.delReqUrlEnd(objId),
|
|
245
317
|
method: 'DELETE'
|
|
246
318
|
});
|
|
247
|
-
if (rep.status === api.currentObj.SC.okDelete)
|
|
319
|
+
if ((rep.status === api.currentObj.SC.okDelete)
|
|
320
|
+
|| (rep.status === api.currentObj.SC.unknownObj)) {
|
|
248
321
|
return;
|
|
249
322
|
}
|
|
250
323
|
else if (rep.status === api.currentObj.SC.concurrentTransaction) {
|
|
251
|
-
throw exceptions_1.makeConcurrentTransExc(objId);
|
|
252
|
-
}
|
|
253
|
-
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
254
|
-
throw exceptions_1.makeObjNotFoundExc(objId);
|
|
324
|
+
throw (0, exceptions_1.makeConcurrentTransExc)(objId);
|
|
255
325
|
}
|
|
256
326
|
else {
|
|
257
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
327
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
258
328
|
}
|
|
259
329
|
}
|
|
260
330
|
async openEventSource() {
|
|
261
331
|
const rep = await this.openWS(api.wsEventChannel.URL_END);
|
|
262
332
|
if (rep.status === api.wsEventChannel.SC.ok) {
|
|
263
|
-
return ws_ipc_1.makeSubscriber(rep.data, undefined);
|
|
333
|
+
return (0, ws_ipc_1.makeSubscriber)(rep.data, undefined);
|
|
264
334
|
}
|
|
265
335
|
else {
|
|
266
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
336
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
267
337
|
}
|
|
268
338
|
}
|
|
269
339
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
declare type WritableFile = web3n.files.WritableFile;
|
|
2
2
|
declare type FileEvent = web3n.files.FileEvent;
|
|
3
|
+
declare type RemoteEvent = web3n.files.RemoteEvent;
|
|
3
4
|
export declare abstract class JsonFileProc<T> {
|
|
4
5
|
private proc;
|
|
5
6
|
private file;
|
|
6
7
|
start(file: WritableFile, initVal: T | (() => T) | (() => Promise<T>)): Promise<void>;
|
|
7
|
-
protected abstract onFileEvent(ev: FileEvent): Promise<void>;
|
|
8
|
+
protected abstract onFileEvent(ev: FileEvent | RemoteEvent): Promise<void>;
|
|
8
9
|
close(): Promise<void>;
|
|
9
10
|
private ensureActive;
|
|
10
11
|
/**
|
|
@@ -38,7 +38,7 @@ class JsonFileProc {
|
|
|
38
38
|
await this.file.writeJSON(fstVal);
|
|
39
39
|
}
|
|
40
40
|
this.proc = (new rxjs_1.Observable(obs => this.file.watch(obs)))
|
|
41
|
-
.pipe(operators_1.mergeMap(ev => this.onFileEvent(ev), 1))
|
|
41
|
+
.pipe((0, operators_1.mergeMap)(ev => this.onFileEvent(ev), 1))
|
|
42
42
|
.subscribe();
|
|
43
43
|
}
|
|
44
44
|
async close() {
|
|
@@ -37,14 +37,14 @@ class CommonAttrs {
|
|
|
37
37
|
if (bytes.length < CommonAttrs.PACK_LEN) {
|
|
38
38
|
throw parsingException(`byte array is too short`);
|
|
39
39
|
}
|
|
40
|
-
const ctime = big_endian_1.uintFrom6Bytes(bytes, 0);
|
|
41
|
-
const mtime = big_endian_1.uintFrom6Bytes(bytes, 6);
|
|
40
|
+
const ctime = (0, big_endian_1.uintFrom6Bytes)(bytes, 0);
|
|
41
|
+
const mtime = (0, big_endian_1.uintFrom6Bytes)(bytes, 6);
|
|
42
42
|
return new CommonAttrs(ctime, mtime);
|
|
43
43
|
}
|
|
44
44
|
pack() {
|
|
45
45
|
const bytes = Buffer.allocUnsafe(CommonAttrs.PACK_LEN);
|
|
46
|
-
big_endian_1.packUintTo6Bytes(this.ctime, bytes, 0);
|
|
47
|
-
big_endian_1.packUintTo6Bytes(this.mtime, bytes, 6);
|
|
46
|
+
(0, big_endian_1.packUintTo6Bytes)(this.ctime, bytes, 0);
|
|
47
|
+
(0, big_endian_1.packUintTo6Bytes)(this.mtime, bytes, 6);
|
|
48
48
|
return bytes;
|
|
49
49
|
}
|
|
50
50
|
copy() {
|
|
@@ -71,7 +71,7 @@ class XAttrs {
|
|
|
71
71
|
for (const bytes of sections) {
|
|
72
72
|
let i = 0;
|
|
73
73
|
while (i < bytes.length) {
|
|
74
|
-
const { bytesRead, binVal, strVal, jsonVal, xaName } = extAttrs.readNamedAttr(buffer_utils_1.toBuffer(bytes), i);
|
|
74
|
+
const { bytesRead, binVal, strVal, jsonVal, xaName } = extAttrs.readNamedAttr((0, buffer_utils_1.toBuffer)(bytes), i);
|
|
75
75
|
xattrs.attrs.set(xaName, { binVal, strVal, jsonVal });
|
|
76
76
|
i += bytesRead;
|
|
77
77
|
}
|
|
@@ -141,7 +141,7 @@ class XAttrs {
|
|
|
141
141
|
bytes.push(extAttrs.packNamedBinaryAttr(xaName, v.binVal));
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
144
|
-
assert_1.assert(v.jsonVal !== undefined);
|
|
144
|
+
(0, assert_1.assert)(v.jsonVal !== undefined);
|
|
145
145
|
bytes.push(extAttrs.packNamedJsonAttr(xaName, v.jsonVal));
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -179,7 +179,7 @@ var extAttrs;
|
|
|
179
179
|
else if (t.type === NAMED_JSON) {
|
|
180
180
|
return {
|
|
181
181
|
bytesRead, xaName,
|
|
182
|
-
jsonVal: JSON.parse(buffer_utils_1.toBuffer(bytes).slice(ofs, ofs + contentLen).toString('utf8')),
|
|
182
|
+
jsonVal: JSON.parse((0, buffer_utils_1.toBuffer)(bytes).slice(ofs, ofs + contentLen).toString('utf8')),
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
else if (t.type === NAMED_BINARY) {
|
|
@@ -208,17 +208,17 @@ var extAttrs;
|
|
|
208
208
|
case 1:
|
|
209
209
|
return bytes[i];
|
|
210
210
|
case 2:
|
|
211
|
-
return big_endian_1.uintFrom2Bytes(bytes, i);
|
|
211
|
+
return (0, big_endian_1.uintFrom2Bytes)(bytes, i);
|
|
212
212
|
case 3:
|
|
213
|
-
return big_endian_1.uintFrom3Bytes(bytes, i);
|
|
213
|
+
return (0, big_endian_1.uintFrom3Bytes)(bytes, i);
|
|
214
214
|
case 4:
|
|
215
|
-
return big_endian_1.uintFrom4Bytes(bytes, i);
|
|
215
|
+
return (0, big_endian_1.uintFrom4Bytes)(bytes, i);
|
|
216
216
|
default:
|
|
217
217
|
throw parsingException(`Too many bytes for xattr length`);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
function packNamedStrAttr(name, value) {
|
|
221
|
-
assert_1.assert((typeof name === 'string') && (name.length > 0) &&
|
|
221
|
+
(0, assert_1.assert)((typeof name === 'string') && (name.length > 0) &&
|
|
222
222
|
(typeof value === 'string') && (value.length > 0));
|
|
223
223
|
const nameBin = Buffer.from(name, 'utf8');
|
|
224
224
|
const valueBin = Buffer.from(value, 'utf8');
|
|
@@ -226,14 +226,14 @@ var extAttrs;
|
|
|
226
226
|
}
|
|
227
227
|
extAttrs.packNamedStrAttr = packNamedStrAttr;
|
|
228
228
|
function packNamedBinaryAttr(name, value) {
|
|
229
|
-
assert_1.assert((typeof name === 'string') && (name.length > 0) &&
|
|
229
|
+
(0, assert_1.assert)((typeof name === 'string') && (name.length > 0) &&
|
|
230
230
|
(value.length > 0));
|
|
231
231
|
const nameBin = Buffer.from(name, 'utf8');
|
|
232
232
|
return packNamedAttr(NAMED_BINARY, nameBin, value);
|
|
233
233
|
}
|
|
234
234
|
extAttrs.packNamedBinaryAttr = packNamedBinaryAttr;
|
|
235
235
|
function packNamedJsonAttr(name, value) {
|
|
236
|
-
assert_1.assert((typeof name === 'string') && (name.length > 0) &&
|
|
236
|
+
(0, assert_1.assert)((typeof name === 'string') && (name.length > 0) &&
|
|
237
237
|
(value !== undefined));
|
|
238
238
|
const nameBin = Buffer.from(name, 'utf8');
|
|
239
239
|
const valueBin = Buffer.from(JSON.stringify(value), 'utf8');
|
|
@@ -292,16 +292,16 @@ var extAttrs;
|
|
|
292
292
|
b[i] = u;
|
|
293
293
|
break;
|
|
294
294
|
case 2:
|
|
295
|
-
big_endian_1.packUintTo2Bytes(u, b, i);
|
|
295
|
+
(0, big_endian_1.packUintTo2Bytes)(u, b, i);
|
|
296
296
|
break;
|
|
297
297
|
case 3:
|
|
298
|
-
big_endian_1.packUintTo3Bytes(u, b, i);
|
|
298
|
+
(0, big_endian_1.packUintTo3Bytes)(u, b, i);
|
|
299
299
|
break;
|
|
300
300
|
case 4:
|
|
301
|
-
big_endian_1.packUintTo4Bytes(u, b, i);
|
|
301
|
+
(0, big_endian_1.packUintTo4Bytes)(u, b, i);
|
|
302
302
|
break;
|
|
303
303
|
default:
|
|
304
|
-
assert_1.assert(false);
|
|
304
|
+
(0, assert_1.assert)(false);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
// export function pack(xattrs: XAttrs): Buffer {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { ScryptGenParams } from '../../key-derivation';
|
|
2
2
|
import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
|
|
3
|
-
import {
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
4
|
export { AsyncSBoxCryptor } from 'xsp-files';
|
|
5
5
|
export { FolderInJSON } from './folder-node';
|
|
6
6
|
declare type StorageType = web3n.files.FSType;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
declare type FolderEvent = web3n.files.FolderEvent;
|
|
8
|
+
declare type FileEvent = web3n.files.FileEvent;
|
|
9
|
+
declare type RemoteEvent = web3n.files.RemoteEvent;
|
|
10
|
+
declare type SyncStatus = web3n.files.SyncStatus;
|
|
11
|
+
declare type OptionsToAdopteRemote = web3n.files.OptionsToAdopteRemote;
|
|
12
|
+
declare type FSSyncException = web3n.files.FSSyncException;
|
|
13
|
+
declare type FileException = web3n.files.FileException;
|
|
14
|
+
export declare type FSChangeSrc = web3n.files.FSChangeEvent['src'];
|
|
14
15
|
export interface Node {
|
|
15
16
|
objId: string;
|
|
16
17
|
name: string;
|
|
17
18
|
type: NodeType;
|
|
18
|
-
|
|
19
|
-
localDelete(): Promise<void>;
|
|
19
|
+
removeObj(src?: FSChangeSrc): Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
export declare type NodeType = 'file' | 'link' | 'folder';
|
|
22
22
|
export declare type ObjId = string | null;
|
|
@@ -47,11 +47,19 @@ export declare class NodesContainer {
|
|
|
47
47
|
reserveId(objId: string): boolean;
|
|
48
48
|
clear(): void;
|
|
49
49
|
}
|
|
50
|
+
export interface NodeEvent {
|
|
51
|
+
objId: ObjId;
|
|
52
|
+
parentObjId?: ObjId;
|
|
53
|
+
childObjId?: ObjId;
|
|
54
|
+
event: FolderEvent | FileEvent | RemoteEvent;
|
|
55
|
+
}
|
|
50
56
|
export interface Storage {
|
|
51
57
|
readonly type: StorageType;
|
|
52
58
|
readonly versioned: boolean;
|
|
53
59
|
readonly cryptor: AsyncSBoxCryptor;
|
|
54
60
|
readonly nodes: NodesContainer;
|
|
61
|
+
getNodeEvents(): Observable<NodeEvent>;
|
|
62
|
+
broadcastNodeEvent(objId: ObjId, parentObjId: ObjId | undefined, childObjId: ObjId | undefined, ev: NodeEvent['event']): void;
|
|
55
63
|
/**
|
|
56
64
|
* This returns a storage of another type, for use by link functionality.
|
|
57
65
|
* @param type is a type of a requested storage.
|
|
@@ -66,33 +74,63 @@ export interface Storage {
|
|
|
66
74
|
/**
|
|
67
75
|
* This returns a promise, resolvable to source for a requested object.
|
|
68
76
|
* @param objId
|
|
77
|
+
* @param version
|
|
69
78
|
*/
|
|
70
|
-
|
|
79
|
+
getObjSrc(objId: ObjId, version?: number): Promise<ObjSource>;
|
|
71
80
|
/**
|
|
72
81
|
* This saves given object, asynchronously.
|
|
73
82
|
* @param objId
|
|
74
83
|
* @param version
|
|
75
84
|
* @param sinkSub is a sink subscribe function
|
|
76
85
|
*/
|
|
77
|
-
saveObj(objId:
|
|
86
|
+
saveObj(objId: ObjId, version: number, sinkSub: Subscribe): Promise<void>;
|
|
78
87
|
/**
|
|
79
88
|
* This asynchronously removes an object. Note that it does not remove
|
|
80
89
|
* archived version, only current one.
|
|
81
90
|
* @param objId
|
|
82
91
|
*/
|
|
83
|
-
removeObj(objId:
|
|
92
|
+
removeObj(objId: ObjId): Promise<void>;
|
|
84
93
|
/**
|
|
85
94
|
* This asynchronously runs closing cleanup.
|
|
86
95
|
*/
|
|
87
96
|
close(): Promise<void>;
|
|
97
|
+
status(objId: ObjId): Promise<LocalObjStatus>;
|
|
98
|
+
}
|
|
99
|
+
export interface LocalObjStatus {
|
|
100
|
+
archiveCurrentVersion(): Promise<void>;
|
|
101
|
+
listVersions(): {
|
|
102
|
+
current?: number;
|
|
103
|
+
archived?: number[];
|
|
104
|
+
};
|
|
88
105
|
}
|
|
89
106
|
export declare function wrapStorageImplementation(impl: Storage): Storage;
|
|
90
107
|
export declare type StorageGetter = (type: StorageType, location?: string) => Storage;
|
|
91
108
|
export interface SyncedStorage extends Storage {
|
|
109
|
+
getObjSrcOfRemoteVersion(objId: ObjId, version: number): Promise<ObjSource>;
|
|
110
|
+
archiveVersionOnServer(objId: ObjId, version: number): Promise<void>;
|
|
92
111
|
/**
|
|
93
112
|
* This returns a promise, resolvable to root key generation parameters.
|
|
94
113
|
*/
|
|
95
114
|
getRootKeyDerivParamsFromServer(): Promise<ScryptGenParams>;
|
|
96
|
-
|
|
115
|
+
adoptRemote(objId: ObjId, opts: OptionsToAdopteRemote | undefined): Promise<number | undefined>;
|
|
116
|
+
updateStatusInfo(objId: ObjId): Promise<SyncStatus>;
|
|
117
|
+
isRemoteVersionOnDisk(objId: ObjId, version: number): Promise<'partial' | 'complete' | 'none'>;
|
|
118
|
+
download(objId: ObjId, version: number): Promise<void>;
|
|
119
|
+
upload(objId: ObjId, localVersion: number, uploadVersion: number, uploadHeader: UploadHeaderChange | undefined, createOnRemote: boolean): Promise<void>;
|
|
120
|
+
dropCachedLocalObjVersionsLessOrEqual(objId: ObjId, localVersion: number): void;
|
|
121
|
+
uploadObjRemoval(objId: ObjId): Promise<void>;
|
|
122
|
+
status(objId: ObjId): Promise<SyncedObjStatus>;
|
|
123
|
+
}
|
|
124
|
+
export interface SyncedObjStatus extends LocalObjStatus {
|
|
125
|
+
syncStatus(): SyncStatus;
|
|
126
|
+
neverUploaded(): boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface UploadHeaderChange {
|
|
129
|
+
localVersion: number;
|
|
130
|
+
uploadVersion: number;
|
|
131
|
+
localHeader: Uint8Array;
|
|
132
|
+
uploadHeader: Uint8Array;
|
|
97
133
|
}
|
|
98
134
|
export declare function wrapSyncStorageImplementation(impl: SyncedStorage): SyncedStorage;
|
|
135
|
+
export declare function isSyncedStorage(storage: Storage): boolean;
|
|
136
|
+
export declare function setPathInExc(exc: FSSyncException | FileException, path: string): FSSyncException | FileException;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.wrapSyncStorageImplementation = exports.wrapStorageImplementation = exports.NodesContainer = void 0;
|
|
19
|
+
exports.setPathInExc = exports.isSyncedStorage = exports.wrapSyncStorageImplementation = exports.wrapStorageImplementation = exports.NodesContainer = void 0;
|
|
20
20
|
/**
|
|
21
21
|
* This is a container for file system nodes.
|
|
22
22
|
*
|
|
@@ -98,12 +98,15 @@ function wrapStorageImplementation(impl) {
|
|
|
98
98
|
type: impl.type,
|
|
99
99
|
versioned: impl.versioned,
|
|
100
100
|
nodes: impl.nodes,
|
|
101
|
+
getNodeEvents: impl.getNodeEvents.bind(impl),
|
|
102
|
+
broadcastNodeEvent: impl.broadcastNodeEvent.bind(impl),
|
|
101
103
|
storageForLinking: impl.storageForLinking.bind(impl),
|
|
102
104
|
generateNewObjId: impl.generateNewObjId.bind(impl),
|
|
103
|
-
|
|
105
|
+
getObjSrc: impl.getObjSrc.bind(impl),
|
|
104
106
|
saveObj: impl.saveObj.bind(impl),
|
|
105
107
|
close: impl.close.bind(impl),
|
|
106
108
|
removeObj: impl.removeObj.bind(impl),
|
|
109
|
+
status: impl.status.bind(impl),
|
|
107
110
|
cryptor: impl.cryptor
|
|
108
111
|
};
|
|
109
112
|
return Object.freeze(wrap);
|
|
@@ -111,21 +114,33 @@ function wrapStorageImplementation(impl) {
|
|
|
111
114
|
exports.wrapStorageImplementation = wrapStorageImplementation;
|
|
112
115
|
function wrapSyncStorageImplementation(impl) {
|
|
113
116
|
const storageWrap = wrapStorageImplementation(impl);
|
|
114
|
-
const wrap = {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
117
|
+
const wrap = {};
|
|
118
|
+
for (const [field, value] of Object.entries(storageWrap)) {
|
|
119
|
+
wrap[field] = value;
|
|
120
|
+
}
|
|
121
|
+
wrap.getRootKeyDerivParamsFromServer =
|
|
122
|
+
impl.getRootKeyDerivParamsFromServer.bind(impl);
|
|
123
|
+
wrap.getObjSrcOfRemoteVersion = impl.getObjSrcOfRemoteVersion.bind(impl);
|
|
124
|
+
wrap.archiveVersionOnServer = impl.archiveVersionOnServer.bind(impl);
|
|
125
|
+
wrap.isRemoteVersionOnDisk = impl.isRemoteVersionOnDisk.bind(impl);
|
|
126
|
+
wrap.download = impl.download.bind(impl);
|
|
127
|
+
wrap.upload = impl.upload.bind(impl);
|
|
128
|
+
wrap.uploadObjRemoval = impl.uploadObjRemoval.bind(impl);
|
|
129
|
+
wrap.dropCachedLocalObjVersionsLessOrEqual = impl.dropCachedLocalObjVersionsLessOrEqual.bind(impl);
|
|
130
|
+
wrap.adoptRemote = impl.adoptRemote.bind(impl);
|
|
131
|
+
wrap.updateStatusInfo = impl.updateStatusInfo.bind(impl);
|
|
128
132
|
return Object.freeze(wrap);
|
|
129
133
|
}
|
|
130
134
|
exports.wrapSyncStorageImplementation = wrapSyncStorageImplementation;
|
|
135
|
+
function isSyncedStorage(storage) {
|
|
136
|
+
return !!storage.upload;
|
|
137
|
+
}
|
|
138
|
+
exports.isSyncedStorage = isSyncedStorage;
|
|
139
|
+
function setPathInExc(exc, path) {
|
|
140
|
+
if ((exc.type === 'fs-sync') || (exc.type === 'file')) {
|
|
141
|
+
exc.path = path;
|
|
142
|
+
}
|
|
143
|
+
return exc;
|
|
144
|
+
}
|
|
145
|
+
exports.setPathInExc = setPathInExc;
|
|
131
146
|
Object.freeze(exports);
|
|
@@ -45,6 +45,7 @@ export declare class FileNode extends NodeInFS<FilePersistance> {
|
|
|
45
45
|
static makeForExisting(storage: Storage, parentId: string, fileName: string, objId: string, key: Uint8Array): Promise<FileNode>;
|
|
46
46
|
static makeFromLinkParams(storage: Storage, params: FileLinkParams): Promise<FileNode>;
|
|
47
47
|
private static initWithAttrs;
|
|
48
|
+
protected setCurrentStateFrom(src: ObjSource): Promise<void>;
|
|
48
49
|
private setUpdatedState;
|
|
49
50
|
get size(): number;
|
|
50
51
|
readSrc(): Promise<{
|