core-3nweb-client-lib 0.43.9 → 0.43.12

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.
Files changed (58) hide show
  1. package/build/api-defs/files.d.ts +32 -8
  2. package/build/api-defs/web3n.d.ts +2 -0
  3. package/build/core/asmail/inbox/index.js +1 -1
  4. package/build/core/asmail/inbox/msg-downloader.d.ts +2 -12
  5. package/build/core/asmail/inbox/msg-downloader.js +13 -46
  6. package/build/core/storage/synced/downloader.d.ts +6 -15
  7. package/build/core/storage/synced/downloader.js +25 -48
  8. package/build/core/storage/synced/obj-files.d.ts +4 -2
  9. package/build/core/storage/synced/obj-files.js +7 -7
  10. package/build/core/storage/synced/storage.d.ts +4 -2
  11. package/build/core/storage/synced/storage.js +2 -2
  12. package/build/core/storage/synced/upsyncer.d.ts +2 -4
  13. package/build/core/storage/synced/upsyncer.js +19 -13
  14. package/build/core-ipc/file.d.ts +10 -0
  15. package/build/core-ipc/file.js +23 -13
  16. package/build/core-ipc/fs.js +15 -8
  17. package/build/lib-client/3nstorage/storage-owner.js +36 -29
  18. package/build/lib-client/3nweb-signup.js +7 -7
  19. package/build/lib-client/asmail/recipient.js +14 -11
  20. package/build/lib-client/asmail/sender.js +24 -25
  21. package/build/lib-client/asmail/service-config.js +3 -6
  22. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  23. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  24. package/build/lib-client/fs-utils/files.js +4 -4
  25. package/build/lib-client/mailer-id/login.js +7 -7
  26. package/build/lib-client/mailer-id/provisioner.js +9 -7
  27. package/build/lib-client/objs-on-disk/file-writing-proc.d.ts +1 -1
  28. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +51 -3
  29. package/build/lib-client/objs-on-disk/obj-on-disk.js +414 -34
  30. package/build/lib-client/request-utils.d.ts +0 -7
  31. package/build/lib-client/request-utils.js +16 -11
  32. package/build/lib-client/service-locator.js +11 -8
  33. package/build/lib-client/user-with-mid-session.js +2 -6
  34. package/build/lib-client/user-with-pkl-session.js +25 -24
  35. package/build/lib-client/xsp-fs/common.d.ts +8 -3
  36. package/build/lib-client/xsp-fs/common.js +1 -1
  37. package/build/lib-client/xsp-fs/file.d.ts +3 -1
  38. package/build/lib-client/xsp-fs/file.js +4 -4
  39. package/build/lib-client/xsp-fs/folder-node.d.ts +1 -1
  40. package/build/lib-client/xsp-fs/folder-node.js +4 -4
  41. package/build/lib-client/xsp-fs/fs.d.ts +3 -1
  42. package/build/lib-client/xsp-fs/fs.js +4 -4
  43. package/build/lib-client/xsp-fs/node-in-fs.d.ts +6 -4
  44. package/build/lib-client/xsp-fs/node-in-fs.js +14 -9
  45. package/build/lib-common/buffer-utils.js +4 -1
  46. package/build/lib-common/exceptions/http.d.ts +11 -1
  47. package/build/lib-common/exceptions/http.js +10 -2
  48. package/build/lib-common/objs-on-disk/utils.d.ts +1 -1
  49. package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
  50. package/build/lib-common/processes/labelled-exec-pools.js +8 -2
  51. package/build/protos/asmail.proto.js +545 -116
  52. package/build/protos/file.proto.js +485 -56
  53. package/build/protos/fs.proto.js +545 -116
  54. package/package.json +1 -1
  55. package/protos/file.proto +8 -2
  56. package/protos/fs.proto +3 -3
  57. /package/build/lib-common/objs-on-disk/{obj-file.d.ts → obj-version-file.d.ts} +0 -0
  58. /package/build/lib-common/objs-on-disk/{obj-file.js → obj-version-file.js} +0 -0
@@ -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.vListVersions = exports.vsUpload = exports.vsStartUpload = exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.vStat = exports.readBytes = exports.fileMsgType = void 0;
19
+ exports.vListVersions = exports.vsUpload = exports.vsStartUpload = exports.vsStartDownload = exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.vStat = exports.readBytes = exports.fileMsgType = void 0;
20
20
  exports.makeFileCaller = makeFileCaller;
