spec-3nweb-server 1.8.4 → 1.8.5

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2022 3NSoft Inc.
3
+ Copyright (C) 2022, 2026 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
@@ -34,7 +34,7 @@ function archiveCurrentObjVersion(root, archiveObjVerFunc) {
34
34
  }
35
35
  try {
36
36
  await archiveObjVerFunc(userId, objId, version);
37
- res.status(SC.okPost).end();
37
+ res.status(SC.okPost).send();
38
38
  }
39
39
  catch (err) {
40
40
  if ("string" !== typeof err) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2020, 2026 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
@@ -29,7 +29,7 @@ function cancelTransaction(root, cancelTransFunc) {
29
29
  const transactionId = req.params.transactionId;
30
30
  try {
31
31
  await cancelTransFunc(userId, objId, ((transactionId === '-') ? undefined : transactionId));
32
- res.status(owner_1.cancelTransaction.SC.ok).end();
32
+ res.status(owner_1.cancelTransaction.SC.ok).send();
33
33
  }
34
34
  catch (err) {
35
35
  if ("string" !== typeof err) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016, 2020, 2022 3NSoft Inc.
3
+ Copyright (C) 2016, 2020, 2022, 2026 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
@@ -55,7 +55,7 @@ function deleteObj(root, delCurrent, deleteObjFunc) {
55
55
  else {
56
56
  await deleteObjFunc(userId, objId, version);
57
57
  }
58
- res.status(owner_1.currentObj.SC.okDelete).end();
58
+ res.status(owner_1.currentObj.SC.okDelete).send();
59
59
  }
60
60
  catch (err) {
61
61
  if ("string" !== typeof err) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2017, 2020, 2026 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
@@ -67,7 +67,7 @@ function getCurrentObj(root, getCurrentObjFunc) {
67
67
  if (opts.ver) {
68
68
  if (opts.ver !== version) {
69
69
  res.set(owner_1.HTTP_HEADER.objVersion, `${version}`);
70
- res.status(owner_1.currentObj.SC.unknownObjVer).end();
70
+ res.status(owner_1.currentObj.SC.unknownObjVer).send();
71
71
  return;
72
72
  }
73
73
  }
@@ -102,8 +102,7 @@ function getCurrentObj(root, getCurrentObjFunc) {
102
102
  }
103
103
  else if ((err === users_1.SC.OBJ_UNKNOWN)
104
104
  || (err === users_1.SC.OBJ_VER_UNKNOWN)) {
105
- res.status(owner_1.currentObj.SC.unknownObj).send(objId ?
106
- `Object ${objId} is unknown.` : `Root object is not set.`);
105
+ res.status(owner_1.currentObj.SC.unknownObj).send(objId ? `Object ${objId} is unknown.` : `Root object is not set.`);
107
106
  }
108
107
  else if (err === users_1.SC.USER_UNKNOWN) {
109
108
  res.status(owner_1.ERR_SC.server).send(`Recipient disappeared from the system.`);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2026 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
@@ -20,9 +20,6 @@ exports.setParam = void 0;
20
20
  const users_1 = require("../../resources/users");
21
21
  const owner_1 = require("../../../lib-common/service-api/3nstorage/owner");
22
22
  function setParam(paramSetter) {
23
- if ('function' !== typeof paramSetter) {
24
- throw new TypeError("Given argument 'paramSetter' must be function, but is not.");
25
- }
26
23
  return async (req, res, next) => {
27
24
  const session = req.session;
28
25
  const userId = session.params.userId;
@@ -30,7 +27,7 @@ function setParam(paramSetter) {
30
27
  try {
31
28
  const valChanged = await paramSetter(userId, pValue);
32
29
  if (valChanged) {
33
- res.status(owner_1.PARAM_SC.ok).end();
30
+ res.status(owner_1.PARAM_SC.ok).send();
34
31
  }
35
32
  else {
36
33
  res.status(owner_1.ERR_SC.malformed).send('Malformed parameter value.');
@@ -48,4 +45,3 @@ function setParam(paramSetter) {
48
45
  };
49
46
  }
50
47
  exports.setParam = setParam;
51
- ;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2025 - 2026 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
@@ -27,7 +27,7 @@ function setParam(paramSetter) {
27
27
  try {
28
28
  const valChanged = await paramSetter(userId, pValue);
29
29
  if (valChanged) {
30
- res.status(config_1.PARAM_SC.ok).end();
30
+ res.status(config_1.PARAM_SC.ok).send();
31
31
  }
32
32
  else {
33
33
  res.status(config_1.ERR_SC.malformed).send('Malformed parameter value.');
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2025 - 2026 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
@@ -27,7 +27,7 @@ function finalizeDelivery(finDelivFunc) {
27
27
  try {
28
28
  await finDelivFunc(recipient, msgId);
29
29
  session.close();
30
- res.status(delivery_1.completion.SC.ok).end();
30
+ res.status(delivery_1.completion.SC.ok).send();
31
31
  }
32
32
  catch (err) {
33
33
  if ('string' !== typeof err) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2019 - 2020, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2019 - 2020, 2025 - 2026 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
@@ -74,7 +74,7 @@ function saveMsgObj(saveObjFunc, chunkLimit) {
74
74
  }
75
75
  try {
76
76
  await saveObjFunc(recipient, msgId, objId, opts.fstReq, opts.sndReq, len, req);
77
- res.status(delivery_1.msgObj.SC.ok).end();
77
+ res.status(delivery_1.msgObj.SC.ok).send();
78
78
  }
79
79
  catch (err) {
80
80
  session.params.currentMsgLength -= len;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2026 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
@@ -50,7 +50,7 @@ function authorize(relyingPartyDomain, midAuthorizingFunc) {
50
50
  const certsVerified = await midAuthorizingFunc(relyingPartyDomain, sessionId, sender, rb.assertion, rb.userCert, rb.provCert);
51
51
  if (certsVerified) {
52
52
  req.session.isAuthorized = true;
53
- res.status(delivery_1.authSender.SC.ok).end();
53
+ res.status(delivery_1.authSender.SC.ok).send();
54
54
  }
55
55
  else {
56
56
  res.status(delivery_1.authSender.SC.authFailed).send("Server is not accepting provided credentials.");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2026 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
@@ -25,7 +25,7 @@ function deleteMsg(delMsgFunc) {
25
25
  const msgId = req.params.msgId;
26
26
  try {
27
27
  await delMsgFunc(userId, msgId);
28
- res.status(retrieval_1.rmMsg.SC.ok).end();
28
+ res.status(retrieval_1.rmMsg.SC.ok).send();
29
29
  }
30
30
  catch (err) {
31
31
  if ("string" !== typeof err) {
@@ -169,7 +169,6 @@ function parseSignupArgs(args, execName) {
169
169
  }
170
170
  }
171
171
  else if (args[0] === createTokenCmd.name) {
172
- console.log(args);
173
172
  const signupCmd = parseWithConfFile(args.slice(1), createTokenOpts);
174
173
  if (signupCmd) {
175
174
  if (!signupCmd.domain && !signupCmd.user) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2026 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
@@ -20,7 +20,7 @@ exports.closeSession = void 0;
20
20
  function closeSession() {
21
21
  return (req, res, next) => {
22
22
  req.session.close();
23
- res.status(200).end();
23
+ res.status(200).send();
24
24
  };
25
25
  }
26
26
  exports.closeSession = closeSession;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2026 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
@@ -26,9 +26,6 @@ const login_1 = require("../../../lib-common/service-api/mailer-id/login");
26
26
  * This creates an authorize-sender route handler.
27
27
  */
28
28
  function midLogin(relyingPartyDomain, midAuthorizingFunc) {
29
- if ('function' !== typeof midAuthorizingFunc) {
30
- throw new TypeError("Given argument 'midAuthorizingFunc' must be function, but is not.");
31
- }
32
29
  return async (req, res, next) => {
33
30
  if (req.session.isAuthorized) {
34
31
  res.status(login_1.ERR_SC.duplicate).send("This protocol request has already been served.");
@@ -47,7 +44,7 @@ function midLogin(relyingPartyDomain, midAuthorizingFunc) {
47
44
  const certsVerified = await midAuthorizingFunc(relyingPartyDomain, sessionId, req.session.params.userId, rb.assertion, rb.userCert, rb.provCert);
48
45
  if (certsVerified) {
49
46
  req.session.isAuthorized = true;
50
- res.status(login_1.authSession.SC.ok).end();
47
+ res.status(login_1.authSession.SC.ok).send();
51
48
  }
52
49
  else {
53
50
  req.session.close();
package/build/main.js CHANGED
@@ -183,30 +183,25 @@ async function displayTokenValue(conf, tokenId) {
183
183
  if (ctx) {
184
184
  const signupLink = signupLinkFrom(conf, ctx.token);
185
185
  if (signupLink) {
186
- console.log(`\nSignup link: ${signupLink}`);
186
+ console.log(`\nSignup link:\n ${signupLink}`);
187
187
  }
188
188
  if (ctx.type === 'multi-domain') {
189
189
  console.log(`\nMulti-user signup context:`);
190
190
  console.log(` domains:`, ctx.domains);
191
191
  console.log(` value:`, ctx.token);
192
192
  if (ctx.validTill) {
193
- console.log(` valid till: ${(new Date(ctx.validTill)).toString()}\n`);
194
- }
195
- else {
196
- console.log(``);
193
+ console.log(` valid till: ${(new Date(ctx.validTill)).toString()}`);
197
194
  }
198
195
  }
199
196
  else if (ctx.type === 'single-user') {
200
197
  console.log(`\nSingle-user signup context:`);
201
- console.log(` address:`, ctx.userId);
202
- console.log(` value:`, ctx.token);
198
+ console.log(` address: `, ctx.userId);
199
+ console.log(` value: `, ctx.token);
203
200
  if (ctx.validTill) {
204
- console.log(` valid till: ${(new Date(ctx.validTill)).toString()}\n`);
205
- }
206
- else {
207
- console.log(``);
201
+ console.log(` valid till: ${(new Date(ctx.validTill)).toString()}`);
208
202
  }
209
203
  }
204
+ console.log(``);
210
205
  }
211
206
  else {
212
207
  console.error(`Token ${tokenId} is not found.`);
@@ -229,19 +224,21 @@ function signupLinkFrom(conf, token = '') {
229
224
  }
230
225
  async function createMultiUserToken(conf, domains) {
231
226
  const token = await (0, signup_1.addMultiDomainSignup)(conf.rootFolder, domains);
232
- console.log(`\nToken value:\n ${token}\n`);
227
+ console.log(`\nFor creating users on domain${(domains.length > 0) ? 's' : ''} ${domains.join(', ')}:\n token value: ${token}`);
233
228
  const signupLink = signupLinkFrom(conf, token);
234
229
  if (signupLink) {
235
- console.log(`Signup link: ${signupLink}\n`);
230
+ console.log(`Signup link:\n ${signupLink}\n`);
236
231
  }
232
+ console.log(``);
237
233
  }
238
234
  async function createSingleUserToken(conf, userId) {
239
235
  const token = await (0, signup_1.addSingleUserSignup)(conf.rootFolder, userId);
240
- console.log(`\nToken value:\n ${token}\n`);
236
+ console.log(`\nFor creating user ${userId}:\n token value: ${token}`);
241
237
  const signupLink = signupLinkFrom(conf, token);
242
238
  if (signupLink) {
243
- console.log(`Signup link: ${signupLink}\n`);
239
+ console.log(`Signup link:\n ${signupLink}\n`);
244
240
  }
241
+ console.log(``);
245
242
  }
246
243
  const cmd = (0, cli_1.parseProcessArgv)();
247
244
  if (cmd.runCmd) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2020, 2026 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
@@ -42,14 +42,14 @@ function addUser(addUserFunc) {
42
42
  }
43
43
  try {
44
44
  await addUserFunc(userId, mailerId, storage.kdParams, signupToken);
45
- res.status(signup_1.addUser.SC.ok).end();
45
+ res.status(signup_1.addUser.SC.ok).send();
46
46
  }
47
47
  catch (err) {
48
48
  if (err === users_1.SC.USER_ALREADY_EXIST) {
49
- res.status(signup_1.addUser.SC.userAlreadyExists).end();
49
+ res.status(signup_1.addUser.SC.userAlreadyExists).send();
50
50
  }
51
51
  else if (err === users_1.SC.CREATION_UNAUTHORIZED) {
52
- res.status(signup_1.addUser.SC.unauthorized).end();
52
+ res.status(signup_1.addUser.SC.unauthorized).send();
53
53
  }
54
54
  else {
55
55
  next(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",