spec-3nweb-server 1.8.6 → 1.8.7

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 (54) hide show
  1. package/build/3nstorage/resources/store.d.ts +2 -2
  2. package/build/3nstorage/resources/store.js +1 -1
  3. package/build/3nstorage/resources/users.d.ts +3 -3
  4. package/build/3nstorage/resources/users.js +1 -1
  5. package/build/3nstorage/resources/utils.d.ts +6 -0
  6. package/build/3nstorage/resources/utils.js +41 -0
  7. package/build/3nstorage/routes/owner/archive-obj-version.js +8 -10
  8. package/build/3nstorage/routes/owner/cancel-trans.js +5 -4
  9. package/build/3nstorage/routes/owner/delete-obj.js +7 -8
  10. package/build/3nstorage/routes/owner/get-archived-obj-ver.js +11 -13
  11. package/build/3nstorage/routes/owner/get-current-obj.js +7 -6
  12. package/build/3nstorage/routes/owner/get-obj-status.js +8 -8
  13. package/build/3nstorage/routes/owner/put-current-obj.js +25 -55
  14. package/build/3nstorage/routes/owner/session-params.js +2 -0
  15. package/build/asmail/resources/utils.d.ts +6 -0
  16. package/build/asmail/resources/utils.js +36 -0
  17. package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
  18. package/build/asmail/routes/delivery/pre-flight.js +9 -26
  19. package/build/asmail/routes/delivery/provide-recipient-pubkey.js +4 -3
  20. package/build/asmail/routes/delivery/put-metadata.js +13 -21
  21. package/build/asmail/routes/delivery/put-obj.js +19 -25
  22. package/build/asmail/routes/delivery/restart-session.d.ts +4 -8
  23. package/build/asmail/routes/delivery/restart-session.js +10 -23
  24. package/build/asmail/routes/delivery/sender-authorization.js +5 -5
  25. package/build/asmail/routes/delivery/start-session.js +9 -24
  26. package/build/asmail/routes/retrieval/get-message-meta.js +4 -7
  27. package/build/asmail/routes/retrieval/get-message-obj.js +10 -7
  28. package/build/asmail/routes/retrieval/list-messages.js +4 -4
  29. package/build/asmail/routes/retrieval/remove-message.js +3 -2
  30. package/package.json +1 -1
  31. package/ts-code/3nstorage/resources/store.ts +3 -3
  32. package/ts-code/3nstorage/resources/users.ts +5 -5
  33. package/ts-code/3nstorage/resources/utils.ts +45 -0
  34. package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +8 -10
  35. package/ts-code/3nstorage/routes/owner/cancel-trans.ts +5 -3
  36. package/ts-code/3nstorage/routes/owner/delete-obj.ts +9 -13
  37. package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +13 -15
  38. package/ts-code/3nstorage/routes/owner/get-current-obj.ts +7 -5
  39. package/ts-code/3nstorage/routes/owner/get-obj-status.ts +8 -8
  40. package/ts-code/3nstorage/routes/owner/put-current-obj.ts +33 -60
  41. package/ts-code/3nstorage/routes/owner/session-params.ts +4 -3
  42. package/ts-code/asmail/resources/utils.ts +41 -0
  43. package/ts-code/asmail/routes/delivery/finalize-delivery.ts +3 -2
  44. package/ts-code/asmail/routes/delivery/pre-flight.ts +15 -29
  45. package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +4 -4
  46. package/ts-code/asmail/routes/delivery/put-metadata.ts +21 -30
  47. package/ts-code/asmail/routes/delivery/put-obj.ts +20 -34
  48. package/ts-code/asmail/routes/delivery/restart-session.ts +11 -24
  49. package/ts-code/asmail/routes/delivery/sender-authorization.ts +5 -5
  50. package/ts-code/asmail/routes/delivery/start-session.ts +17 -32
  51. package/ts-code/asmail/routes/retrieval/get-message-meta.ts +5 -8
  52. package/ts-code/asmail/routes/retrieval/get-message-obj.ts +12 -15
  53. package/ts-code/asmail/routes/retrieval/list-messages.ts +4 -6
  54. package/ts-code/asmail/routes/retrieval/remove-message.ts +3 -2
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
2
+ Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify it under
5
5
  the terms of the GNU General Public License as published by the Free Software
