core-3nweb-client-lib 0.26.1 → 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/build/api-defs/asmail.d.ts +1 -1
- package/build/api-defs/files.d.ts +278 -69
- package/build/core/app-files.js +7 -7
- package/build/core/asmail/config/common.js +2 -2
- 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 +5 -5
- package/build/core/asmail/delivery/msg.js +4 -4
- package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
- package/build/core/asmail/inbox/attachments/fs.js +5 -1
- package/build/core/asmail/inbox/cached-msgs.js +1 -1
- package/build/core/asmail/inbox/inbox-events.js +4 -4
- package/build/core/asmail/inbox/index.js +10 -10
- package/build/core/asmail/inbox/msg-downloader.js +1 -1
- package/build/core/asmail/inbox/msg-indexing.js +1 -1
- package/build/core/asmail/inbox/msg-on-disk.js +5 -5
- 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 +2 -1
- 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 +2 -2
- package/build/core/asmail/sending-params/params-from-others.js +1 -1
- package/build/core/id-manager.js +6 -3
- package/build/core/index.d.ts +2 -1
- package/build/core/index.js +14 -14
- package/build/core/sign-in.js +5 -5
- package/build/core/sign-up.js +9 -9
- package/build/core/storage/common/json-saving.js +2 -2
- package/build/core/storage/common/obj-info-file.d.ts +12 -4
- package/build/core/storage/common/obj-info-file.js +66 -34
- 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 +56 -76
- package/build/core/storage/local/obj-files-gc.d.ts +2 -0
- package/build/core/storage/local/obj-files-gc.js +49 -37
- package/build/core/storage/local/obj-files.d.ts +4 -7
- package/build/core/storage/local/obj-files.js +7 -10
- package/build/core/storage/local/obj-status.d.ts +12 -6
- package/build/core/storage/local/obj-status.js +24 -9
- package/build/core/storage/local/storage.d.ts +9 -6
- package/build/core/storage/local/storage.js +29 -18
- package/build/core/storage/synced/downloader.js +1 -1
- package/build/core/storage/synced/obj-files-gc.d.ts +5 -1
- package/build/core/storage/synced/obj-files-gc.js +91 -37
- package/build/core/storage/synced/obj-files.d.ts +42 -36
- package/build/core/storage/synced/obj-files.js +178 -147
- package/build/core/storage/synced/obj-status.d.ts +87 -85
- package/build/core/storage/synced/obj-status.js +463 -259
- package/build/core/storage/synced/remote-events.d.ts +11 -12
- package/build/core/storage/synced/remote-events.js +73 -56
- package/build/core/storage/synced/storage.d.ts +18 -9
- package/build/core/storage/synced/storage.js +108 -48
- 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 +12 -7
- package/build/core/storage/synced/upsyncer.js +205 -280
- 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 +58 -57
- package/build/ipc-via-protobuf/bytes.js +16 -17
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +1 -0
- package/build/ipc-via-protobuf/connector-clients-side.js +14 -15
- 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 +474 -126
- package/build/ipc-via-protobuf/fs.d.ts +8 -0
- package/build/ipc-via-protobuf/fs.js +577 -142
- 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 +21 -21
- package/build/ipc-via-protobuf/storage-cap.js +12 -12
- package/build/ipc.js +7 -2
- package/build/lib-client/3nstorage/exceptions.d.ts +3 -0
- package/build/lib-client/3nstorage/exceptions.js +13 -1
- package/build/lib-client/3nstorage/service.d.ts +16 -2
- package/build/lib-client/3nstorage/service.js +104 -38
- 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 +42 -18
- package/build/lib-client/3nstorage/xsp-fs/common.js +29 -19
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +17 -13
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
- package/build/lib-client/3nstorage/xsp-fs/file.js +73 -25
- 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 +575 -179
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +231 -110
- 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 -24
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +229 -123
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +17 -18
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -3
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +53 -53
- 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 +18 -16
- 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 +6 -6
- 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 -6
- package/build/lib-client/fs-collection.js +1 -1
- 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 +7 -7
- 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 +3 -3
- package/build/lib-client/objs-on-disk/obj-folders.js +31 -31
- 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 +13 -13
- package/build/lib-client/server-events.d.ts +3 -3
- package/build/lib-client/server-events.js +9 -8
- 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 +2 -2
- 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 +16 -16
- package/build/lib-common/byte-streaming/pipe.js +1 -1
- package/build/lib-common/byte-streaming/wrapping.js +13 -13
- 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 +4 -0
- package/build/lib-common/ipc/ws-ipc.js +2 -2
- 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 +96 -35
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/utils.js +3 -3
- package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
- package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
- package/build/lib-common/processes/labelled-exec-pools.js +1 -1
- package/build/lib-common/processes/pressure.js +2 -2
- package/build/lib-common/processes/synced.js +1 -1
- package/build/lib-common/processes/timeout.js +2 -2
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +95 -35
- package/build/lib-common/service-api/3nstorage/owner.js +82 -40
- 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.js +4 -4
- 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 +12955 -7496
- package/build/protos/file.proto.js +4867 -2744
- package/build/protos/fs.proto.js +9227 -3768
- package/package.json +6 -5
- package/protos/file.proto +91 -19
- package/protos/fs.proto +107 -8
|
@@ -27,6 +27,7 @@ const service_locator_1 = require("../service-locator");
|
|
|
27
27
|
const keyGen = require("../key-derivation");
|
|
28
28
|
const exceptions_1 = require("./exceptions");
|
|
29
29
|
const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
|
|
30
|
+
const assert_1 = require("../../lib-common/assert");
|
|
30
31
|
class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
31
32
|
constructor(user, getSigner, mainUrlGetter, net) {
|
|
32
33
|
super(user, {
|
|
@@ -35,7 +36,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
35
36
|
canBeRedirected: true
|
|
36
37
|
}, getSigner, async () => {
|
|
37
38
|
const serviceUrl = await mainUrlGetter();
|
|
38
|
-
const info = await service_locator_1.storageInfoAt(this.net, serviceUrl);
|
|
39
|
+
const info = await (0, service_locator_1.storageInfoAt)(this.net, serviceUrl);
|
|
39
40
|
if (!info.owner) {
|
|
40
41
|
throw new Error(`Missing owner service url in 3NStorage information at ${serviceUrl}`);
|
|
41
42
|
}
|
|
@@ -51,11 +52,11 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
51
52
|
responseType: 'json'
|
|
52
53
|
});
|
|
53
54
|
if (rep.status !== api.sessionParams.SC.ok) {
|
|
54
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
55
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
55
56
|
}
|
|
56
57
|
const keyDerivParams = rep.data;
|
|
57
58
|
if (!keyGen.checkParams(rep.data)) {
|
|
58
|
-
throw request_utils_1.makeException(rep, 'Malformed response');
|
|
59
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed response');
|
|
59
60
|
}
|
|
60
61
|
return keyDerivParams;
|
|
61
62
|
}
|
|
@@ -66,11 +67,11 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
66
67
|
responseType: 'json'
|
|
67
68
|
});
|
|
68
69
|
if (rep.status !== api.sessionParams.SC.ok) {
|
|
69
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
70
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
70
71
|
}
|
|
71
72
|
if ((typeof rep.data.maxChunkSize !== 'number') ||
|
|
72
73
|
(rep.data.maxChunkSize < 64 * 1024)) {
|
|
73
|
-
throw request_utils_1.makeException(rep, 'Malformed response');
|
|
74
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed response');
|
|
74
75
|
}
|
|
75
76
|
this.maxChunkSize = rep.data.maxChunkSize;
|
|
76
77
|
}
|
|
@@ -98,10 +99,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
101
|
else if (rep.status === api.cancelTransaction.SC.missing) {
|
|
101
|
-
throw exceptions_1.makeUnknownTransactionExc(objId);
|
|
102
|
+
throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
|
|
102
103
|
}
|
|
103
104
|
else {
|
|
104
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
105
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
@@ -128,13 +129,13 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
128
129
|
});
|
|
129
130
|
if (rep.status === api.currentObj.SC.okGet) {
|
|
130
131
|
if (!(rep.data instanceof Uint8Array)) {
|
|
131
|
-
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`);
|
|
132
133
|
}
|
|
133
|
-
const version = request_utils_1.extractIntHeader(rep, api.HTTP_HEADER.objVersion);
|
|
134
|
-
const segsTotalLen = request_utils_1.extractIntHeader(rep, api.HTTP_HEADER.objSegmentsLength);
|
|
135
|
-
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);
|
|
136
137
|
if (rep.data.length > (headerLen + segsTotalLen)) {
|
|
137
|
-
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`);
|
|
138
139
|
}
|
|
139
140
|
return {
|
|
140
141
|
version, segsTotalLen,
|
|
@@ -143,10 +144,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
146
|
-
throw exceptions_1.makeObjNotFoundExc(objId, undefined, true);
|
|
147
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
147
148
|
}
|
|
148
149
|
else {
|
|
149
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
150
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
/**
|
|
@@ -173,15 +174,15 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
173
174
|
});
|
|
174
175
|
if (rep.status === api.currentObj.SC.okGet) {
|
|
175
176
|
if (!(rep.data instanceof Uint8Array)) {
|
|
176
|
-
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`);
|
|
177
178
|
}
|
|
178
179
|
return rep.data;
|
|
179
180
|
}
|
|
180
181
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
181
|
-
throw exceptions_1.makeObjNotFoundExc(objId, undefined, true);
|
|
182
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
182
183
|
}
|
|
183
184
|
else {
|
|
184
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
185
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
188
|
/**
|
|
@@ -190,50 +191,117 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
190
191
|
* complete, or to a transaction id, which must be used for subsequent
|
|
191
192
|
* request(s).
|
|
192
193
|
* @param objId is object's id, with null value for root object
|
|
193
|
-
* @param bytes are bytes to upload
|
|
194
194
|
* @param fstReq is options object for the first request
|
|
195
195
|
* @param followReq is options object for subsequent request(s)
|
|
196
|
+
* @param bytes is an object with header, diff and segs bytes to upload
|
|
196
197
|
*/
|
|
197
|
-
async saveNewObjVersion(objId,
|
|
198
|
+
async saveNewObjVersion(objId, fstReq, followReq, { header, diff, segs }) {
|
|
198
199
|
let appPath;
|
|
199
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
|
+
};
|
|
200
208
|
appPath = (objId ?
|
|
201
|
-
api.currentObj.firstPutReqUrlEnd(objId,
|
|
202
|
-
api.currentRootObj.firstPutReqUrlEnd(
|
|
209
|
+
api.currentObj.firstPutReqUrlEnd(objId, reqOpts) :
|
|
210
|
+
api.currentRootObj.firstPutReqUrlEnd(reqOpts));
|
|
203
211
|
}
|
|
204
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
|
+
};
|
|
205
218
|
appPath = (objId ?
|
|
206
|
-
api.currentObj.secondPutReqUrlEnd(objId,
|
|
207
|
-
api.currentRootObj.secondPutReqUrlEnd(
|
|
219
|
+
api.currentObj.secondPutReqUrlEnd(objId, reqOpts) :
|
|
220
|
+
api.currentRootObj.secondPutReqUrlEnd(reqOpts));
|
|
208
221
|
}
|
|
209
222
|
else {
|
|
210
223
|
throw new Error(`Missing request options`);
|
|
211
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
|
+
}
|
|
212
241
|
const rep = await this.doBinarySessionRequest({ appPath, method: 'PUT', responseType: 'json' }, bytes);
|
|
213
242
|
if (rep.status === api.currentObj.SC.okPut) {
|
|
214
243
|
return rep.data.transactionId;
|
|
215
244
|
}
|
|
216
245
|
else if (rep.status === api.currentObj.SC.objAlreadyExists) {
|
|
217
|
-
throw exceptions_1.makeObjExistsExc(objId, undefined, true);
|
|
246
|
+
throw (0, exceptions_1.makeObjExistsExc)(objId, undefined, true);
|
|
218
247
|
}
|
|
219
248
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
220
|
-
throw exceptions_1.makeObjNotFoundExc(objId, undefined, true);
|
|
249
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
|
|
221
250
|
}
|
|
222
251
|
else if (rep.status === api.currentObj.SC.concurrentTransaction) {
|
|
223
|
-
throw exceptions_1.makeConcurrentTransExc(objId);
|
|
252
|
+
throw (0, exceptions_1.makeConcurrentTransExc)(objId);
|
|
224
253
|
}
|
|
225
254
|
else if (rep.status === api.currentObj.SC.unknownTransaction) {
|
|
226
|
-
throw exceptions_1.makeUnknownTransactionExc(objId);
|
|
255
|
+
throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
|
|
227
256
|
}
|
|
228
257
|
else if (rep.status === api.currentObj.SC.mismatchedObjVer) {
|
|
229
258
|
const curVer = rep.current_version;
|
|
230
259
|
if (!Number.isInteger(curVer)) {
|
|
231
260
|
throw new Error(`Got non-integer current object version value from a version mismatch reply ${curVer}`);
|
|
232
261
|
}
|
|
233
|
-
throw exceptions_1.makeVersionMismatchExc(objId, curVer);
|
|
262
|
+
throw (0, exceptions_1.makeVersionMismatchExc)(objId, curVer);
|
|
234
263
|
}
|
|
235
264
|
else {
|
|
236
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
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);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
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');
|
|
237
305
|
}
|
|
238
306
|
}
|
|
239
307
|
/**
|
|
@@ -245,29 +313,27 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
245
313
|
*/
|
|
246
314
|
async deleteObj(objId) {
|
|
247
315
|
const rep = await this.doBodylessSessionRequest({
|
|
248
|
-
appPath: api.currentObj.
|
|
316
|
+
appPath: api.currentObj.delReqUrlEnd(objId),
|
|
249
317
|
method: 'DELETE'
|
|
250
318
|
});
|
|
251
|
-
if (rep.status === api.currentObj.SC.okDelete)
|
|
319
|
+
if ((rep.status === api.currentObj.SC.okDelete)
|
|
320
|
+
|| (rep.status === api.currentObj.SC.unknownObj)) {
|
|
252
321
|
return;
|
|
253
322
|
}
|
|
254
323
|
else if (rep.status === api.currentObj.SC.concurrentTransaction) {
|
|
255
|
-
throw exceptions_1.makeConcurrentTransExc(objId);
|
|
256
|
-
}
|
|
257
|
-
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
258
|
-
throw exceptions_1.makeObjNotFoundExc(objId, undefined, true);
|
|
324
|
+
throw (0, exceptions_1.makeConcurrentTransExc)(objId);
|
|
259
325
|
}
|
|
260
326
|
else {
|
|
261
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
327
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
262
328
|
}
|
|
263
329
|
}
|
|
264
330
|
async openEventSource() {
|
|
265
331
|
const rep = await this.openWS(api.wsEventChannel.URL_END);
|
|
266
332
|
if (rep.status === api.wsEventChannel.SC.ok) {
|
|
267
|
-
return ws_ipc_1.makeSubscriber(rep.data, undefined);
|
|
333
|
+
return (0, ws_ipc_1.makeSubscriber)(rep.data, undefined);
|
|
268
334
|
}
|
|
269
335
|
else {
|
|
270
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
336
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
271
337
|
}
|
|
272
338
|
}
|
|
273
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,28 +1,22 @@
|
|
|
1
1
|
import { ScryptGenParams } from '../../key-derivation';
|
|
2
2
|
import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
|
|
3
|
-
import { objChanged, objRemoved } from '../../../lib-common/service-api/3nstorage/owner';
|
|
4
3
|
import { Observable } from 'rxjs';
|
|
5
|
-
import { UpSyncTaskInfo } from '../../../core/storage/synced/obj-status';
|
|
6
4
|
export { AsyncSBoxCryptor } from 'xsp-files';
|
|
7
5
|
export { FolderInJSON } from './folder-node';
|
|
8
6
|
declare type StorageType = web3n.files.FSType;
|
|
9
7
|
declare type FolderEvent = web3n.files.FolderEvent;
|
|
10
8
|
declare type FileEvent = web3n.files.FileEvent;
|
|
11
|
-
declare type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export declare type RemoteEvent = RemoteObjRemovalEvent | RemoteObjChangeEvent;
|
|
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'];
|
|
19
15
|
export interface Node {
|
|
20
16
|
objId: string;
|
|
21
17
|
name: string;
|
|
22
18
|
type: NodeType;
|
|
23
|
-
|
|
24
|
-
broadcastUpSyncEvent(task: UpSyncTaskInfo): void;
|
|
25
|
-
localDelete(): Promise<void>;
|
|
19
|
+
removeObj(src?: FSChangeSrc): Promise<void>;
|
|
26
20
|
}
|
|
27
21
|
export declare type NodeType = 'file' | 'link' | 'folder';
|
|
28
22
|
export declare type ObjId = string | null;
|
|
@@ -56,7 +50,8 @@ export declare class NodesContainer {
|
|
|
56
50
|
export interface NodeEvent {
|
|
57
51
|
objId: ObjId;
|
|
58
52
|
parentObjId?: ObjId;
|
|
59
|
-
|
|
53
|
+
childObjId?: ObjId;
|
|
54
|
+
event: FolderEvent | FileEvent | RemoteEvent;
|
|
60
55
|
}
|
|
61
56
|
export interface Storage {
|
|
62
57
|
readonly type: StorageType;
|
|
@@ -64,7 +59,7 @@ export interface Storage {
|
|
|
64
59
|
readonly cryptor: AsyncSBoxCryptor;
|
|
65
60
|
readonly nodes: NodesContainer;
|
|
66
61
|
getNodeEvents(): Observable<NodeEvent>;
|
|
67
|
-
broadcastNodeEvent(objId: ObjId, parentObjId: ObjId | undefined,
|
|
62
|
+
broadcastNodeEvent(objId: ObjId, parentObjId: ObjId | undefined, childObjId: ObjId | undefined, ev: NodeEvent['event']): void;
|
|
68
63
|
/**
|
|
69
64
|
* This returns a storage of another type, for use by link functionality.
|
|
70
65
|
* @param type is a type of a requested storage.
|
|
@@ -79,8 +74,9 @@ export interface Storage {
|
|
|
79
74
|
/**
|
|
80
75
|
* This returns a promise, resolvable to source for a requested object.
|
|
81
76
|
* @param objId
|
|
77
|
+
* @param version
|
|
82
78
|
*/
|
|
83
|
-
|
|
79
|
+
getObjSrc(objId: ObjId, version?: number): Promise<ObjSource>;
|
|
84
80
|
/**
|
|
85
81
|
* This saves given object, asynchronously.
|
|
86
82
|
* @param objId
|
|
@@ -98,15 +94,43 @@ export interface Storage {
|
|
|
98
94
|
* This asynchronously runs closing cleanup.
|
|
99
95
|
*/
|
|
100
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
|
+
};
|
|
101
105
|
}
|
|
102
106
|
export declare function wrapStorageImplementation(impl: Storage): Storage;
|
|
103
107
|
export declare type StorageGetter = (type: StorageType, location?: string) => Storage;
|
|
104
108
|
export interface SyncedStorage extends Storage {
|
|
109
|
+
getObjSrcOfRemoteVersion(objId: ObjId, version: number): Promise<ObjSource>;
|
|
110
|
+
archiveVersionOnServer(objId: ObjId, version: number): Promise<void>;
|
|
105
111
|
/**
|
|
106
112
|
* This returns a promise, resolvable to root key generation parameters.
|
|
107
113
|
*/
|
|
108
114
|
getRootKeyDerivParamsFromServer(): Promise<ScryptGenParams>;
|
|
109
|
-
|
|
110
|
-
|
|
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;
|
|
111
133
|
}
|
|
112
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
|
*
|
|
@@ -102,10 +102,11 @@ function wrapStorageImplementation(impl) {
|
|
|
102
102
|
broadcastNodeEvent: impl.broadcastNodeEvent.bind(impl),
|
|
103
103
|
storageForLinking: impl.storageForLinking.bind(impl),
|
|
104
104
|
generateNewObjId: impl.generateNewObjId.bind(impl),
|
|
105
|
-
|
|
105
|
+
getObjSrc: impl.getObjSrc.bind(impl),
|
|
106
106
|
saveObj: impl.saveObj.bind(impl),
|
|
107
107
|
close: impl.close.bind(impl),
|
|
108
108
|
removeObj: impl.removeObj.bind(impl),
|
|
109
|
+
status: impl.status.bind(impl),
|
|
109
110
|
cryptor: impl.cryptor
|
|
110
111
|
};
|
|
111
112
|
return Object.freeze(wrap);
|
|
@@ -113,24 +114,33 @@ function wrapStorageImplementation(impl) {
|
|
|
113
114
|
exports.wrapStorageImplementation = wrapStorageImplementation;
|
|
114
115
|
function wrapSyncStorageImplementation(impl) {
|
|
115
116
|
const storageWrap = wrapStorageImplementation(impl);
|
|
116
|
-
const wrap = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
getObjSyncInfo: impl.getObjSyncInfo.bind(impl)
|
|
132
|
-
};
|
|
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);
|
|
133
132
|
return Object.freeze(wrap);
|
|
134
133
|
}
|
|
135
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;
|
|
136
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<{
|