spec-3nweb-server 1.8.1 → 1.8.3

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.
package/build/main.js CHANGED
@@ -139,10 +139,17 @@ async function displaySignupInfo(conf) {
139
139
  if (conf.signup.noTokenFile) {
140
140
  const ctx = await (0, signup_1.readNoTokensFile)(conf.signup.noTokenFile);
141
141
  console.log(`Signup of user without token is allowed in domains:\n`, ctx.domains, `\n`);
142
+ const signupLink = signupLinkFrom(conf, undefined);
143
+ if (signupLink) {
144
+ console.log(`Signup link:\n`, signupLink, `\n`);
145
+ }
142
146
  }
143
147
  else {
144
148
  console.log(`Signup of users is allowed only with valid signup tokens.\n`);
145
149
  }
150
+ if (conf.signup.serviceUrl) {
151
+ console.log(`Signup service url (from configuration file):\n`, conf.signup.serviceUrl, `\n`);
152
+ }
146
153
  }
147
154
  const { multiUserTokens, singleUserTokens } = await (0, signup_1.readAllSignupTokens)(conf.rootFolder);
148
155
  console.log(`There are ${multiUserTokens.length} multi-user tokens.\n`);
@@ -173,40 +180,67 @@ async function displayTokensList(conf) {
173
180
  }
174
181
  async function displayTokenValue(conf, tokenId) {
175
182
  const ctx = await (0, signup_1.readTokenFile)(conf.rootFolder, tokenId);
176
- if (!ctx) {
183
+ if (ctx) {
184
+ const signupLink = signupLinkFrom(conf, ctx.token);
185
+ if (signupLink) {
186
+ console.log(`\nSignup link: ${signupLink}`);
187
+ }
188
+ if (ctx.type === 'multi-domain') {
189
+ console.log(`\nMulti-user signup context:`);
190
+ console.log(` domains:`, ctx.domains);
191
+ console.log(` value:`, ctx.token);
192
+ if (ctx.validTill) {
193
+ console.log(` valid till: ${(new Date(ctx.validTill)).toString()}\n`);
194
+ }
195
+ else {
196
+ console.log(``);
197
+ }
198
+ }
199
+ else if (ctx.type === 'single-user') {
200
+ console.log(`\nSingle-user signup context:`);
201
+ console.log(` address:`, ctx.userId);
202
+ console.log(` value:`, ctx.token);
203
+ if (ctx.validTill) {
204
+ console.log(` valid till: ${(new Date(ctx.validTill)).toString()}\n`);
205
+ }
206
+ else {
207
+ console.log(``);
208
+ }
209
+ }
210
+ }
211
+ else {
177
212
  console.error(`Token ${tokenId} is not found.`);
178
213
  process.exit(-1);
179
214
  }
180
- else if (ctx.type === 'multi-domain') {
181
- console.log(`\nMulti-user signup context:`);
182
- console.log(` domains:`, ctx.domains);
183
- console.log(` value:`, ctx.token);
184
- if (ctx.validTill) {
185
- console.log(` valid till: ${(new Date(ctx.validTill)).toString()}\n`);
186
- }
187
- else {
188
- console.log(``);
189
- }
215
+ }
216
+ function signupLinkFrom(conf, token = '') {
217
+ var _a;
218
+ if (!((_a = conf.signup) === null || _a === void 0 ? void 0 : _a.serviceUrl)) {
219
+ return;
190
220
  }
191
- else if (ctx.type === 'single-user') {
192
- console.log(`\nSingle-user signup context:`);
193
- console.log(` address:`, ctx.userId);
194
- console.log(` value:`, ctx.token);
195
- if (ctx.validTill) {
196
- console.log(` valid till: ${(new Date(ctx.validTill)).toString()}\n`);
197
- }
198
- else {
199
- console.log(``);
200
- }
221
+ try {
222
+ const url = new URL(conf.signup.serviceUrl);
223
+ return `3nweb://signup/${url.host}${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}${token}`;
224
+ }
225
+ catch (err) {
226
+ return;
201
227
  }
202
228
  }
203
229
  async function createMultiUserToken(conf, domains) {
204
230
  const token = await (0, signup_1.addMultiDomainSignup)(conf.rootFolder, domains);
205
231
  console.log(`\nToken value:\n ${token}\n`);
232
+ const signupLink = signupLinkFrom(conf, token);
233
+ if (signupLink) {
234
+ console.log(`Signup link: ${signupLink}\n`);
235
+ }
206
236
  }
207
237
  async function createSingleUserToken(conf, userId) {
208
238
  const token = await (0, signup_1.addSingleUserSignup)(conf.rootFolder, userId);
209
239
  console.log(`\nToken value:\n ${token}\n`);
240
+ const signupLink = signupLinkFrom(conf, token);
241
+ if (signupLink) {
242
+ console.log(`Signup link: ${signupLink}\n`);
243
+ }
210
244
  }
211
245
  const cmd = (0, cli_1.parseProcessArgv)();
212
246
  if (cmd.runCmd) {
@@ -25,6 +25,7 @@ export interface Configurations {
25
25
  };
26
26
  signup?: {
27
27
  noTokenFile?: string;
28
+ serviceUrl?: string;
28
29
  };
29
30
  }
30
31
  export declare function servicesApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",