21
21
  exports.exposeFileService = exposeFileService;
22
22
  exports.packStats = packStats;
@@ -98,7 +98,7 @@ function makeFileCaller(caller, fileMsg) {
98
98
  file.v.sync = {
99
99
  status: vsStatus.makeCaller(caller, vsPath),
100
100
  isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.makeCaller(caller, vsPath),
101
- download: vsDownload.makeCaller(caller, vsPath),
101
+ startDownload: vsStartDownload.makeCaller(caller, vsPath),
102
102
  adoptRemote: vsAdoptRemote.makeCaller(caller, vsPath),
103
103
  };
104
104
  if (file.writable) {
@@ -153,7 +153,7 @@ function exposeFileService(file, expServices) {
153
153
  implExp.v.sync = {
154
154
  status: vsStatus.wrapService(file.v.sync.status),
155
155
  isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.wrapService(file.v.sync.isRemoteVersionOnDisk),
156
- download: vsDownload.wrapService(file.v.sync.download),
156
+ startDownload: vsStartDownload.wrapService(file.v.sync.startDownload),
157
157
  adoptRemote: vsAdoptRemote.wrapService(file.v.sync.adoptRemote),
158
158
  };
159
159
  if (file.writable) {
@@ -1119,25 +1119,35 @@ var vsIsRemoteVersionOnDisk;
1119
1119
  vsIsRemoteVersionOnDisk.makeCaller = makeCaller;
1120
1120
  })(vsIsRemoteVersionOnDisk || (vsIsRemoteVersionOnDisk = {}));
1121
1121
  Object.freeze(vsIsRemoteVersionOnDisk);
1122
- var vsDownload;
1123
- (function (vsDownload) {
1124
- const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncDownloadRequestBody);
1122
+ var vsStartDownload;
1123
+ (function (vsStartDownload) {
1124
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncStartDownloadRequestBody);
1125
+ vsStartDownload.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncStartDownloadReplyBody);
1125
1126
  function wrapService(fn) {
1126
1127
  return buf => {
1127
1128
  const { version } = requestType.unpack(buf);
1128
- const promise = fn((0, protobuf_msg_1.fixInt)(version));
1129
+ const promise = fn((0, protobuf_msg_1.fixInt)(version))
1130
+ .then(startedDownload => vsStartDownload.replyType.pack({ startedDownload }));
1129
1131
  return { promise };
1130
1132
  };
1131
1133
  }
1132
- vsDownload.wrapService = wrapService;
1134
+ vsStartDownload.wrapService = wrapService;
1133
1135
  function makeCaller(caller, objPath) {
1134
- const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'download');
1136
+ const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'startDownload');
1135
1137
  return version => caller
1136
- .startPromiseCall(path, requestType.pack({ version }));
1138
+ .startPromiseCall(path, requestType.pack({ version }))
1139
+ .then(buf => {
1140
+ const { startedDownload } = vsStartDownload.replyType.unpack(buf);
1141
+ if (startedDownload) {
1142
+ return {
1143
+ downloadTaskId: (0, protobuf_msg_1.fixInt)(startedDownload.downloadTaskId)
1144
+ };
1145
+ }
1146
+ });
1137
1147
  }
1138
- vsDownload.makeCaller = makeCaller;
1139
- })(vsDownload || (vsDownload = {}));
1140
- Object.freeze(vsDownload);
1148
+ vsStartDownload.makeCaller = makeCaller;
1149
+ })(vsStartDownload || (exports.vsStartDownload = vsStartDownload = {}));
1150
+ Object.freeze(vsStartDownload);
1141
1151
  function optionsToUploadLocalToMsg(opts) {
1142
1152
  if (!opts) {
1143
1153
  return;
@@ -105,7 +105,7 @@ function makeFSCaller(caller, fsMsg) {
105
105
  fs.v.sync = {
106
106
  status: vsStatus.makeCaller(caller, vsPath),
107
107
  isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.makeCaller(caller, vsPath),
108
- download: vsDownload.makeCaller(caller, vsPath),
108
+ startDownload: vsDownload.makeCaller(caller, vsPath),
109
109
  adoptRemote: vsAdoptRemote.makeCaller(caller, vsPath),
110
110
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.makeCaller(caller, vsPath)
111
111
  };
@@ -184,7 +184,7 @@ function exposeFSService(fs, expServices) {
184
184
  implExp.v.sync = {
185
185
  status: vsStatus.wrapService(fs.v.sync.status),
186
186
  isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.wrapService(fs.v.sync.isRemoteVersionOnDisk),
187
- download: vsDownload.wrapService(fs.v.sync.download),
187
+ startDownload: vsDownload.wrapService(fs.v.sync.startDownload),
188
188
  adoptRemote: vsAdoptRemote.wrapService(fs.v.sync.adoptRemote),
189
189
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.wrapService(fs.v.sync.diffCurrentAndRemoteFolderVersions)
190
190
  };
@@ -1829,21 +1829,28 @@ var vsIsRemoteVersionOnDisk;
1829
1829
  Object.freeze(vsIsRemoteVersionOnDisk);
1830
1830
  var vsDownload;
1831
1831
  (function (vsDownload) {
1832
- const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncDownloadRequestBody);
1832
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncStartDownloadRequestBody);
1833
1833
  function wrapService(fn) {
1834
1834
  return buf => {
1835
1835
  const { path, version } = requestType.unpack(buf);
1836
- const promise = fn(path, (0, protobuf_msg_1.fixInt)(version));
1836
+ const promise = fn(path, (0, protobuf_msg_1.fixInt)(version))
1837
+ .then(startedDownload => file.vsStartDownload.replyType.pack({ startedDownload }));
1837
1838
  return { promise };
1838
1839
  };
1839
1840
  }
1840
1841
  vsDownload.wrapService = wrapService;
1841
1842
  function makeCaller(caller, objPath) {
1842
- const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'download');
1843
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'startDownload');
1843
1844
  return (path, version) => caller
1844
- .startPromiseCall(ipcPath, requestType.pack({
1845
- path, version
1846
- }));
1845
+ .startPromiseCall(ipcPath, requestType.pack({ path, version }))
1846
+ .then(buf => {
1847
+ const { startedDownload } = file.vsStartDownload.replyType.unpack(buf);
1848
+ if (startedDownload) {
1849
+ return {
1850
+ downloadTaskId: (0, protobuf_msg_1.fixInt)(startedDownload.downloadTaskId)
1851
+ };
1852
+ }
1853
+ });
1847
1854
  }
1848
1855
  vsDownload.makeCaller = makeCaller;
1849
1856
  })(vsDownload || (vsDownload = {}));
