spec-3nweb-server 1.8.12 → 1.9.1

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/lib.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AppWithWSs } from './lib-server/web-sockets/app';
2
- export { Configurations, servicesApp, accountsApp } from './services';
2
+ export { Configurations, servicesApp, accountsApp, wellKnownApp } from './services';
3
3
  export { addSingleUserSignup } from './config/signup';
4
4
  export import errors = require('./lib-server/middleware/error-handler');
5
5
  export * as mock from './mock/run-in-proc';
package/build/lib.js CHANGED
@@ -16,12 +16,13 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.mock = exports.addSingleUserSignup = exports.accountsApp = exports.servicesApp = exports.AppWithWSs = void 0;
19
+ exports.mock = exports.addSingleUserSignup = exports.wellKnownApp = exports.accountsApp = exports.servicesApp = exports.AppWithWSs = void 0;
20
20
  var app_1 = require("./lib-server/web-sockets/app");
21
21
  Object.defineProperty(exports, "AppWithWSs", { enumerable: true, get: function () { return app_1.AppWithWSs; } });
22
22
  var services_1 = require("./services");
23
23
  Object.defineProperty(exports, "servicesApp", { enumerable: true, get: function () { return services_1.servicesApp; } });
24
24
  Object.defineProperty(exports, "accountsApp", { enumerable: true, get: function () { return services_1.accountsApp; } });
25
+ Object.defineProperty(exports, "wellKnownApp", { enumerable: true, get: function () { return services_1.wellKnownApp; } });
25
26
  var signup_1 = require("./config/signup");
26
27
  Object.defineProperty(exports, "addSingleUserSignup", { enumerable: true, get: function () { return signup_1.addSingleUserSignup; } });
27
28
  exports.errors = require("./lib-server/middleware/error-handler");
package/build/main.js CHANGED
@@ -36,6 +36,7 @@ async function run(conf) {
36
36
  const app = new lib_1.AppWithWSs();
37
37
  app.use((0, lib_1.servicesApp)(conf, 'console', 'console'));
38
38
  app.use((0, lib_1.accountsApp)(conf, 'console', 'console'));
39
+ app.use((0, lib_1.wellKnownApp)(conf));
39
40
  return app;
40
41
  }
