spec-3nweb-server 1.8.9 → 1.8.10

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.
@@ -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);
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.10",
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);