@@ -25,6 +25,7 @@ const keyGen = require("../key-derivation");
25
25
  const exceptions_1 = require("../xsp-fs/exceptions");
26
26
  const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
27
27
  const assert_1 = require("../../lib-common/assert");
28
+ const http_1 = require("../../lib-common/exceptions/http");
28
29
  const storageAccessParams = {
29
30
  login: api.midLogin.MID_URL_PART,
30
31
  logout: api.closeSession.URL_END,
@@ -54,11 +55,13 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
54
55
  responseType: 'json'
55
56
  });
56
57
  if (rep.status !== api.sessionParams.SC.ok) {
57
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
58
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
58
59
  }
59
60
  const keyDerivParams = rep.data;
60
61
  if (!keyGen.checkParams(rep.data)) {
61
- throw (0, request_utils_1.makeException)(rep, 'Malformed response');
62
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, {
63
+ message: `expected key generation parameters form isn't there`
64
+ });
62
65
  }
63
66
  return keyDerivParams;
64
67
  }
@@ -69,11 +72,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
69
72
  responseType: 'json'
70
73
  });
71
74
  if (rep.status !== api.sessionParams.SC.ok) {
72
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
75
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
73
76
  }
74
- if ((typeof rep.data.maxChunkSize !== 'number') ||
75
- (rep.data.maxChunkSize < 64 * 1024)) {
76
- throw (0, request_utils_1.makeException)(rep, 'Malformed response');
77
+ if ((typeof rep.data.maxChunkSize !== 'number') || (rep.data.maxChunkSize < 64 * 1024)) {
78
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'bad maxChunkSize value in reply' });
77
79
  }
78
80
  this.maxChunkSize = rep.data.maxChunkSize;
79
81
  }
@@ -104,7 +106,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
104
106
  throw (0, exceptions_1.makeUnknownTransactionExc)(objId);
105
107
  }
106
108
  else {
107
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
109
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
108
110
  }
109
111
  }