41
42
  async function stopProcess() {
@@ -61,7 +62,7 @@ async function run(conf) {
61
62
  }
62
63
  async function startAppWithoutTLS(port, hostname) {
63
64
  await app.start(undefined, port, hostname);
64
- console.log(`🚀 Started 3NWeb server on port ${port},${hostname ? ` hostname ${hostname},` : ''} without TLS, and requiring TLS reverse proxy infront.`);
65
+ console.log(`🚀 Started 3NWeb server on port ${port},${hostname ? ` hostname ${hostname},` : ''} without TLS, and requiring TLS or Tor-like reverse proxy infront.`);
65
66
  }
66
67
  try {
67
68
  app = createApp(conf);
@@ -27,6 +27,12 @@ export interface Configurations {
27
27
  noTokenFile?: string;
28
28
  serviceUrl?: string;
29
29
  };
30
+ wellKnown3NWeb?: {
31
+ mailerid?: string;
32
+ asmail?: string;
33
+ "3nstorage"?: string;
34
+ };
30
35
  }
31
36
  export declare function servicesApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
32
37
  export declare function accountsApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
38
+ export declare function wellKnownApp(conf: Configurations): AppWithWSs;
package/build/services.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2020, 2024 - 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2020, 2024 - 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
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.accountsApp = exports.servicesApp = void 0;
19
+ exports.wellKnownApp = exports.accountsApp = exports.servicesApp = void 0;
20
20
  const mailerid_authorizer_1 = require("./lib-server/resources/mailerid-authorizer");
21
21
  const app_1 = require("./lib-server/web-sockets/app");
22
22
  const mailerId_app_1 = require("./mailerId/mailerId-app");
@@ -25,6 +25,7 @@ const _3nstorage_app_1 = require("./3nstorage/3nstorage-app");
25
25
  const signup_app_1 = require("./signup/signup-app");
26
26
  const error_handler_1 = require("./lib-server/middleware/error-handler");
27
27
  const locker_app_1 = require("./locker/locker-app");
28
+ const well_known_route_app_1 = require("./well-known/well-known-route-app");
28
29
  function servicesApp(conf, errLogger, logSetup) {
29
30
  var _a;
30
31
  if (!conf.enabledServices || (typeof conf.enabledServices !== 'object')) {
@@ -75,4 +76,12 @@ function accountsApp(conf, errLogger, logSetup) {
75
76
  return app;
76
77
  }
77
78
  exports.accountsApp = accountsApp;
79
+ function wellKnownApp(conf) {
80
+ const app = new app_1.AppWithWSs();
81
+ if (conf.wellKnown3NWeb) {
82
+ app.http.use('/.well-known', (0, well_known_route_app_1.makeWellKnownApp)(conf.wellKnown3NWeb));
83
+ }
84
+ return app;
85
+ }
86
+ exports.wellKnownApp = wellKnownApp;
78
87
  Object.freeze(exports);
@@ -0,0 +1,3 @@
1
+ import * as express from 'express';
2
+ import { Configurations } from '../services';
3
+ export declare function makeWellKnownApp(w3n: NonNullable<Configurations['wellKnown3NWeb']>): express.Application;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2026 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.makeWellKnownApp = void 0;
20
+ const express = require("express");
21
+ function makeWellKnownApp(w3n) {
22
+ const app = express();
23
+ const w3nJson = confTo3NWebJSON(w3n);
24
+ app.get('3nweb.json', (req, res) => {
25
+ // the following implicitly sets content type application/json
26
+ res.status(200).json(w3nJson);
27
+ });
28
+ return app;
29
+ }
30
+ exports.makeWellKnownApp = makeWellKnownApp;
31
+ function confTo3NWebJSON(conf) {
32
+ const json = {};
33
+ const fields = ['3nstorage', 'asmail', 'mailerid'];
34
+ for (const field in fields) {
35
+ const href = conf[field];
36
+ if (href) {
37
+ let u;
38
+ try {
39
+ u = new URL(href);
40
+ }
41
+ catch (err) {
42
+ console.error(` ❌ Configuration field ${field} for well-known needs potocol section`);
43
+ throw err;
44
+ }
45
+ if ((u.protocol !== 'https:') && (u.protocol !== 'http:')) {
46
+ throw new Error(` ❌ Configuration field ${field} for well-known needs potocol section`);
47
+ }
48
+ json[field] = href;
49
+ }
50
+ }
51
+ return json;
52
+ }
53
+ Object.freeze(exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.8.12",
3
+ "version": "1.9.1",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",
package/ts-code/lib.ts CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  export { AppWithWSs } from './lib-server/web-sockets/app';
19
19
 
20
- export { Configurations, servicesApp, accountsApp } from './services';
20
+ export { Configurations, servicesApp, accountsApp, wellKnownApp } from './services';
21
21
 
22
22
  export { addSingleUserSignup } from './config/signup';
23
23
 
package/ts-code/main.ts CHANGED
@@ -25,7 +25,7 @@ import { ServerOptions } from 'https';
25
25
  import { CliUsageDisplay, parseProcessArgv } from './cli';
26
26
  import { readYamlConfFile } from './config/from-yaml';
27
27
  import { sslOptsFromConfig } from './config/letsencrypt';
28
- import { Configurations, servicesApp, accountsApp, AppWithWSs } from './lib';
28
+ import { Configurations, servicesApp, accountsApp, AppWithWSs, wellKnownApp } 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';
@@ -45,6 +45,7 @@ async function run(conf: Configurations): Promise<void> {
45
45
  const app = new AppWithWSs();
46
46
  app.use(servicesApp(conf, 'console', 'console'));
47
47
  app.use(accountsApp(conf, 'console', 'console'));
48
+ app.use(wellKnownApp(conf));
48
49
  return app;
49
50
  }
50
51
 
@@ -73,7 +74,7 @@ async function run(conf: Configurations): Promise<void> {
73
74
  port: number, hostname: string|undefined
74
75
  ): Promise<void> {
75
76
  await app!.start(undefined, port, hostname);
76
- console.log(`🚀 Started 3NWeb server on port ${port},${hostname ? ` hostname ${hostname},` : ''} without TLS, and requiring TLS reverse proxy infront.`);
77
+ console.log(`🚀 Started 3NWeb server on port ${port},${hostname ? ` hostname ${hostname},` : ''} without TLS, and requiring TLS or Tor-like reverse proxy infront.`);
77
78
  }
78
79
 
79
80
  try {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2015 - 2017, 2020, 2024 - 2025 3NSoft Inc.
2
+ Copyright (C) 2015 - 2017, 2020, 2024 - 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
@@ -30,6 +30,7 @@ import { makeSignupApp } from './signup/signup-app';
30
30
  import { ErrLogger, makeErrLoggerToConsole } from "./lib-server/middleware/error-handler";
31
31
  import { makeLockerApp } from "./locker/locker-app";
32
32
  import { MidAuthorizer } from "./lib-server/routes/sessions/mid-auth";
33
+ import { makeWellKnownApp } from "./well-known/well-known-route-app";
33
34
 
34
35
  export interface Configurations {
35
36
  enabledServices: {
@@ -56,6 +57,11 @@ export interface Configurations {
56
57
  noTokenFile?: string;
57
58
  serviceUrl?: string;
58
59
  };
60
+ wellKnown3NWeb?: {
61
+ mailerid?: string;
62
+ asmail?: string;
63
+ "3nstorage"?: string;
64
+ };
59
65
  }
60
66
 
61
67
  export function servicesApp(
@@ -135,4 +141,15 @@ export function accountsApp(
135
141
  return app;
136
142
  }
137
143
 
144
+ export function wellKnownApp(conf: Configurations): AppWithWSs {
145
+
146
+ const app = new AppWithWSs();
147
+
148
+ if (conf.wellKnown3NWeb) {
149
+ app.http.use('/.well-known', makeWellKnownApp(conf.wellKnown3NWeb));
150
+ }
151
+
152
+ return app;
153
+ }
154
+
138
155
  Object.freeze(exports);
@@ -0,0 +1,66 @@
1
+ /*
2
+ Copyright (C) 2026 3NSoft Inc.
3
+
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU General Public License as published by the Free Software
6
+ Foundation, either version 3 of the License, or (at your option) any later
7
+ version.
8
+
9
+ This program is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ See the GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import * as express from 'express';
19
+ import { Configurations } from '../services';
20
+
21
+ export function makeWellKnownApp(w3n: NonNullable<Configurations['wellKnown3NWeb']>): express.Application {
22
+
23
+ const app = express();
24
+
25
+ const w3nJson = confTo3NWebJSON(w3n);
26
+
27
+ app.get('3nweb.json', (req, res) => {
28
+ // the following implicitly sets content type application/json
29
+ res.status(200).json(w3nJson);
30
+ });
31
+
32
+ return app;
33
+ }
34
+
35
+ interface WellKnown3NWeb {
36
+ mailerid?: string;
37
+ asmail?: string;
38
+ '3nstorage'?: string;
39
+ report?: string;
40
+ 'w3n-app'?: string;
41
+ }
42
+
43
+ function confTo3NWebJSON(conf: NonNullable<Configurations['wellKnown3NWeb']>): WellKnown3NWeb {
44
+ const json: WellKnown3NWeb = {};
45
+ const fields: (keyof WellKnown3NWeb)[] = [ '3nstorage', 'asmail', 'mailerid' ];
46
+ for (const field in fields) {
47
+ const href = conf[field];
48
+ if (href) {
49
+ let u: URL;
50
+ try {
51
+ u = new URL(href);
52
+ } catch (err) {
53
+ console.error(` ❌ Configuration field ${field} for well-known needs potocol section`);
54
+ throw err;
55
+ }
56
+ if ((u.protocol !== 'https:') && (u.protocol !== 'http:')) {
57
+ throw new Error(` ❌ Configuration field ${field} for well-known needs potocol section`);
58
+ }
59
+ json[field] = href;
60
+ }
61
+ }
62
+ return json;
63
+ }
64
+
65
+
66
+ Object.freeze(exports);