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
|
@@ -55,7 +55,7 @@ class ServiceUser {
|
|
|
55
55
|
return this.uri;
|
|
56
56
|
}
|
|
57
57
|
set serviceURI(uriString) {
|
|
58
|
-
const u = url_1.parse(uriString);
|
|
58
|
+
const u = (0, url_1.parse)(uriString);
|
|
59
59
|
if (u.protocol !== 'https:') {
|
|
60
60
|
throw new Error("Url protocol must be https.");
|
|
61
61
|
}
|
|
@@ -82,40 +82,40 @@ class ServiceUser {
|
|
|
82
82
|
if (rep.status == loginApi.start.SC.ok) {
|
|
83
83
|
// set sessionid
|
|
84
84
|
if (!rep.data || (typeof rep.data.sessionId !== 'string')) {
|
|
85
|
-
throw request_utils_1.makeException(rep, 'Malformed reply to starting session');
|
|
85
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply to starting session');
|
|
86
86
|
}
|
|
87
87
|
this.sessionId = rep.data.sessionId;
|
|
88
88
|
// set server public key
|
|
89
89
|
if (typeof rep.data.serverPubKey !== 'string') {
|
|
90
|
-
throw request_utils_1.makeException(rep, 'Malformed reply: serverPubKey string is missing.');
|
|
90
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: serverPubKey string is missing.');
|
|
91
91
|
}
|
|
92
92
|
try {
|
|
93
93
|
this.serverPubKey = buffer_utils_1.base64.open(rep.data.serverPubKey);
|
|
94
94
|
if (this.serverPubKey.length !== ecma_nacl_1.box.KEY_LENGTH) {
|
|
95
|
-
throw request_utils_1.makeException(rep, 'Malformed reply: server\'s key has a wrong size.');
|
|
95
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: server\'s key has a wrong size.');
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
catch (err) {
|
|
99
|
-
throw request_utils_1.makeException(rep, `Malformed reply: bad serverPubKey string. Error: ${('string' === typeof err) ? err : err.message}`);
|
|
99
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: bad serverPubKey string. Error: ${('string' === typeof err) ? err : err.message}`);
|
|
100
100
|
}
|
|
101
101
|
// get encrypted session key from json body
|
|
102
102
|
if (typeof rep.data.sessionKey !== 'string') {
|
|
103
|
-
throw request_utils_1.makeException(rep, 'Malformed reply: sessionKey string is missing.');
|
|
103
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: sessionKey string is missing.');
|
|
104
104
|
}
|
|
105
105
|
try {
|
|
106
106
|
this.encChallenge = buffer_utils_1.base64.open(rep.data.sessionKey);
|
|
107
107
|
if (this.encChallenge.length !==
|
|
108
108
|
(ecma_nacl_1.secret_box.NONCE_LENGTH + ecma_nacl_1.secret_box.KEY_LENGTH)) {
|
|
109
|
-
throw request_utils_1.makeException(rep, `Malformed reply: byte chunk with session key has a wrong size.`);
|
|
109
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: byte chunk with session key has a wrong size.`);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
catch (err) {
|
|
113
|
-
throw request_utils_1.makeException(rep, `Malformed reply: bad sessionKey string. Error: ${(typeof err === 'string') ? err : err.message}`);
|
|
113
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: bad sessionKey string. Error: ${(typeof err === 'string') ? err : err.message}`);
|
|
114
114
|
}
|
|
115
115
|
// get key derivation parameters for a default key
|
|
116
116
|
if (!keyId) {
|
|
117
117
|
if (typeof rep.data.keyDerivParams !== 'object') {
|
|
118
|
-
throw request_utils_1.makeException(rep, `Malformed reply: keyDerivParams string is missing.`);
|
|
118
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: keyDerivParams string is missing.`);
|
|
119
119
|
}
|
|
120
120
|
this.keyDerivationParams = rep.data.keyDerivParams;
|
|
121
121
|
}
|
|
@@ -124,11 +124,11 @@ class ServiceUser {
|
|
|
124
124
|
(rep.status === loginApi.start.SC.redirect)) {
|
|
125
125
|
const rd = rep.data;
|
|
126
126
|
if (!rd || ('string' !== typeof rd.redirect)) {
|
|
127
|
-
throw request_utils_1.makeException(rep, 'Malformed reply');
|
|
127
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
|
|
128
128
|
}
|
|
129
129
|
// refuse second redirect
|
|
130
130
|
if (this.redirectedFrom !== undefined) {
|
|
131
|
-
throw request_utils_1.makeException(rep, `Redirected too many times. First redirect was from ${this.redirectedFrom} to ${this.serviceURI}. Second and forbidden redirect is to ${rd.redirect}`);
|
|
131
|
+
throw (0, request_utils_1.makeException)(rep, `Redirected too many times. First redirect was from ${this.redirectedFrom} to ${this.serviceURI}. Second and forbidden redirect is to ${rd.redirect}`);
|
|
132
132
|
}
|
|
133
133
|
// set params
|
|
134
134
|
this.redirectedFrom = this.serviceURI;
|
|
@@ -137,19 +137,19 @@ class ServiceUser {
|
|
|
137
137
|
return this.startSession(keyId);
|
|
138
138
|
}
|
|
139
139
|
else if (rep.status === loginApi.start.SC.unknownUser) {
|
|
140
|
-
const exc = request_utils_1.makeException(rep);
|
|
140
|
+
const exc = (0, request_utils_1.makeException)(rep);
|
|
141
141
|
exc.unknownUser = true;
|
|
142
142
|
throw exc;
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
145
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
145
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
openSessionKey(dhsharedKeyCalc) {
|
|
149
|
-
assert_1.assert(!!this.encChallenge);
|
|
149
|
+
(0, assert_1.assert)(!!this.encChallenge);
|
|
150
150
|
const dhsharedKey = dhsharedKeyCalc();
|
|
151
|
-
const nonce = buffer_utils_1.makeUint8ArrayCopy(this.encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
152
|
-
const sessionKey = buffer_utils_1.makeUint8ArrayCopy(this.encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
151
|
+
const nonce = (0, buffer_utils_1.makeUint8ArrayCopy)(this.encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
152
|
+
const sessionKey = (0, buffer_utils_1.makeUint8ArrayCopy)(this.encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
153
153
|
// encrypted challenge has session key packaged into WN format, with
|
|
154
154
|
// poly part cut out. Therefore, usual open method will not do as it
|
|
155
155
|
// does poly check. We should recall that cipher is a stream with data
|
|
@@ -168,15 +168,15 @@ class ServiceUser {
|
|
|
168
168
|
this.serverVerificationBytes =
|
|
169
169
|
this.serverVerificationBytes.subarray(0, ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
170
170
|
ecma_nacl_1.nonce.advanceOddly(nonce);
|
|
171
|
-
this.encryptor = session_encryptor_1.makeSessionEncryptor(sessionKey, nonce);
|
|
171
|
+
this.encryptor = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
|
|
172
172
|
// encrypt session key for completion of login exchange
|
|
173
173
|
this.encChallenge = this.encryptor.pack(sessionKey);
|
|
174
174
|
// cleanup arrays
|
|
175
175
|
ecma_nacl_1.arrays.wipe(dhsharedKey, nonce, sessionKey);
|
|
176
176
|
}
|
|
177
177
|
async completeLoginExchange() {
|
|
178
|
-
assert_1.assert(!!this.encChallenge);
|
|
179
|
-
assert_1.assert(!!this.serverVerificationBytes);
|
|
178
|
+
(0, assert_1.assert)(!!this.encChallenge);
|
|
179
|
+
(0, assert_1.assert)(!!this.serverVerificationBytes);
|
|
180
180
|
const rep = await this.net.doBinaryRequest({
|
|
181
181
|
url: `${this.serviceURI}${this.loginUrlPart}${loginApi.complete.URL_END}`,
|
|
182
182
|
method: loginApi.complete.method,
|
|
@@ -186,22 +186,22 @@ class ServiceUser {
|
|
|
186
186
|
this.encChallenge = undefined;
|
|
187
187
|
if (rep.status === loginApi.complete.SC.ok) {
|
|
188
188
|
// compare bytes to check, if server can be trusted
|
|
189
|
-
if (ecma_nacl_1.compareVectors(rep.data, this.serverVerificationBytes)) {
|
|
189
|
+
if ((0, ecma_nacl_1.compareVectors)(rep.data, this.serverVerificationBytes)) {
|
|
190
190
|
this.serverVerificationBytes = undefined;
|
|
191
191
|
}
|
|
192
192
|
else {
|
|
193
|
-
const exc = request_utils_1.makeException(rep);
|
|
193
|
+
const exc = (0, request_utils_1.makeException)(rep);
|
|
194
194
|
exc.serverNotTrusted = true;
|
|
195
195
|
throw exc;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
else if (rep.status === loginApi.complete.SC.authFailed) {
|
|
199
|
-
const exc = request_utils_1.makeException(rep);
|
|
199
|
+
const exc = (0, request_utils_1.makeException)(rep);
|
|
200
200
|
exc.cryptoResponseNotAccepted = true;
|
|
201
201
|
throw exc;
|
|
202
202
|
}
|
|
203
203
|
else {
|
|
204
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
204
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
@@ -216,7 +216,7 @@ class ServiceUser {
|
|
|
216
216
|
*/
|
|
217
217
|
async login(keyId) {
|
|
218
218
|
await this.startSession(keyId);
|
|
219
|
-
assert_1.assert(!!this.serverPubKey);
|
|
219
|
+
(0, assert_1.assert)(!!this.serverPubKey);
|
|
220
220
|
return {
|
|
221
221
|
keyParams: this.keyDerivationParams,
|
|
222
222
|
serverPKey: this.serverPubKey,
|
|
@@ -245,7 +245,7 @@ class ServiceUser {
|
|
|
245
245
|
this.encryptor = undefined;
|
|
246
246
|
}
|
|
247
247
|
else {
|
|
248
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
248
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -28,8 +28,8 @@ function openSocket(url, sessionId) {
|
|
|
28
28
|
const headers = {};
|
|
29
29
|
headers[request_utils_1.SESSION_ID_HEADER] = sessionId;
|
|
30
30
|
const ws = new WebSocket(url, { headers, agent: https_1.globalAgent });
|
|
31
|
-
const opening = deferred_1.defer();
|
|
32
|
-
const initOnError = err => opening.reject(http_1.makeConnectionException(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
|
|
31
|
+
const opening = (0, deferred_1.defer)();
|
|
32
|
+
const initOnError = err => opening.reject((0, http_1.makeConnectionException)(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
|
|
33
33
|
const onNonOkReply = (req, res) => {
|
|
34
34
|
const errReply = {
|
|
35
35
|
url,
|
|
@@ -52,8 +52,8 @@ function makeEncryptor(cryptor, key, nextNonce, delta) {
|
|
|
52
52
|
else if ((delta < 1) || (delta > 255)) {
|
|
53
53
|
throw new Error("Given delta is out of bounds.");
|
|
54
54
|
}
|
|
55
|
-
key = buffer_utils_1.makeUint8ArrayCopy(key);
|
|
56
|
-
nextNonce = buffer_utils_1.makeUint8ArrayCopy(nextNonce);
|
|
55
|
+
key = (0, buffer_utils_1.makeUint8ArrayCopy)(key);
|
|
56
|
+
nextNonce = (0, buffer_utils_1.makeUint8ArrayCopy)(nextNonce);
|
|
57
57
|
let counter = 0;
|
|
58
58
|
const counterMax = Math.floor(0xfffffffffffff / delta);
|
|
59
59
|
const encryptor = {
|
|
@@ -65,7 +65,7 @@ function makeEncryptor(cryptor, key, nextNonce, delta) {
|
|
|
65
65
|
throw new Error(`This encryptor has been used too many times. Further use may lead to duplication of nonces.`);
|
|
66
66
|
}
|
|
67
67
|
const c = await cryptor.formatWN.pack(m, nextNonce, key);
|
|
68
|
-
xsp_files_1.advanceNonce(nextNonce, delta);
|
|
68
|
+
(0, xsp_files_1.advanceNonce)(nextNonce, delta);
|
|
69
69
|
counter += 1;
|
|
70
70
|
return c;
|
|
71
71
|
},
|
|
@@ -101,7 +101,7 @@ function makeDecryptor(cryptor, key) {
|
|
|
101
101
|
if (key.length !== 32) {
|
|
102
102
|
throw new Error(`Key array key should have 32 elements (bytes) in it, but it is ${key.length} elements long.`);
|
|
103
103
|
}
|
|
104
|
-
key = buffer_utils_1.makeUint8ArrayCopy(key);
|
|
104
|
+
key = (0, buffer_utils_1.makeUint8ArrayCopy)(key);
|
|
105
105
|
const decryptor = {
|
|
106
106
|
open: (c) => {
|
|
107
107
|
if (!key) {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import * as fs from 'fs';
|
|
3
5
|
import { Readable, Writable } from 'stream';
|
|
4
6
|
export { Stats } from 'fs';
|
|
5
7
|
export { FileException } from './exceptions/file';
|
|
6
8
|
export declare function readFile(filename: string, options: {
|
|
7
|
-
encoding:
|
|
9
|
+
encoding: BufferEncoding;
|
|
8
10
|
flag?: string;
|
|
9
11
|
}): Promise<string>;
|
|
10
12
|
export declare function readFile(filename: string, options?: {
|
|
11
13
|
flag?: string;
|
|
12
14
|
}): Promise<Buffer>;
|
|
13
15
|
export declare function writeFile(path: string, data: any, options?: {
|
|
14
|
-
encoding?:
|
|
16
|
+
encoding?: BufferEncoding;
|
|
15
17
|
mode?: string;
|
|
16
18
|
flag?: string;
|
|
17
19
|
}): Promise<void>;
|
|
18
20
|
export declare function appendFile(path: string, data: any, options?: {
|
|
19
|
-
encoding?:
|
|
21
|
+
encoding?: BufferEncoding;
|
|
20
22
|
mode?: string;
|
|
21
23
|
flag?: string;
|
|
22
24
|
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2019, 2021 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2019, 2021 - 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
|
|
@@ -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.ensureFolderExists = exports.copyTree = exports.copyFile = exports.streamFromFile = exports.rmDirWithContent = exports.read = exports.streamToExistingFile = exports.append = exports.write = exports.getFolderContentSize = exports.getFileSize = exports.existsFileSync = exports.existsFolderSync = exports.existsFolder = exports.createEmptyFile = exports.writeFromBuf = exports.readToBuf = exports.ftruncate = exports.truncate = exports.rename = exports.unlink = exports.rmdir = exports.readdir = exports.fstat = exports.stat = exports.lstat = exports.readlink = exports.symlink = exports.close = exports.open = exports.mkdir = exports.appendFile = exports.writeFile = exports.readFile = void 0;
|
|
19
|
+
exports.ensureFolderExists = exports.copyTree = exports.copyFile = exports.streamFromFile = exports.rmDirWithContent = exports.read = exports.streamToExistingFile = exports.append = exports.write = exports.getFolderContentSize = exports.getFileSize = exports.existsFileSync = exports.existsFolderSync = exports.existsFolder = exports.createEmptyFile = exports.writeFromBuf = exports.readToBuf = exports.ftruncate = exports.truncate = exports.rename = exports.unlink = exports.rmdir = exports.readdir = exports.fstat = exports.stat = exports.lstat = exports.readlink = exports.symlink = exports.close = exports.open = exports.mkdir = exports.appendFile = exports.writeFile = exports.readFile = exports.Stats = void 0;
|
|
20
20
|
const fs = require("fs");
|
|
21
21
|
const fs_1 = require("fs");
|
|
22
22
|
const file_1 = require("./exceptions/file");
|
|
@@ -28,7 +28,7 @@ const path_1 = require("path");
|
|
|
28
28
|
var fs_2 = require("fs");
|
|
29
29
|
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return fs_2.Stats; } });
|
|
30
30
|
function makeFileExceptionFromNodes(nodeExc) {
|
|
31
|
-
return file_1.
|
|
31
|
+
return (0, file_1.makeFileExceptionFromCode)(nodeExc.code, nodeExc.path);
|
|
32
32
|
}
|
|
33
33
|
function readFile(path, options) {
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
@@ -307,7 +307,7 @@ async function readToBuf(fd, pos, buf) {
|
|
|
307
307
|
while (bytesRead < buf.length) {
|
|
308
308
|
const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
|
|
309
309
|
if (bNum === 0) {
|
|
310
|
-
throw file_1.makeFileException(
|
|
310
|
+
throw (0, file_1.makeFileException)('endOfFile', '<file descriptor>');
|
|
311
311
|
}
|
|
312
312
|
bytesRead += bNum;
|
|
313
313
|
pos += bNum;
|
|
@@ -379,7 +379,7 @@ async function existsFolder(path) {
|
|
|
379
379
|
return true;
|
|
380
380
|
}
|
|
381
381
|
else {
|
|
382
|
-
throw file_1.makeFileException(
|
|
382
|
+
throw (0, file_1.makeFileException)('notDirectory', path);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
catch (e) {
|
|
@@ -396,11 +396,11 @@ exports.existsFolder = existsFolder;
|
|
|
396
396
|
*/
|
|
397
397
|
function existsFolderSync(path) {
|
|
398
398
|
try {
|
|
399
|
-
if (fs_1.statSync(path).isDirectory()) {
|
|
399
|
+
if ((0, fs_1.statSync)(path).isDirectory()) {
|
|
400
400
|
return true;
|
|
401
401
|
}
|
|
402
402
|
else {
|
|
403
|
-
throw file_1.makeFileException(
|
|
403
|
+
throw (0, file_1.makeFileException)('notDirectory', path);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
catch (e) {
|
|
@@ -417,11 +417,11 @@ exports.existsFolderSync = existsFolderSync;
|
|
|
417
417
|
*/
|
|
418
418
|
function existsFileSync(path) {
|
|
419
419
|
try {
|
|
420
|
-
if (fs_1.statSync(path).isFile()) {
|
|
420
|
+
if ((0, fs_1.statSync)(path).isFile()) {
|
|
421
421
|
return true;
|
|
422
422
|
}
|
|
423
423
|
else {
|
|
424
|
-
throw file_1.makeFileException(
|
|
424
|
+
throw (0, file_1.makeFileException)('notFile', path);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
catch (e) {
|
|
@@ -532,7 +532,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
532
532
|
let bytesWritten = 0;
|
|
533
533
|
let bytesRead = 0;
|
|
534
534
|
const buf = new bytes_fifo_buffer_1.BytesFIFOBuffer();
|
|
535
|
-
let deferred = deferred_1.defer();
|
|
535
|
+
let deferred = (0, deferred_1.defer)();
|
|
536
536
|
let doneReading = false;
|
|
537
537
|
const complete = (err) => {
|
|
538
538
|
if (!deferred) {
|
|
@@ -569,7 +569,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
569
569
|
if (!bytesToWrite) {
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
|
-
await writeToExistingFile(filePath, pos, buffer_utils_1.toBuffer(bytesToWrite));
|
|
572
|
+
await writeToExistingFile(filePath, pos, (0, buffer_utils_1.toBuffer)(bytesToWrite));
|
|
573
573
|
pos += bytesToWrite.length;
|
|
574
574
|
bytesWritten += bytesToWrite.length;
|
|
575
575
|
if (bytesWritten < len) {
|
|
@@ -586,7 +586,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
586
586
|
if (doneReading) {
|
|
587
587
|
return;
|
|
588
588
|
}
|
|
589
|
-
complete(file_1.makeFileException(
|
|
589
|
+
complete((0, file_1.makeFileException)('endOfFile', '<input stream>'));
|
|
590
590
|
});
|
|
591
591
|
src.on('error', (err) => {
|
|
592
592
|
complete(err);
|
|
@@ -614,7 +614,7 @@ async function read(fd, pos, buf) {
|
|
|
614
614
|
while (bytesRead < buf.length) {
|
|
615
615
|
const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
|
|
616
616
|
if (bNum === 0) {
|
|
617
|
-
throw file_1.makeFileException(
|
|
617
|
+
throw (0, file_1.makeFileException)('endOfFile', '<file descriptor>');
|
|
618
618
|
}
|
|
619
619
|
bytesRead += bNum;
|
|
620
620
|
pos += bNum;
|
|
@@ -729,8 +729,8 @@ exports.streamFromFile = streamFromFile;
|
|
|
729
729
|
*/
|
|
730
730
|
function copyFile(src, dst, overwrite = false, dstMode = '660') {
|
|
731
731
|
return new Promise((resolve, reject) => {
|
|
732
|
-
const srcStream = fs_1.createReadStream(src);
|
|
733
|
-
const dstStream = fs_1.createWriteStream(dst, {
|
|
732
|
+
const srcStream = (0, fs_1.createReadStream)(src);
|
|
733
|
+
const dstStream = (0, fs_1.createWriteStream)(dst, {
|
|
734
734
|
mode: parseInt(dstMode, 8),
|
|
735
735
|
flags: (overwrite ? 'w' : 'wx')
|
|
736
736
|
});
|
|
@@ -773,8 +773,8 @@ async function copyTree(src, dst, fileOverwrite = false) {
|
|
|
773
773
|
const srcFNames = await readdir(src);
|
|
774
774
|
const cpTasks = [];
|
|
775
775
|
for (const fName of srcFNames) {
|
|
776
|
-
const srcPath = path_1.join(src, fName);
|
|
777
|
-
const dstPath = path_1.join(dst, fName);
|
|
776
|
+
const srcPath = (0, path_1.join)(src, fName);
|
|
777
|
+
const dstPath = (0, path_1.join)(dst, fName);
|
|
778
778
|
const task = stat(srcPath)
|
|
779
779
|
.then((stats) => {
|
|
780
780
|
if (stats.isFile()) {
|
|
@@ -29,7 +29,7 @@ const sink_utils_1 = require("../obj-streaming/sink-utils");
|
|
|
29
29
|
* Default value is 64K.
|
|
30
30
|
*/
|
|
31
31
|
async function pipe(src, sink, progressCB = undefined, closeSink = true, bufSize = 64 * 1024) {
|
|
32
|
-
const contSink = sink_utils_1.makeContinuousSink(sink);
|
|
32
|
+
const contSink = (0, sink_utils_1.makeContinuousSink)(sink);
|
|
33
33
|
try {
|
|
34
34
|
let buf = await src.read(bufSize);
|
|
35
35
|
let bytesPiped = 0;
|
|
@@ -21,11 +21,11 @@ const synced_1 = require("../processes/synced");
|
|
|
21
21
|
function wrapAndSyncFileSink(sink) {
|
|
22
22
|
const syncProc = new synced_1.SingleProc();
|
|
23
23
|
const w = {
|
|
24
|
-
done: synced_1.makeSyncedFunc(syncProc, sink, sink.done),
|
|
25
|
-
getSize: synced_1.makeSyncedFunc(syncProc, sink, sink.getSize),
|
|
26
|
-
showLayout: synced_1.makeSyncedFunc(syncProc, sink, sink.showLayout),
|
|
27
|
-
splice: synced_1.makeSyncedFunc(syncProc, sink, sink.splice),
|
|
28
|
-
truncate: synced_1.makeSyncedFunc(syncProc, sink, sink.truncate)
|
|
24
|
+
done: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.done),
|
|
25
|
+
getSize: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.getSize),
|
|
26
|
+
showLayout: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.showLayout),
|
|
27
|
+
splice: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.splice),
|
|
28
|
+
truncate: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.truncate)
|
|
29
29
|
};
|
|
30
30
|
return w;
|
|
31
31
|
}
|
|
@@ -33,10 +33,10 @@ exports.wrapAndSyncFileSink = wrapAndSyncFileSink;
|
|
|
33
33
|
function wrapAndSyncSource(src) {
|
|
34
34
|
const syncProc = new synced_1.SingleProc();
|
|
35
35
|
const w = {
|
|
36
|
-
getPosition: synced_1.makeSyncedFunc(syncProc, src, src.getPosition),
|
|
37
|
-
getSize: synced_1.makeSyncedFunc(syncProc, src, src.getSize),
|
|
38
|
-
read: synced_1.makeSyncedFunc(syncProc, src, src.read),
|
|
39
|
-
seek: synced_1.makeSyncedFunc(syncProc, src, src.seek)
|
|
36
|
+
getPosition: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getPosition),
|
|
37
|
+
getSize: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getSize),
|
|
38
|
+
read: (0, synced_1.makeSyncedFunc)(syncProc, src, src.read),
|
|
39
|
+
seek: (0, synced_1.makeSyncedFunc)(syncProc, src, src.seek)
|
|
40
40
|
};
|
|
41
41
|
return w;
|
|
42
42
|
}
|
|
@@ -44,10 +44,10 @@ exports.wrapAndSyncSource = wrapAndSyncSource;
|
|
|
44
44
|
function wrapAndSyncFileSource(src) {
|
|
45
45
|
const syncProc = new synced_1.SingleProc();
|
|
46
46
|
const w = {
|
|
47
|
-
getPosition: synced_1.makeSyncedFunc(syncProc, src, src.getPosition),
|
|
48
|
-
getSize: synced_1.makeSyncedFunc(syncProc, src, src.getSize),
|
|
49
|
-
read: synced_1.makeSyncedFunc(syncProc, src, src.read),
|
|
50
|
-
seek: synced_1.makeSyncedFunc(syncProc, src, src.seek),
|
|
47
|
+
getPosition: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getPosition),
|
|
48
|
+
getSize: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getSize),
|
|
49
|
+
read: (0, synced_1.makeSyncedFunc)(syncProc, src, src.read),
|
|
50
|
+
seek: (0, synced_1.makeSyncedFunc)(syncProc, src, src.seek),
|
|
51
51
|
};
|
|
52
52
|
return w;
|
|
53
53
|
}
|
|
@@ -2,4 +2,5 @@ export interface ErrorWithCause extends Error {
|
|
|
2
2
|
cause: any;
|
|
3
3
|
}
|
|
4
4
|
export declare function errWithCause(cause: any, message: string): ErrorWithCause;
|
|
5
|
+
export declare function recursiveErrJSONify(err: web3n.RuntimeException): any;
|
|
5
6
|
export declare function stringifyErr(err: any): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 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
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.stringifyErr = exports.errWithCause = void 0;
|
|
18
|
+
exports.stringifyErr = exports.recursiveErrJSONify = exports.errWithCause = void 0;
|
|
19
19
|
function errWithCause(cause, message) {
|
|
20
20
|
const err = new Error(message);
|
|
21
21
|
err.cause = cause;
|
|
@@ -25,13 +25,13 @@ function errWithCause(cause, message) {
|
|
|
25
25
|
return err;
|
|
26
26
|
}
|
|
27
27
|
exports.errWithCause = errWithCause;
|
|
28
|
-
function
|
|
28
|
+
function recursiveErrJSONify(err) {
|
|
29
29
|
if (!err || (typeof err !== 'object') || Array.isArray(err)) {
|
|
30
30
|
return err;
|
|
31
31
|
}
|
|
32
32
|
else if (err.runtimeException) {
|
|
33
33
|
if (err.cause) {
|
|
34
|
-
err.cause =
|
|
34
|
+
err.cause = recursiveErrJSONify(err.cause);
|
|
35
35
|
}
|
|
36
36
|
return err;
|
|
37
37
|
}
|
|
@@ -41,16 +41,17 @@ function recursiveJSONify(err) {
|
|
|
41
41
|
stack: err.stack
|
|
42
42
|
};
|
|
43
43
|
if (err.cause) {
|
|
44
|
-
jsonErr.cause =
|
|
44
|
+
jsonErr.cause = recursiveErrJSONify(err.cause);
|
|
45
45
|
}
|
|
46
46
|
return jsonErr;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
exports.recursiveErrJSONify = recursiveErrJSONify;
|
|
49
50
|
function stringifyErr(err) {
|
|
50
51
|
if (!err) {
|
|
51
52
|
return '';
|
|
52
53
|
}
|
|
53
|
-
let json =
|
|
54
|
+
let json = recursiveErrJSONify(err);
|
|
54
55
|
let errStr;
|
|
55
56
|
if (!json || (typeof json !== 'object') || err.runtimeException) {
|
|
56
57
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare const Code: web3n.files.exceptionCode;
|
|
2
1
|
export declare type FileException = web3n.files.FileException;
|
|
3
|
-
export declare
|
|
2
|
+
export declare type FileExceptionFlag = web3n.files.FileExceptionFlag;
|
|
3
|
+
export declare const Code: web3n.files.exceptionCode;
|
|
4
|
+
export declare function makeFileExceptionFromCode(code: string | undefined, path: string, cause?: any): FileException;
|
|
5
|
+
export declare function makeFileException(flag: keyof FileExceptionFlag, path: string, cause?: any): FileException;
|
|
4
6
|
export declare function maskPathInExc(pathPrefixMaskLen: number, exc: any): FileException;
|
|
5
7
|
export declare function ensureCorrectFS(fs: web3n.files.FS, type: web3n.files.FSType, writable: boolean): void;
|
|
6
8
|
export declare function makeNoAttrsExc(path: string): FileException;
|
|
@@ -16,27 +16,26 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.Code = void 0;
|
|
19
|
+
exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.makeFileExceptionFromCode = exports.Code = void 0;
|
|
20
20
|
exports.Code = {
|
|
21
21
|
notFound: 'ENOENT',
|
|
22
22
|
alreadyExists: 'EEXIST',
|
|
23
23
|
notDirectory: 'ENOTDIR',
|
|
24
24
|
notFile: 'ENOTFILE',
|
|
25
|
-
notLink: 'not-link',
|
|
26
25
|
isDirectory: 'EISDIR',
|
|
27
26
|
notEmpty: 'ENOTEMPTY',
|
|
28
27
|
endOfFile: 'EEOF',
|
|
29
28
|
opNotPermitted: 'EPERM',
|
|
30
29
|
busy: 'EBUSY',
|
|
31
30
|
ioError: 'EIO',
|
|
32
|
-
concurrentUpdate: 'concurrent-update',
|
|
33
|
-
parsingError: 'parsing-error',
|
|
34
31
|
notImplemented: 'ENOSYS',
|
|
35
|
-
isEndless: 'is-endless',
|
|
36
|
-
storageClosed: 'storage-closed',
|
|
37
32
|
};
|
|
38
33
|
Object.freeze(exports.Code);
|
|
39
|
-
|
|
34
|
+
const codeToFlag = {};
|
|
35
|
+
for (const [flag, code] of Object.entries(exports.Code)) {
|
|
36
|
+
codeToFlag[code] = flag;
|
|
37
|
+
}
|
|
38
|
+
function makeFileExceptionFromCode(code, path, cause) {
|
|
40
39
|
const err = {
|
|
41
40
|
runtimeException: true,
|
|
42
41
|
type: 'file',
|
|
@@ -44,56 +43,27 @@ function makeFileException(code, path, cause) {
|
|
|
44
43
|
path,
|
|
45
44
|
cause
|
|
46
45
|
};
|
|
47
|
-
if (code
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
else if (code === exports.Code.isDirectory) {
|
|
54
|
-
err.isDirectory = true;
|
|
55
|
-
}
|
|
56
|
-
else if (code === exports.Code.notDirectory) {
|
|
57
|
-
err.notDirectory = true;
|
|
58
|
-
}
|
|
59
|
-
else if (code === exports.Code.notFile) {
|
|
60
|
-
err.notFile = true;
|
|
61
|
-
}
|
|
62
|
-
else if (code === exports.Code.notLink) {
|
|
63
|
-
err.notLink = true;
|
|
64
|
-
}
|
|
65
|
-
else if (code === exports.Code.endOfFile) {
|
|
66
|
-
err.endOfFile = true;
|
|
67
|
-
}
|
|
68
|
-
else if (code === exports.Code.busy) {
|
|
69
|
-
err.busy = true;
|
|
70
|
-
}
|
|
71
|
-
else if (code === exports.Code.ioError) {
|
|
72
|
-
err.ioError = true;
|
|
73
|
-
}
|
|
74
|
-
else if (code === exports.Code.notEmpty) {
|
|
75
|
-
err.notEmpty = true;
|
|
76
|
-
}
|
|
77
|
-
else if (code === exports.Code.opNotPermitted) {
|
|
78
|
-
err.opNotPermitted = true;
|
|
79
|
-
}
|
|
80
|
-
else if (code === exports.Code.concurrentUpdate) {
|
|
81
|
-
err.concurrentUpdate = true;
|
|
82
|
-
}
|
|
83
|
-
else if (code === exports.Code.parsingError) {
|
|
84
|
-
err.parsingError = true;
|
|
85
|
-
}
|
|
86
|
-
else if (code === exports.Code.notImplemented) {
|
|
87
|
-
err.notImplemented = true;
|
|
88
|
-
}
|
|
89
|
-
else if (code === exports.Code.isEndless) {
|
|
90
|
-
err.isEndless = true;
|
|
91
|
-
}
|
|
92
|
-
else if (code === exports.Code.storageClosed) {
|
|
93
|
-
err.storageClosed = true;
|
|
46
|
+
if (code) {
|
|
47
|
+
const flag = codeToFlag[code];
|
|
48
|
+
if (flag) {
|
|
49
|
+
err[flag] = true;
|
|
50
|
+
}
|
|
94
51
|
}
|
|
95
52
|
return err;
|
|
96
53
|
}
|
|
54
|
+
exports.makeFileExceptionFromCode = makeFileExceptionFromCode;
|
|
55
|
+
function makeFileException(flag, path, cause) {
|
|
56
|
+
const code = exports.Code[flag];
|
|
57
|
+
const err = {
|
|
58
|
+
runtimeException: true,
|
|
59
|
+
type: 'file',
|
|
60
|
+
code,
|
|
61
|
+
path,
|
|
62
|
+
cause
|
|
63
|
+
};
|
|
64
|
+
err[flag] = true;
|
|
65
|
+
return err;
|
|
66
|
+
}
|
|
97
67
|
exports.makeFileException = makeFileException;
|
|
98
68
|
function maskPathInExc(pathPrefixMaskLen, exc) {
|
|
99
69
|
if (!exc.runtimeException || !exc.code) {
|
|
@@ -278,11 +278,12 @@ function makeRequestServer(channel, comm) {
|
|
|
278
278
|
return (new ReplyingSide(channel, comm)).wrap();
|
|
279
279
|
}
|
|
280
280
|
exports.makeRequestServer = makeRequestServer;
|
|
281
|
-
function makeUnknownEventException() {
|
|
281
|
+
function makeUnknownEventException(message) {
|
|
282
282
|
return {
|
|
283
283
|
runtimeException: true,
|
|
284
284
|
type: 'events',
|
|
285
|
-
unknownEvent: true
|
|
285
|
+
unknownEvent: true,
|
|
286
|
+
message
|
|
286
287
|
};
|
|
287
288
|
}
|
|
288
289
|
const SUBSCRIBE_REQ_NAME = 'subscribe';
|
|
@@ -307,7 +308,7 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
307
308
|
const event = env.req;
|
|
308
309
|
const gr = this.findGroup(event);
|
|
309
310
|
if (!gr) {
|
|
310
|
-
throw makeUnknownEventException();
|
|
311
|
+
throw makeUnknownEventException(`Events' channel ${event} is not found in handling subscribe`);
|
|
311
312
|
}
|
|
312
313
|
this.subscribedEvents.add(event);
|
|
313
314
|
await gr.subscribe(event);
|
|
@@ -316,7 +317,7 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
316
317
|
const event = env.req;
|
|
317
318
|
const gr = this.findGroup(event);
|
|
318
319
|
if (!gr) {
|
|
319
|
-
throw makeUnknownEventException();
|
|
320
|
+
throw makeUnknownEventException(`Events' channel ${event} is not found in handling unsubscribe`);
|
|
320
321
|
}
|
|
321
322
|
this.subscribedEvents.delete(event);
|
|
322
323
|
if (gr.unsubscribe) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.makeSubscriber = void 0;
|
|
18
|
+
exports.makeSubscriber = exports.makeEventfulServer = void 0;
|
|
19
19
|
const generic_ipc_1 = require("./generic-ipc");
|
|
20
20
|
var generic_ipc_2 = require("./generic-ipc");
|
|
21
21
|
Object.defineProperty(exports, "makeEventfulServer", { enumerable: true, get: function () { return generic_ipc_2.makeEventfulServer; } });
|
|
@@ -111,7 +111,7 @@ function onError(ws, observers) {
|
|
|
111
111
|
}
|
|
112
112
|
function makeSubscriber(ws, ipcChannel) {
|
|
113
113
|
const comm = makeJsonCommPoint(ws);
|
|
114
|
-
return generic_ipc_1.makeSubscribingClient(ipcChannel, comm);
|
|
114
|
+
return (0, generic_ipc_1.makeSubscribingClient)(ipcChannel, comm);
|
|
115
115
|
}
|
|
116
116
|
exports.makeSubscriber = makeSubscriber;
|
|
117
117
|
Object.freeze(exports);
|