110
112
  /**
@@ -126,30 +128,32 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
126
128
  appPath,
127
129
  method: 'GET',
128
130
  responseType: 'arraybuffer',
129
- responseHeaders: [api.HTTP_HEADER.objVersion,
130
- api.HTTP_HEADER.objSegmentsLength, api.HTTP_HEADER.objHeaderLength]
131
+ responseHeaders: [
132
+ api.HTTP_HEADER.objVersion, api.HTTP_HEADER.objSegmentsLength, api.HTTP_HEADER.objHeaderLength
133
+ ]
131
134
  });
132
135
  if (rep.status === api.currentObj.SC.okGet) {
133
- if (!(rep.data instanceof Uint8Array)) {
134
- throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
136
+ const bytes = rep.data;
137
+ if (!(bytes instanceof Uint8Array)) {
138
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is not binary` });
135
139
  }
136
140
  const version = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objVersion);
137
141
  const segsTotalLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objSegmentsLength);
138
142
  const headerLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objHeaderLength);
139
- if (rep.data.length > (headerLen + segsTotalLen)) {
140
- throw (0, request_utils_1.makeException)(rep, `Malformed response: body is too long`);
143
+ if (bytes.length > (headerLen + segsTotalLen)) {
144
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is too long` });
141
145
  }
142
146
  return {
143
147
  version, segsTotalLen,
144
- header: rep.data.subarray(0, headerLen),
145
- segsChunk: rep.data.subarray(headerLen)
148
+ header: bytes.subarray(0, headerLen),
149
+ segsChunk: bytes.subarray(headerLen)
146
150
  };
147
151
  }
148
152
  else if (rep.status === api.currentObj.SC.unknownObj) {
149
153
  throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
150
154
  }
151
155
  else {
152
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
156
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
153
157
  }
154
158
  }
155
159
  /**
@@ -166,25 +170,28 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
166
170
  }
167
171
  const limit = end - start;
168
172
  const opts = { ofs: start, limit, ver: version };
169
- const appPath = (objId ?
170
- api.currentObj.getReqUrlEnd(objId, opts) :
171
- api.currentRootObj.getReqUrlEnd(opts));
172
173
  const rep = await this.doBodylessSessionRequest({
173
- appPath,
174
+ appPath: (objId ?
175
+ api.currentObj.getReqUrlEnd(objId, opts) :
176
+ api.currentRootObj.getReqUrlEnd(opts)),
174
177
  method: 'GET',
175
178
  responseType: 'arraybuffer',
176
179
  });
177
180
  if (rep.status === api.currentObj.SC.okGet) {
178
- if (!(rep.data instanceof Uint8Array)) {
179
- throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
181
+ const chunk = rep.data;
182
+ if (!(chunk instanceof Uint8Array)) {
183
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is not binary` });
180
184
  }
181
- return rep.data;
185
+ if (chunk.length > limit) {
186
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is too long` });
187
+ }
188
+ return chunk;
182
189
  }
183
190
  else if (rep.status === api.currentObj.SC.unknownObj) {
184
191
  throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
185
192
  }
186
193
  else {
187
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
194
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
188
195
  }
189
196
  }
190
197
  /**
@@ -264,7 +271,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
264
271
  throw (0, exceptions_1.makeVersionMismatchExc)(objId, curVer);
265
272
  }
266
273
  else {
267
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
274
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
268
275
  }
269
276
  }
270
277
  async archiveObjVersion(objId, currentVer) {
@@ -284,7 +291,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
284
291
  throw (0, exceptions_1.makeObjVersionNotFoundExc)(objId, currentVer, true);
285
292
  }
286
293
  else {
287
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
294
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
288
295
  }
289
296
  }
290
297
  async getObjStatus(objId) {
@@ -303,7 +310,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
303
310
  throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
304
311
  }
305
312
  else {
306
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
313
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
307
314
  }
308
315
  }
309
316
  /**
@@ -326,7 +333,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
326
333
  throw (0, exceptions_1.makeConcurrentTransExc)(objId);
327
334
  }
328
335
  else {
329
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
336
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
330
337
  }
331
338
  }
332
339
  async openEventSource() {
@@ -335,7 +342,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
335
342
  return (0, ws_ipc_1.makeSubscriber)(rep.data, undefined);
336
343
  }
337
344
  else {
338
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
345
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
339
346
  }
340
347
  }
341
348
  }
@@ -20,8 +20,8 @@ exports.checkAvailableDomains = checkAvailableDomains;
20
20
  exports.checkAvailableAddressesForName = checkAvailableAddressesForName;
21
21
  exports.addUser = addUser;
22
22
  exports.sendActivationCheckRequest = sendActivationCheckRequest;
23
- const request_utils_1 = require("./request-utils");
24
23
  const api = require("../lib-common/user-admin-api/signup");
24
+ const http_1 = require("../lib-common/exceptions/http");
25
25
  async function checkAvailableDomains(client, serviceUrl, signupToken) {
26
26
  const reqData = { signupToken };
27
27
  const rep = await client.doJsonRequest({
@@ -34,11 +34,11 @@ async function checkAvailableDomains(client, serviceUrl, signupToken) {
34
34
  return rep.data;
35
35
  }
36
36
  else {
37
- throw (0, request_utils_1.makeException)(rep, 'Reply is malformed');
37
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep);
38
38
  }
39
39
  }
40
40
  else {
41
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
41
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
42
42
  }
43
43
  }
44
44
  async function checkAvailableAddressesForName(client, serviceUrl, name, signupToken) {
@@ -55,11 +55,11 @@ async function checkAvailableAddressesForName(client, serviceUrl, name, signupTo
55
55
  return rep.data;
56
56
  }
57
57
  else {
58
- throw (0, request_utils_1.makeException)(rep, 'Reply is malformed');
58
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep);
59
59
  }
60
60
  }
61
61
  else {
62
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
62
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
63
63
  }
64
64
  }
65
65
  async function addUser(client, serviceUrl, userParams) {
@@ -76,7 +76,7 @@ async function addUser(client, serviceUrl, userParams) {
76
76
  return false;
77
77
  }
78
78
  else {
79
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
79
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
80
80
  }
81
81
  }
82
82
  async function sendActivationCheckRequest(client, serviceUrl, userId) {
@@ -95,7 +95,7 @@ async function sendActivationCheckRequest(client, serviceUrl, userId) {
95
95
  return false;
96
96
  }
97
97
  else {
98
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
98
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
99
99
  }
100
100
  }
101
101
  Object.freeze(exports);
@@ -25,6 +25,7 @@ const api = require("../../lib-common/service-api/asmail/retrieval");
25
25
  const user_with_mid_session_1 = require("../user-with-mid-session");
26
26
  const service_locator_1 = require("../service-locator");
27
27
  const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
28
+ const http_1 = require("../../lib-common/exceptions/http");
28
29
  function makeMsgNotFoundException(msgId) {
29
30
  const exc = {
30
31
  runtimeException: true,
@@ -74,12 +75,12 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
74
75
  });
75
76
  if (rep.status === api.listMsgs.SC.ok) {
76
77
  if (!Array.isArray(rep.data)) {
77
- throw (0, request_utils_1.makeException)(rep, 'Malformed response');
78
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep);
78
79
  }
79
80
  return rep.data;
80
81
  }
81
82
  else {
82
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
83
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
83
84
  }
84
85
  }
85
86
  async getMsgMeta(msgId) {
@@ -91,7 +92,9 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
91
92
  if (rep.status === api.msgMetadata.SC.ok) {
92
93
  const { meta, errMsg } = api.sanitizedMeta(rep.data);
93
94
  if (!meta) {
94
- throw (0, request_utils_1.makeException)(rep, `Malformed message metadata in a server response: ${errMsg}`);
95
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, {
96
+ message: `Malformed message metadata in a server response: ${errMsg}`
97
+ });
95
98
  }
96
99
  return meta;
97
100
  }
@@ -99,7 +102,7 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
99
102
  throw makeMsgNotFoundException(msgId);
100
103
  }
101
104
  else {
102
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
105
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
103
106
  }
104
107
  }
105
108
  /**
@@ -124,12 +127,12 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
124
127
  });
125
128
  if (rep.status === api.msgObj.SC.ok) {
126
129
  if (!(rep.data instanceof Uint8Array)) {
127
- throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
130
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is not binary` });
128
131
  }
129
132
  const segsTotalLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objSegmentsLength);
130
133
  const headerLen = (0, request_utils_1.extractIntHeader)(rep, api.HTTP_HEADER.objHeaderLength);
131
134
  if (rep.data.length > (headerLen + segsTotalLen)) {
132
- throw (0, request_utils_1.makeException)(rep, `Malformed response: body is too long`);
135
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is too long` });
133
136
  }
134
137
  return {
135
138
  segsTotalLen,
@@ -141,7 +144,7 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
141
144
  throw makeObjNotFoundException(msgId, objId);
142
145
  }
143
146
  else {
144
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
147
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
145
148
  }
146
149
  }
147
150
  /**
@@ -165,7 +168,7 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
165
168
  });
166
169
  if (rep.status === api.msgObj.SC.ok) {
167
170
  if (!(rep.data instanceof Uint8Array)) {
168
- throw (0, request_utils_1.makeException)(rep, `Malformed response: body is not binary`);
171
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: `body is not binary` });
169
172
  }
170
173
  return rep.data;
171
174
  }
@@ -173,7 +176,7 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
173
176
  throw makeObjNotFoundException(msgId, objId);
174
177
  }
175
178
  else {
176
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
179
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
177
180
  }
178
181
  }
179
182
  async removeMsg(msgId) {
@@ -188,7 +191,7 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
188
191
  throw makeMsgNotFoundException(msgId);
189
192
  }
190
193
  else {
191
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
194
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
192
195
  }
193
196
  }
194
197
  async openEventSource() {
@@ -197,7 +200,7 @@ class MailRecipient extends user_with_mid_session_1.ServiceUser {
197
200
  return (0, ws_ipc_1.makeSubscriber)(rep.data, undefined);
198
201
  }
199
202
  else {
200
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
203
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
201
204
  }
202
205
  }
203
206
  }
@@ -16,13 +16,10 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>. */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.MailSender = void 0;
19
- /**
20
- * This defines functions that implement ASMail delivery protocol.
21
- */
22
- const request_utils_1 = require("../request-utils");
23
19
  const api = require("../../lib-common/service-api/asmail/delivery");
