core-3nweb-client-lib 0.26.1 → 0.27.3
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 +281 -75
- 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.d.ts +2 -1
- package/build/core/asmail/inbox/attachments/fs.js +9 -4
- 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/index.d.ts +43 -0
- package/build/core/{id-manager.js → id-manager/index.js} +36 -114
- package/build/core/id-manager/key-storage.d.ts +21 -0
- package/build/core/id-manager/key-storage.js +96 -0
- package/build/core/index.d.ts +2 -1
- package/build/core/index.js +31 -33
- package/build/core/sign-in.d.ts +1 -2
- package/build/core/sign-in.js +8 -17
- package/build/core/sign-up.d.ts +2 -0
- package/build/core/sign-up.js +11 -10
- 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 +5 -17
- package/build/core/storage/index.js +78 -119
- 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 +10 -7
- 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 +1 -0
- package/build/core/storage/synced/obj-files-gc.js +76 -39
- package/build/core/storage/synced/obj-files.d.ts +50 -36
- package/build/core/storage/synced/obj-files.js +201 -162
- package/build/core/storage/synced/obj-status.d.ts +99 -86
- package/build/core/storage/synced/obj-status.js +520 -251
- 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 +24 -10
- package/build/core/storage/synced/storage.js +147 -47
- 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 +210 -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 +16 -1
- package/build/lib-client/3nstorage/exceptions.js +21 -3
- package/build/lib-client/3nstorage/service.d.ts +21 -3
- package/build/lib-client/3nstorage/service.js +128 -46
- package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
- package/build/lib-client/3nstorage/util/file-based-json.js +3 -2
- package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
- package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
- package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +44 -19
- package/build/lib-client/3nstorage/xsp-fs/common.js +30 -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 +32 -13
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +752 -192
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +236 -119
- 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 -29
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +232 -127
- 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.d.ts +2 -1
- package/build/lib-client/user-with-mid-session.js +14 -8
- 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 +17 -17
- 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.d.ts +4 -2
- package/build/lib-common/exceptions/file.js +24 -54
- package/build/lib-common/ipc/generic-ipc.js +5 -4
- 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 +101 -42
- package/build/lib-common/service-api/3nstorage/owner.js +83 -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 +7 -5
- package/protos/file.proto +91 -19
- package/protos/fs.proto +107 -8
- package/build/core/id-manager.d.ts +0 -46
|
@@ -27,23 +27,40 @@ 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");
|
|
31
|
+
function toInitServiceUriGetter(net, mainUrlGetter) {
|
|
32
|
+
return async () => {
|
|
33
|
+
const serviceUrl = await mainUrlGetter();
|
|
34
|
+
const info = await (0, service_locator_1.storageInfoAt)(net, serviceUrl);
|
|
35
|
+
if (!info.owner) {
|
|
36
|
+
throw new Error(`Missing owner service url in 3NStorage information at ${serviceUrl}`);
|
|
37
|
+
}
|
|
38
|
+
return info.owner;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
30
41
|
class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
31
|
-
constructor(user, getSigner,
|
|
42
|
+
constructor(user, getSigner, getInitServiceURI, net) {
|
|
32
43
|
super(user, {
|
|
33
44
|
login: api.midLogin.MID_URL_PART,
|
|
34
45
|
logout: api.closeSession.URL_END,
|
|
35
46
|
canBeRedirected: true
|
|
36
|
-
}, getSigner,
|
|
37
|
-
const serviceUrl = await mainUrlGetter();
|
|
38
|
-
const info = await service_locator_1.storageInfoAt(this.net, serviceUrl);
|
|
39
|
-
if (!info.owner) {
|
|
40
|
-
throw new Error(`Missing owner service url in 3NStorage information at ${serviceUrl}`);
|
|
41
|
-
}
|
|
42
|
-
return info.owner;
|
|
43
|
-
}, net);
|
|
47
|
+
}, getSigner, getInitServiceURI, net);
|
|
44
48
|
this.maxChunkSize = undefined;
|
|
45
49
|
Object.seal(this);
|
|
46
50
|
}
|
|
51
|
+
static make(user, getSigner, mainUrlGetter, net) {
|
|
52
|
+
const srvUriGetter = toInitServiceUriGetter(net, mainUrlGetter);
|
|
53
|
+
const remote = new StorageOwner(user, getSigner, srvUriGetter, net);
|
|
54
|
+
return remote;
|
|
55
|
+
}
|
|
56
|
+
static makeBeforeMidSetup(user, mainUrlGetter, net) {
|
|
57
|
+
const srvUriGetter = toInitServiceUriGetter(net, mainUrlGetter);
|
|
58
|
+
const remote = new StorageOwner(user, undefined, srvUriGetter, net);
|
|
59
|
+
return {
|
|
60
|
+
remote,
|
|
61
|
+
setMid: getSigner => remote.setGetterOfSigner(getSigner)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
47
64
|
async getKeyDerivParams() {
|
|
48
65
|
const rep = await this.doBodylessSessionRequest({
|
|
49
66
|
appPath: api.keyDerivParams.URL_END,
|
|
@@ -51,11 +68,11 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
51
68
|
responseType: 'json'
|
|
52
69
|
});
|
|
53
70
|
if (rep.status !== api.sessionParams.SC.ok) {
|
|
54
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
71
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
55
72
|
}
|
|
56
73
|
const keyDerivParams = rep.data;
|
|
57
74
|
if (!keyGen.checkParams(rep.data)) {
|
|
58
|
-
throw request_utils_1.makeException(rep, 'Malformed response');
|
|
75
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed response');
|
|
59
76
|
}
|
|
60
77
|
return keyDerivParams;
|
|
61
78
|
}
|
|
@@ -66,11 +83,11 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
66
83
|
responseType: 'json'
|
|
67
84
|
});
|
|
68
85
|
if (rep.status !== api.sessionParams.SC.ok) {
|
|
69
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
86
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
70
87
|
}
|
|
71
88
|
if ((typeof rep.data.maxChunkSize !== 'number') ||
|
|
72
89
|
(rep.data.maxChunkSize < 64 * 1024)) {
|
|
73
|
-
throw request_utils_1.makeException(rep, 'Malformed response');
|
|
90
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed response');
|
|
74
91
|
}
|
|
75
92
|
this.maxChunkSize = rep.data.maxChunkSize;
|
|
76
93
|
}
|
|
@@ -98,10 +115,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
98
115
|
return;
|
|
99
116
|
}
|
|
100
117
|
else if (rep.status === api.cancelTransaction.SC.missing) {
|
|
101
|
-
throw exceptions_1.makeUnknownTransactionExc(objId);
|
|
118
|
+
throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
|
|
102
119
|
}
|
|
103
120
|
else {
|
|
104
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
121
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
124
|
/**
|
|
@@ -128,13 +145,13 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
128
145
|
});
|
|
129
146
|
if (rep.status === api.currentObj.SC.okGet) {
|
|
130
147
|
if (!(rep.data instanceof Uint8Array)) {
|
|
131
|
-
throw request_utils_1.makeException(rep, `Malformed response: body is not binary`);
|
|
148
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
|
|
132
149
|
}
|
|
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);
|
|
150
|
+
const version = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objVersion);
|
|
151
|
+
const segsTotalLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objSegmentsLength);
|
|
152
|
+
const headerLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objHeaderLength);
|
|
136
153
|
if (rep.data.length > (headerLen + segsTotalLen)) {
|
|
137
|
-
throw request_utils_1.makeException(rep, `Malformed response: body is too long`);
|
|
154
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed response: body is too long`);
|
|
138
155
|
}
|
|
139
156
|
return {
|
|
140
157
|
version, segsTotalLen,
|
|
@@ -143,10 +160,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
143
160
|
};
|
|
144
161
|
}
|
|
145
162
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
146
|
-
throw exceptions_1.makeObjNotFoundExc(objId,
|
|
163
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
|
|
147
164
|
}
|
|
148
165
|
else {
|
|
149
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
166
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
150
167
|
}
|
|
151
168
|
}
|
|
152
169
|
/**
|
|
@@ -173,15 +190,15 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
173
190
|
});
|
|
174
191
|
if (rep.status === api.currentObj.SC.okGet) {
|
|
175
192
|
if (!(rep.data instanceof Uint8Array)) {
|
|
176
|
-
throw request_utils_1.makeException(rep, `Malformed response: body is not binary`);
|
|
193
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
|
|
177
194
|
}
|
|
178
195
|
return rep.data;
|
|
179
196
|
}
|
|
180
197
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
181
|
-
throw exceptions_1.makeObjNotFoundExc(objId,
|
|
198
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
|
|
182
199
|
}
|
|
183
200
|
else {
|
|
184
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
201
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
185
202
|
}
|
|
186
203
|
}
|
|
187
204
|
/**
|
|
@@ -190,50 +207,117 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
190
207
|
* complete, or to a transaction id, which must be used for subsequent
|
|
191
208
|
* request(s).
|
|
192
209
|
* @param objId is object's id, with null value for root object
|
|
193
|
-
* @param bytes are bytes to upload
|
|
194
210
|
* @param fstReq is options object for the first request
|
|
195
211
|
* @param followReq is options object for subsequent request(s)
|
|
212
|
+
* @param bytes is an object with header, diff and segs bytes to upload
|
|
196
213
|
*/
|
|
197
|
-
async saveNewObjVersion(objId,
|
|
214
|
+
async saveNewObjVersion(objId, fstReq, followReq, { header, diff, segs }) {
|
|
198
215
|
let appPath;
|
|
199
216
|
if (fstReq) {
|
|
217
|
+
(0, assert_1.assert)(!!header);
|
|
218
|
+
const { ver, last } = fstReq;
|
|
219
|
+
const reqOpts = {
|
|
220
|
+
ver, last,
|
|
221
|
+
header: header.length,
|
|
222
|
+
diff: (diff ? diff.length : undefined)
|
|
223
|
+
};
|
|
200
224
|
appPath = (objId ?
|
|
201
|
-
api.currentObj.firstPutReqUrlEnd(objId,
|
|
202
|
-
api.currentRootObj.firstPutReqUrlEnd(
|
|
225
|
+
api.currentObj.firstPutReqUrlEnd(objId, reqOpts) :
|
|
226
|
+
api.currentRootObj.firstPutReqUrlEnd(reqOpts));
|
|
203
227
|
}
|
|
204
228
|
else if (followReq) {
|
|
229
|
+
const { ofs, trans, last } = followReq;
|
|
230
|
+
// XXX segs argument will introduce difference between these two
|
|
231
|
+
const reqOpts = {
|
|
232
|
+
ofs, trans, last
|
|
233
|
+
};
|
|
205
234
|
appPath = (objId ?
|
|
206
|
-
api.currentObj.secondPutReqUrlEnd(objId,
|
|
207
|
-
api.currentRootObj.secondPutReqUrlEnd(
|
|
235
|
+
api.currentObj.secondPutReqUrlEnd(objId, reqOpts) :
|
|
236
|
+
api.currentRootObj.secondPutReqUrlEnd(reqOpts));
|
|
208
237
|
}
|
|
209
238
|
else {
|
|
210
239
|
throw new Error(`Missing request options`);
|
|
211
240
|
}
|
|
241
|
+
// ordering body bytes in accordance with protocol expectation
|
|
242
|
+
const bytes = [];
|
|
243
|
+
if (diff) {
|
|
244
|
+
bytes.push(diff);
|
|
245
|
+
}
|
|
246
|
+
if (header) {
|
|
247
|
+
bytes.push(header);
|
|
248
|
+
}
|
|
249
|
+
if (segs) {
|
|
250
|
+
if (Array.isArray(segs)) {
|
|
251
|
+
bytes.push(...segs);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
bytes.push(segs);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
212
257
|
const rep = await this.doBinarySessionRequest({ appPath, method: 'PUT', responseType: 'json' }, bytes);
|
|
213
258
|
if (rep.status === api.currentObj.SC.okPut) {
|
|
214
259
|
return rep.data.transactionId;
|
|
215
260
|
}
|
|
216
261
|
else if (rep.status === api.currentObj.SC.objAlreadyExists) {
|
|
217
|
-
throw exceptions_1.makeObjExistsExc(objId, undefined, true);
|
|
262
|
+
throw (0, exceptions_1.makeObjExistsExc)(objId, undefined, true);
|
|
218
263
|
}
|
|
219
264
|
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
220
|
-
throw exceptions_1.makeObjNotFoundExc(objId,
|
|
265
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
|
|
221
266
|
}
|
|
222
267
|
else if (rep.status === api.currentObj.SC.concurrentTransaction) {
|
|
223
|
-
throw exceptions_1.makeConcurrentTransExc(objId);
|
|
268
|
+
throw (0, exceptions_1.makeConcurrentTransExc)(objId);
|
|
224
269
|
}
|
|
225
270
|
else if (rep.status === api.currentObj.SC.unknownTransaction) {
|
|
226
|
-
throw exceptions_1.makeUnknownTransactionExc(objId);
|
|
271
|
+
throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
|
|
227
272
|
}
|
|
228
273
|
else if (rep.status === api.currentObj.SC.mismatchedObjVer) {
|
|
229
274
|
const curVer = rep.current_version;
|
|
230
275
|
if (!Number.isInteger(curVer)) {
|
|
231
276
|
throw new Error(`Got non-integer current object version value from a version mismatch reply ${curVer}`);
|
|
232
277
|
}
|
|
233
|
-
throw exceptions_1.makeVersionMismatchExc(objId, curVer);
|
|
278
|
+
throw (0, exceptions_1.makeVersionMismatchExc)(objId, curVer);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
async archiveObjVersion(objId, currentVer) {
|
|
285
|
+
const rep = await this.doBodylessSessionRequest({
|
|
286
|
+
appPath: (objId ?
|
|
287
|
+
api.archiveObj.postAndDelReqUrlEnd(objId, currentVer) :
|
|
288
|
+
api.archiveRoot.postAndDelReqUrlEnd(currentVer)),
|
|
289
|
+
method: 'POST'
|
|
290
|
+
});
|
|
291
|
+
if (rep.status === api.archiveObj.SC.okPost) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
else if (rep.status === api.currentObj.SC.unknownObj) {
|
|
295
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
|
|
296
|
+
}
|
|
297
|
+
else if (rep.status === api.currentObj.SC.unknownObjVer) {
|
|
298
|
+
throw (0, exceptions_1.makeObjVersionNotFoundExc)(objId, currentVer, true);
|
|
234
299
|
}
|
|
235
300
|
else {
|
|
236
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
301
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
async getObjStatus(objId) {
|
|
305
|
+
const rep = await this.doBodylessSessionRequest({
|
|
306
|
+
appPath: (objId ?
|
|
307
|
+
api.objStatus.getReqUrlEnd(objId) :
|
|
308
|
+
api.rootStatus.getReqUrlEnd()),
|
|
309
|
+
method: 'GET',
|
|
310
|
+
responseType: 'json'
|
|
311
|
+
});
|
|
312
|
+
if (rep.status === api.objStatus.SC.ok) {
|
|
313
|
+
// XXX we may want to add sanity check(s)
|
|
314
|
+
return rep.data;
|
|
315
|
+
}
|
|
316
|
+
else if (rep.status === api.objStatus.SC.unknownObj) {
|
|
317
|
+
throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
237
321
|
}
|
|
238
322
|
}
|
|
239
323
|
/**
|
|
@@ -245,29 +329,27 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
|
|
|
245
329
|
*/
|
|
246
330
|
async deleteObj(objId) {
|
|
247
331
|
const rep = await this.doBodylessSessionRequest({
|
|
248
|
-
appPath: api.currentObj.
|
|
332
|
+
appPath: api.currentObj.delReqUrlEnd(objId),
|
|
249
333
|
method: 'DELETE'
|
|
250
334
|
});
|
|
251
|
-
if (rep.status === api.currentObj.SC.okDelete)
|
|
335
|
+
if ((rep.status === api.currentObj.SC.okDelete)
|
|
336
|
+
|| (rep.status === api.currentObj.SC.unknownObj)) {
|
|
252
337
|
return;
|
|
253
338
|
}
|
|
254
339
|
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);
|
|
340
|
+
throw (0, exceptions_1.makeConcurrentTransExc)(objId);
|
|
259
341
|
}
|
|
260
342
|
else {
|
|
261
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
343
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
262
344
|
}
|
|
263
345
|
}
|
|
264
346
|
async openEventSource() {
|
|
265
347
|
const rep = await this.openWS(api.wsEventChannel.URL_END);
|
|
266
348
|
if (rep.status === api.wsEventChannel.SC.ok) {
|
|
267
|
-
return ws_ipc_1.makeSubscriber(rep.data, undefined);
|
|
349
|
+
return (0, ws_ipc_1.makeSubscriber)(rep.data, undefined);
|
|
268
350
|
}
|
|
269
351
|
else {
|
|
270
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
352
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
271
353
|
}
|
|
272
354
|
}
|
|
273
355
|
}
|
|
@@ -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
|
/**
|
|
@@ -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.JsonFileProc = void 0;
|
|
19
20
|
const rxjs_1 = require("rxjs");
|
|
@@ -38,7 +39,7 @@ class JsonFileProc {
|
|
|
38
39
|
await this.file.writeJSON(fstVal);
|
|
39
40
|
}
|
|
40
41
|
this.proc = (new rxjs_1.Observable(obs => this.file.watch(obs)))
|
|
41
|
-
.pipe(operators_1.mergeMap(ev => this.onFileEvent(ev), 1))
|
|
42
|
+
.pipe((0, operators_1.mergeMap)(ev => this.onFileEvent(ev), 1))
|
|
42
43
|
.subscribe();
|
|
43
44
|
}
|
|
44
45
|
async close() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appendArray<T>(arr: T[], elems: T[] | T | undefined): T[];
|
|
@@ -0,0 +1,32 @@
|
|
|
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.appendArray = void 0;
|
|
20
|
+
function appendArray(arr, elems) {
|
|
21
|
+
if (elems !== undefined) {
|
|
22
|
+
if (Array.isArray(elems)) {
|
|
23
|
+
arr.push(...elems);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
arr.push(elems);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return arr;
|
|
30
|
+
}
|
|
31
|
+
exports.appendArray = appendArray;
|
|
32
|
+
Object.freeze(exports);
|
|
@@ -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 {
|
|
4
|
+
import { LogError } from '../../logging/log-to-file';
|
|
6
5
|
export { AsyncSBoxCryptor } from 'xsp-files';
|
|
7
6
|
export { FolderInJSON } from './folder-node';
|
|
8
7
|
declare type StorageType = web3n.files.FSType;
|
|
9
8
|
declare type FolderEvent = web3n.files.FolderEvent;
|
|
10
9
|
declare type FileEvent = web3n.files.FileEvent;
|
|
11
|
-
declare type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export declare type RemoteEvent = RemoteObjRemovalEvent | RemoteObjChangeEvent;
|
|
10
|
+
declare type RemoteEvent = web3n.files.RemoteEvent;
|
|
11
|
+
declare type SyncStatus = web3n.files.SyncStatus;
|
|
12
|
+
declare type OptionsToAdopteRemote = web3n.files.OptionsToAdopteRemote;
|
|
13
|
+
declare type FSSyncException = web3n.files.FSSyncException;
|
|
14
|
+
declare type FileException = web3n.files.FileException;
|
|
15
|
+
export declare type FSChangeSrc = web3n.files.FSChangeEvent['src'];
|
|
19
16
|
export interface Node {
|
|
20
17
|
objId: string;
|
|
21
18
|
name: string;
|
|
22
19
|
type: NodeType;
|
|
23
|
-
processRemoteEvent: (event: RemoteEvent) => Promise<void>;
|
|
24
|
-
broadcastUpSyncEvent(task: UpSyncTaskInfo): void;
|
|
25
|
-
localDelete(): Promise<void>;
|
|
26
20
|
}
|
|
27
21
|
export declare type NodeType = 'file' | 'link' | 'folder';
|
|
28
22
|
export declare type ObjId = string | null;
|
|
@@ -56,15 +50,17 @@ 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;
|
|
63
58
|
readonly versioned: boolean;
|
|
64
59
|
readonly cryptor: AsyncSBoxCryptor;
|
|
65
60
|
readonly nodes: NodesContainer;
|
|
61
|
+
readonly logError: LogError;
|
|
66
62
|
getNodeEvents(): Observable<NodeEvent>;
|
|
67
|
-
broadcastNodeEvent(objId: ObjId, parentObjId: ObjId | undefined,
|
|
63
|
+
broadcastNodeEvent(objId: ObjId, parentObjId: ObjId | undefined, childObjId: ObjId | undefined, ev: NodeEvent['event']): void;
|
|
68
64
|
/**
|
|
69
65
|
* This returns a storage of another type, for use by link functionality.
|
|
70
66
|
* @param type is a type of a requested storage.
|
|
@@ -78,9 +74,8 @@ export interface Storage {
|
|
|
78
74
|
generateNewObjId(): Promise<string>;
|
|
79
75
|
/**
|
|
80
76
|
* This returns a promise, resolvable to source for a requested object.
|
|
81
|
-
* @param objId
|
|
82
77
|
*/
|
|
83
|
-
|
|
78
|
+
getObjSrc(objId: ObjId, version?: number, allowArchived?: boolean): Promise<ObjSource>;
|
|
84
79
|
/**
|
|
85
80
|
* This saves given object, asynchronously.
|
|
86
81
|
* @param objId
|
|
@@ -98,15 +93,45 @@ export interface Storage {
|
|
|
98
93
|
* This asynchronously runs closing cleanup.
|
|
99
94
|
*/
|
|
100
95
|
close(): Promise<void>;
|
|
96
|
+
status(objId: ObjId): Promise<LocalObjStatus>;
|
|
97
|
+
}
|
|
98
|
+
export interface LocalObjStatus {
|
|
99
|
+
archiveCurrentVersion(): Promise<void>;
|
|
100
|
+
listVersions(): {
|
|
101
|
+
current?: number;
|
|
102
|
+
archived?: number[];
|
|
103
|
+
};
|
|
101
104
|
}
|
|
102
105
|
export declare function wrapStorageImplementation(impl: Storage): Storage;
|
|
103
106
|
export declare type StorageGetter = (type: StorageType, location?: string) => Storage;
|
|
104
107
|
export interface SyncedStorage extends Storage {
|
|
108
|
+
getObjSrcOfRemoteVersion(objId: ObjId, version: number): Promise<ObjSource>;
|
|
109
|
+
archiveVersionOnServer(objId: ObjId, version: number): Promise<void>;
|
|
105
110
|
/**
|
|
106
111
|
* This returns a promise, resolvable to root key generation parameters.
|
|
107
112
|
*/
|
|
108
113
|
getRootKeyDerivParamsFromServer(): Promise<ScryptGenParams>;
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
adoptRemote(objId: ObjId, opts: OptionsToAdopteRemote | undefined): Promise<number | undefined>;
|
|
115
|
+
updateStatusInfo(objId: ObjId): Promise<SyncStatus>;
|
|
116
|
+
isObjOnDisk(objId: ObjId): Promise<boolean>;
|
|
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
|
+
versionBeforeUnsyncedRemoval(): number | undefined;
|
|
128
|
+
}
|
|
129
|
+
export interface UploadHeaderChange {
|
|
130
|
+
localVersion: number;
|
|
131
|
+
uploadVersion: number;
|
|
132
|
+
localHeader: Uint8Array;
|
|
133
|
+
uploadHeader: Uint8Array;
|
|
111
134
|
}
|
|
112
135
|
export declare function wrapSyncStorageImplementation(impl: SyncedStorage): SyncedStorage;
|
|
136
|
+
export declare function isSyncedStorage(storage: Storage): boolean;
|
|
137
|
+
export declare function setPathInExc(exc: FSSyncException | FileException, path: string): FSSyncException | FileException;
|