@@ -17,8 +17,9 @@
17
17
 
18
18
  import { RequestHandler } from 'express';
19
19
  import { SC as recipSC, MsgRetrieval } from '../../resources/recipients';
20
- import { msgMetadata as api, ERR_SC, ErrorReply } from '../../../lib-common/service-api/asmail/retrieval';
20
+ import { msgMetadata as api, ERR_SC } from '../../../lib-common/service-api/asmail/retrieval';
21
21
  import { Request } from '../../resources/sessions';
22
+ import { replyWithErr } from '../../resources/utils';
22
23
 
23
24
  export function getMsgMeta(
24
25
  getMsgMetaFunc: MsgRetrieval['getMsgMeta']
@@ -34,13 +35,9 @@ export function getMsgMeta(
34
35
  if ("string" !== typeof err) {
35
36
  next(err);
36
37
  } else if (err === recipSC.MSG_UNKNOWN) {
37
- res.status(api.SC.unknownMsg).json(<ErrorReply> {
38
- error: "Message "+msgId+" is unknown."
39
- });
38
+ replyWithErr(api.SC.unknownMsg, "Message "+msgId+" is unknown.", res);
40
39
  } else if (err === recipSC.USER_UNKNOWN) {
41
- res.status(ERR_SC.server).json( <ErrorReply> {
42
- error: "Recipient disappeared from the system."
43
- });
40
+ replyWithErr(ERR_SC.server, "Recipient disappeared from the system.", res);
44
41
  req.session.close();
45
42
  } else {
46
43
  next(new Error("Unhandled storage error code: "+err));
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2015 - 2017, 2025 3NSoft Inc.
2
+ Copyright (C) 2015 - 2017, 2025 - 2026 3NSoft Inc.
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify it under
5
5
  the terms of the GNU General Public License as published by the Free Software
@@ -21,6 +21,7 @@ import { GetObjQueryOpts, ERR_SC, msgObj as api, HTTP_HEADER } from '../../../li
21
21
  import { Request } from '../../resources/sessions';
22
22
  import { errWithCause } from '../../../lib-common/exceptions/error';
23
23
  import { EMPTY_BUFFER } from '../../../lib-common/buffer-utils';
24
+ import { getObjIdFromParams, replyWithErr } from '../../resources/utils';
24
25
 
25
26
  function extractQueryOptions(req: Request): undefined|{
26
27
  header: boolean; limit: number|undefined; ofs: number;
@@ -52,17 +53,19 @@ export function getMsgObj(
52
53
 
53
54
  const userId = req.session.params.userId;
54
55
  const msgId: string = req.params.msgId;
55
- const objId: string = req.params.objId;
56
+
57
+ const { objId, objIdParseErr } = getObjIdFromParams(req);
58
+ if (objIdParseErr) {
59
+ return replyWithErr(ERR_SC.malformed, objIdParseErr, res);
60
+ }
56
61
 
57
62
  const opts = extractQueryOptions(req);
58
63
  if (!opts) {
59
- res.status(ERR_SC.malformed).send("Bad query parameters");
60
- return;
64
+ return replyWithErr(ERR_SC.malformed, "Bad query parameters", res);
61
65
  }
62
66
 
63
67
  try{
64
- const reader = await getMsgObjFunc(userId, msgId, objId,
65
- opts.header, opts.ofs, opts.limit);
68
+ const reader = await getMsgObjFunc(userId, msgId, objId, opts.header, opts.ofs, opts.limit);
66
69
  res.status(api.SC.ok);
67
70
  res.set(HTTP_HEADER.contentType, BIN_TYPE);
68
71
  res.set(HTTP_HEADER.contentLength, `${reader.len}`);
@@ -87,17 +90,11 @@ export function getMsgObj(
87
90
  if ("string" !== typeof err) {
88
91
  next(err);
89
92
  } else if (err === recipSC.OBJ_UNKNOWN) {
90
- res.status(api.SC.unknownMsgOrObj).send(
91
- `Object ${objId} is unknown.`
92
- );
93
+ replyWithErr(api.SC.unknownMsgOrObj, `Object ${objId} is unknown.`, res);
93
94
  } else if (err === recipSC.MSG_UNKNOWN) {
94
- res.status(api.SC.unknownMsgOrObj).send(
95
- `Message ${msgId} is unknown.`
96
- );
95
+ replyWithErr(api.SC.unknownMsgOrObj, `Message ${msgId} is unknown.`, res);
97
96
  } else if (err === recipSC.USER_UNKNOWN) {
98
- res.status(ERR_SC.server).send(
99
- `Recipient disappeared from the system.`
100
- );
97
+ replyWithErr(ERR_SC.server, `Recipient disappeared from the system.`, res);
101
98
  req.session.close();
102
99
  } else {
103
100
  next(new Error(`Unhandled storage error code: ${err}`));
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
2
+ Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify it under
5
5
  the terms of the GNU General Public License as published by the Free Software
@@ -19,6 +19,7 @@ import { RequestHandler } from 'express';
19
19
  import { SC as recipSC, MsgRetrieval } from '../../resources/recipients';
20
20
  import { listMsgs as api, ERR_SC, ListMsgsOpts } from '../../../lib-common/service-api/asmail/retrieval';
21
21
  import { Request } from '../../resources/sessions';
22
+ import { replyWithErr } from '../../resources/utils';
22
23
 
23
24
  export function listMsgIds(
24
25
  listMsgIdsFunc: MsgRetrieval['getMsgIds']
@@ -28,8 +29,7 @@ export function listMsgIds(
28
29
 
29
30
  const opts = extractQueryOptions(req);
30
31
  if (!opts) {
31
- res.status(ERR_SC.malformed).send("Bad query parameters");
32
- return;
32
+ return replyWithErr(ERR_SC.malformed, "Bad query parameters", res);
33
33
  }
34
34
 
35
35
  try {
@@ -40,9 +40,7 @@ export function listMsgIds(
40
40
  if ("string" !== typeof err) {
41
41
  next(err);
42
42
  } else if (err === recipSC.USER_UNKNOWN) {
43
- res.status(ERR_SC.server).send(
44
- "Recipient disappeared from the system."
45
- );
43
+ replyWithErr(ERR_SC.server, "Recipient disappeared from the system.", res);
46
44
  req.session.close();
47
45
  } else {
48
46
  next(new Error("Unhandled storage error code: "+err));
@@ -19,6 +19,7 @@ import { RequestHandler } from 'express';
19
19
  import { SC as recipSC, MsgRetrieval } from '../../resources/recipients';
20
20
  import { rmMsg as api, ERR_SC } from '../../../lib-common/service-api/asmail/retrieval';
21
21
  import { Request } from '../../resources/sessions';
22
+ import { replyWithErr } from '../../resources/utils';
22
23
 
23
24
  export function deleteMsg(delMsgFunc: MsgRetrieval['deleteMsg']): RequestHandler {
24
25
  return async (req: Request, res, next) => {
@@ -32,9 +33,9 @@ export function deleteMsg(delMsgFunc: MsgRetrieval['deleteMsg']): RequestHandler
32
33
  if ("string" !== typeof err) {
33
34
  next(err);
34
35
  } else if (err === recipSC.MSG_UNKNOWN) {
35
- res.status(api.SC.unknownMsg).send("Message "+msgId+" is unknown.");
36
+ replyWithErr(api.SC.unknownMsg, "Message "+msgId+" is unknown.", res);
36
37
  } else if (err === recipSC.USER_UNKNOWN) {
37
- res.status(ERR_SC.server).send("Recipient disappeared from the system.");
38
+ replyWithErr(ERR_SC.server, "Recipient disappeared from the system.", res);
38
39
  req.session.close();
39
40
  } else {
40
41
  next(new Error("Unhandled storage error code: "+err));