spec-3nweb-server 1.8.9 → 1.8.11

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.
@@ -6,7 +6,7 @@
6
6
  build for linux:
7
7
  extends: build
8
8
  rules: [ { when: on_success } ]
9
- image: node-22
9
+ image: node-24
10
10
 
11
11
 
12
12
  test on linux:
@@ -14,7 +14,7 @@ test on linux:
14
14
  rules: [ { when: on_success } ]
15
15
  needs:
16
16
  - build for linux
17
- image: node-22
17
+ image: node-24
18
18
 
19
19
 
20
20
  pack for linux:
@@ -23,7 +23,7 @@ pack for linux:
23
23
  needs:
24
24
  - build for linux
25
25
  - test on linux
26
- image: node-22
26
+ image: node-24
27
27
 
28
28
 
29
29
  pack mock for linux:
@@ -32,7 +32,7 @@ pack mock for linux:
32
32
  needs:
33
33
  - build for linux
34
34
  - test on linux
35
- image: node-22
35
+ image: node-24
36
36
 
37
37
 
38
38
  # pack deb:
@@ -41,7 +41,7 @@ pack mock for linux:
41
41
  # needs:
42
42
  # - build for linux
43
43
  # - test on linux
44
- # image: node-16
44
+ # image: node-24
45
45
  # script:
46
46
  # - npm run pack-deb
47
47
  # artifacts:
package/.gitlab-ci.yml CHANGED
@@ -52,7 +52,7 @@ publish to npm:
52
52
  rules:
53
53
  - if: '$CI_COMMIT_BRANCH == "master"'
54
54
  when: manual
55
- image: node-22
55
+ image: node-24
56
56
  script:
57
57
  - bash publish-task.sh $NPM_PUBLISH_TOKEN
58
58
 