24
20
  const service_locator_1 = require("../service-locator");
25
21
  const url_1 = require("url");
22
+ const http_1 = require("../../lib-common/exceptions/http");
26
23
  const LIMIT_ON_MAX_CHUNK = 1024 * 1024;
27
24
  const TOO_EARLY_RESTART_PERIOD = 5 * 60 * 1000;
28
25
  class MailSender {
@@ -195,10 +192,10 @@ class MailSender {
195
192
  }, reqData);
196
193
  if (rep.status === api.preFlight.SC.ok) {
197
194
  if (typeof rep.data.maxMsgLength !== 'number') {
198
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: missing number maxMsgLength');
195
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'missing number maxMsgLength' });
199
196
  }
200
197
  if (rep.data.maxMsgLength < 500) {
201
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: maxMsgLength is too short');
198
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'maxMsgLength is too short' });
202
199
  }
203
200
  this.maxMsgLength = rep.data.maxMsgLength;
204
201
  return rep.data;
@@ -217,7 +214,7 @@ class MailSender {
217
214
  throw this.inboxIsFullExc();
218
215
  }
219
216
  else {
220
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
217
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
221
218
  }
222
219
  }
223
220
  /**
@@ -245,14 +242,14 @@ class MailSender {
245
242
  }, reqData);
246
243
  if (rep.status == api.sessionStart.SC.ok) {
247
244
  if (typeof rep.data.maxMsgLength !== 'number') {
248
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: missing number maxMsgLength');
245
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'missing number maxMsgLength' });
249
246
  }
250
247
  if (rep.data.maxMsgLength < 500) {
251
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: maxMsgLength is too short');
248
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'maxMsgLength is too short' });
252
249
  }
253
250
  this.maxMsgLength = rep.data.maxMsgLength;
254
251
  if ('string' !== typeof rep.data.sessionId) {
255
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: missing sessionId string');
252
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'missing sessionId string' });
256
253
  }
257
254
  this.sessionId = rep.data.sessionId;
258
255
  delete rep.data.sessionId;
@@ -272,7 +269,7 @@ class MailSender {
272
269
  throw this.inboxIsFullExc();
273
270
  }
274
271
  else {
275
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
272
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
276
273
  }
277
274
  }
278
275
  async restartSession() {
@@ -290,14 +287,14 @@ class MailSender {
290
287
  }, reqData);
291
288
  if (rep.status == api.sessionRestart.SC.ok) {
292
289
  if (typeof rep.data.maxMsgLength !== 'number') {
293
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: missing number maxMsgLength');
290
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'missing number maxMsgLength' });
294
291
  }
295
292
  if (rep.data.maxMsgLength < 500) {
296
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: maxMsgLength is too short');
293
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'maxMsgLength is too short' });
297
294
  }
298
295
  this.maxMsgLength = rep.data.maxMsgLength;
299
296
  if (typeof rep.data.sessionId !== 'string') {
300
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: missing sessionId string');
297
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'missing sessionId string' });
301
298
  }
302
299
  this.sessionId = rep.data.sessionId;
303
300
  if ((typeof rep.data.maxChunkSize === 'number') &&
@@ -314,7 +311,7 @@ class MailSender {
314
311
  throw this.unknownRecipientExc();
315
312
  }
316
313
  else {
317
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
314
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
318
315
  }
319
316
  }
320
317
  /**
@@ -344,7 +341,7 @@ class MailSender {
344
341
  throw this.authFailedOnDeliveryExc();
345
342
  }
346
343
  else {
347
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
344
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
348
345
  }
349
346
  }
350
347
  /**
@@ -369,7 +366,7 @@ class MailSender {
369
366
  throw this.recipientHasNoPubKeyExc();
370
367
  }
371
368
  else {
372
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
369
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
373
370
  }
374
371
  }
375
372
  /**
@@ -389,14 +386,14 @@ class MailSender {
389
386
  responseType: 'json'
390
387
  }, meta);
391
388
  if (rep.status == api.msgMeta.SC.ok) {
392
- if (('string' !== typeof rep.data.msgId) ||
393
- (rep.data.msgId.length === 0)) {
394
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: msgId string is missing');
389
+ if (('string' !== typeof rep.data.msgId)
390
+ || (rep.data.msgId.length === 0)) {
391
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'msgId string is missing' });
395
392
  }
396
393
  this.msgId = rep.data.msgId;
397
394
  if (typeof rep.data.maxChunkSize === 'number') {
398
395
  if (rep.data.maxChunkSize < 64 * 1024) {
399
- throw (0, request_utils_1.makeException)(rep, 'Malformed reply: maxChunkSize is too small');
396
+ throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'maxChunkSize is too small' });
400
397
  }
401
398
  else if (rep.data.maxChunkSize < this.maxChunkSize) {
402
399
  this.maxChunkSize = rep.data.maxChunkSize;
@@ -411,7 +408,7 @@ class MailSender {
411
408
  };
412
409
  }
413
410
  else {
414
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
411
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
415
412
  }
416
413
  }
417
414
  async trySessionRestart() {
@@ -449,7 +446,9 @@ class MailSender {
449
446
  return this.sendObj(objId, bytes, fstReq, followReq);
450
447
  }
451
448
  else {
452
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status, when session restart is not expected to happen');
449
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep, {
450
+ message: 'Unexpected status, when session restart is not expected to happen'
451
+ });
453
452
  }
454
453
  }
455
454
  else if (rep.status === api.msgObj.SC.ok) {
@@ -457,7 +456,7 @@ class MailSender {
457
456
  return;
458
457
  }
459
458
  else {
460
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
459
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
461
460
  }
462
461
  }
463
462
  /**
@@ -473,7 +472,7 @@ class MailSender {
473
472
  this.sessionId = undefined;
474
473
  }
475
474
  else {
476
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
475
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
477
476
  }
478
477
  }
479
478
  async cancelDelivery() {
@@ -16,13 +16,10 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>. */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.MailConfigurator = void 0;
19
- /**
20
- * This defines functions that implement ASMail configuration protocol.
21
- */
22
- const request_utils_1 = require("../request-utils");
23
19
  const api = require("../../lib-common/service-api/asmail/config");
24
20
  const user_with_mid_session_1 = require("../user-with-mid-session");
25
21
  const service_locator_1 = require("../service-locator");
22
+ const http_1 = require("../../lib-common/exceptions/http");
26
23
  const configAccessParams = {
27
24
  login: api.midLogin.MID_URL_PART,
28
25
  logout: api.closeSession.URL_END,
@@ -41,7 +38,7 @@ class MailConfigurator extends user_with_mid_session_1.ServiceUser {
41
38
  responseType: 'json'
42
39
  });
43
40
  if (rep.status !== api.PARAM_SC.ok) {
44
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
41
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
45
42
  }
46
43
  return rep.data;
47
44
  }
@@ -52,7 +49,7 @@ class MailConfigurator extends user_with_mid_session_1.ServiceUser {
52
49
  method: 'PUT',
53
50
  }, value);
54
51
  if (rep.status !== api.PARAM_SC.ok) {
55
- throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
52
+ throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
56
53
  }
57
54
  }
58
55
  makeParamSetterAndGetter(param) {