@@ -23,7 +23,7 @@ const default_confs_1 = require("./default-confs");
23
23
  function readYamlConfFile(path) {
24
24
  const txt = (0, fs_1.readFileSync)(path, 'utf8');
25
25
  const conf = yaml.load(txt);
26
- if (conf.rootFolder) {
26
+ if (!conf.rootFolder) {
27
27
  conf.rootFolder = default_confs_1.DEFAULT_DATA_ROOT_PATH;
28
28
  }
29
29
  return conf;
@@ -17,7 +17,7 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.checkAndTransformAddress = exports.areAddressesEqual = exports.toCanonicalAddress = void 0;
20
- const punycode_1 = require("punycode");
20
+ const punycode_1 = require("punycode/");
21
21
  /**
22
22
  * @param address
23
23
  * @return a canonical form of a given address.
package/build/main.js CHANGED
@@ -24,6 +24,7 @@ const lib_1 = require("./lib");
24
24
  const signup_1 = require("./config/signup");
25
25
  const default_confs_1 = require("./config/default-confs");
26
26
  const file_1 = require("./lib-common/exceptions/file");
27
+ const qrcode = require("qrcode-terminal");
27
28
  async function run(conf) {
28
29
  if (!conf.servicesConnect) {
29
30
  console.error(`❌ No connection settings found in configuration.`);
@@ -142,6 +143,7 @@ async function displaySignupInfo(conf) {
142
143
  const signupLink = signupLinkFrom(conf, undefined);
143
144
  if (signupLink) {
144
145
  console.log(`Signup link:\n`, signupLink, `\n`);
146
+ displayAsQR(signupLink);
145
147
  }
146
148
  }
147
149
  else {
@@ -155,6 +157,10 @@ async function displaySignupInfo(conf) {
155
157
  console.log(`There are ${multiUserTokens.length} multi-user tokens.\n`);
156
158
  console.log(`There are ${singleUserTokens.length} single-user tokens.\n`);
157
159
  }
160
+ function displayAsQR(str) {
161
+ qrcode.setErrorLevel('Q');
162
+ qrcode.generate(str, { small: true });
163
+ }
158
164
  async function displayTokensList(conf) {
159
165
  const { multiUserTokens, singleUserTokens } = await (0, signup_1.readAllSignupTokens)(conf.rootFolder);
160
166
  if (multiUserTokens.length > 0) {
@@ -181,10 +187,6 @@ async function displayTokensList(conf) {
181
187
  async function displayTokenValue(conf, tokenId) {
182
188
  const ctx = await (0, signup_1.readTokenFile)(conf.rootFolder, tokenId);
183
189
  if (ctx) {
184
- const signupLink = signupLinkFrom(conf, ctx.token);
185
- if (signupLink) {
186
- console.log(`\nSignup link:\n ${signupLink}`);
187
- }
188
190
  if (ctx.type === 'multi-domain') {
189
191
  console.log(`\nMulti-user signup context:`);
190
192
  console.log(` domains:`, ctx.domains);
@@ -201,6 +203,11 @@ async function displayTokenValue(conf, tokenId) {
201
203
  console.log(` valid till: ${(new Date(ctx.validTill)).toString()}`);
202
204
  }
203
205
  }
206
+ const signupLink = signupLinkFrom(conf, ctx.token);
207
+ if (signupLink) {
208
+ console.log(`\nSignup link:\n ${signupLink}`);
209
+ displayAsQR(signupLink);
210
+ }
204
211
  console.log(``);
205
212
  }
206
213
  else {
@@ -241,6 +248,12 @@ async function createSingleUserToken(conf, userId) {
241
248
  console.log(``);
242
249
  }
243
250
  const cmd = (0, cli_1.parseProcessArgv)();
251
+ process.on('unhandledRejection', (err, p) => {
252
+ console.error(' -- Unhandled rejection of promise:', err);
253
+ });
254
+ process.on('uncaughtException', err => {
255
+ console.error(' -- Unhandled exception:', err);
256
+ });
244
257
  if (cmd.runCmd) {
245
258
  const conf = assembleConfig(cmd.runCmd.config);
246
259
  run(conf);
@@ -34,13 +34,15 @@ function setTestCertsAndDNS(domains, thisSrvLoc) {
34
34
  https.globalAgent.options.ca = tls_options_1.sslOpts.cert;
35
35
  // inject dns mock
36
36
  const dnsRecs = {};
37
+ const reportAddress = `report@${thisSrvLoc.includes(':') ? thisSrvLoc.substring(0, thisSrvLoc.indexOf(':')) : thisSrvLoc}`;
37
38
  for (const domain of domains) {
38
39
  dnsRecs[domain] = [
39
40
  ['asmail', '=', `${thisSrvLoc}/asmail`],
40
41
  [
41
42
  'mailerid=', `${thisSrvLoc}/mailerid`,
42
43
  `3nstorage=${thisSrvLoc}/3nstorage`
43
- ] // two 3NWeb records in one DNS TXT record
44
+ ],
45
+ [`report=${reportAddress}`]
44
46
  // XXX add other life-like records
45
47
  ];
46
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.8.9",
3
+ "version": "1.8.11",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",
@@ -41,7 +41,8 @@
41
41
  "express": "^4.22.2",
42
42
  "js-yaml": "^4.3.0",
43
43
  "prompts": "^2.4.2",
44
- "punycode": "^2.1.1",
44
+ "punycode": "^2.3.1",
45
+ "qrcode-terminal": "^0.12.0",
45
46
  "ws": "^7.5.11",
46
47
  "xsp-files": "^2.0.0"
47
48
  },
@@ -49,6 +50,7 @@
49
50
  "@types/express": "4.17.13",
50
51
  "@types/jasmine": "^3.9.1",
51
52
  "@types/node": "^16.11.7",
53
+ "@types/punycode": "^2.1.4",
52
54
  "@types/ws": "^4.0.0",
53
55
  "jasmine": "^3.9.0",
54
56
  "rxjs": "^5.3.0",
@@ -24,7 +24,7 @@ export function readYamlConfFile(path: string): Configurations {
24
24
  const txt = readFileSync(path, 'utf8');
25
25
  const conf = yaml.load(txt) as Configurations;
26
26
 
27
- if (conf.rootFolder) {
27
+ if (!conf.rootFolder) {
28
28
  conf.rootFolder = DEFAULT_DATA_ROOT_PATH;
29
29
  }
30
30
 
@@ -15,7 +15,7 @@
15
15
  this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
- import { toASCII } from 'punycode';
18
+ import { toASCII } from 'punycode/';
19
19
 
20
20
  /**
21
21
  * @param address
package/ts-code/main.ts CHANGED
@@ -29,6 +29,7 @@ import { Configurations, servicesApp, accountsApp, AppWithWSs } from './lib';
29
29
  import { addMultiDomainSignup, addSingleUserSignup, readAllSignupTokens, readNoTokensFile, readTokenFile } from './config/signup';
30
30
  import { DEFAULT_CONFIG_PATH } from './config/default-confs';
31
31
  import { Code } from './lib-common/exceptions/file';
32
+ import * as qrcode from 'qrcode-terminal';
32
33
 
33
34
  async function run(conf: Configurations): Promise<void> {
34
35
 
@@ -159,6 +160,7 @@ async function displaySignupInfo(conf: Configurations): Promise<void> {
159
160
  const signupLink = signupLinkFrom(conf, undefined);
160
161
  if (signupLink) {
161
162
  console.log(`Signup link:\n`, signupLink, `\n`);
163
+ displayAsQR(signupLink);
162
164
  }
163
165
  } else {
164
166
  console.log(`Signup of users is allowed only with valid signup tokens.\n`);
@@ -174,6 +176,11 @@ async function displaySignupInfo(conf: Configurations): Promise<void> {
174
176
  console.log(`There are ${singleUserTokens.length} single-user tokens.\n`);
175
177
  }
176
178
 
179
+ function displayAsQR(str: string): void {
180
+ qrcode.setErrorLevel('Q');
181
+ qrcode.generate(str, { small: true });
182
+ }
183
+
177
184
  async function displayTokensList(conf: Configurations): Promise<void> {
178
185
  const {
179
186
  multiUserTokens, singleUserTokens
@@ -203,10 +210,6 @@ async function displayTokenValue(
203
210
  ): Promise<void> {
204
211
  const ctx = await readTokenFile(conf.rootFolder, tokenId);
205
212
  if (ctx) {
206
- const signupLink = signupLinkFrom(conf, ctx.token);
207
- if (signupLink) {
208
- console.log(`\nSignup link:\n ${signupLink}`);
209
- }
210
213
  if (ctx.type === 'multi-domain') {
211
214
  console.log(`\nMulti-user signup context:`);
212
215
  console.log(` domains:`, ctx.domains);
@@ -222,6 +225,11 @@ async function displayTokenValue(
222
225
  console.log(` valid till: ${(new Date(ctx.validTill)).toString()}`);
223
226
  }
224
227
  }
228
+ const signupLink = signupLinkFrom(conf, ctx.token);
229
+ if (signupLink) {
230
+ console.log(`\nSignup link:\n ${signupLink}`);
231
+ displayAsQR(signupLink);
232
+ }
225
233
  console.log(``);
226
234
  } else {
227
235
  console.error(`Token ${tokenId} is not found.`);
@@ -269,6 +277,13 @@ async function createSingleUserToken(
269
277
 
270
278
  const cmd = parseProcessArgv();
271
279
 
280
+ process.on('unhandledRejection', (err, p) => {
281
+ console.error(' -- Unhandled rejection of promise:', err);
282
+ });
283
+ process.on('uncaughtException', err => {
284
+ console.error(' -- Unhandled exception:', err);
285
+ });
286
+
272
287
  if (cmd.runCmd) {
273
288
  const conf = assembleConfig(cmd.runCmd.config!);
274
289
  run(conf);
@@ -37,13 +37,17 @@ export function setTestCertsAndDNS(
37
37
 
38
38
  // inject dns mock
39
39
  const dnsRecs: DnsTxtRecords = {};
40
+ const reportAddress = `report@${
41
+ thisSrvLoc.includes(':') ? thisSrvLoc.substring(0, thisSrvLoc.indexOf(':')) : thisSrvLoc
42
+ }`;
40
43
  for (const domain of domains) {
41
44
  dnsRecs[domain] = [
42
45
  [ 'asmail', '=', `${thisSrvLoc}/asmail` ], // one record in DNS TXT
43
46
  [
44
47
  'mailerid=', `${thisSrvLoc}/mailerid`,
45
48
  `3nstorage=${thisSrvLoc}/3nstorage`
46
- ] // two 3NWeb records in one DNS TXT record
49
+ ], // two 3NWeb records in one DNS TXT record
50
+ [ `report=${reportAddress}` ]
47
51
  // XXX add other life-like records
48
52
  ];
49
53
  }