@sockethub/server 5.0.0-alpha.21 → 5.0.0-alpha.22
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/README.md +15 -5
- package/dist/cli.d.ts +13 -0
- package/dist/index.js +187 -65
- package/dist/index.js.map +11 -9
- package/dist/platform.js +38 -20
- package/dist/platform.js.map +6 -6
- package/dist/sentry.d.ts +9 -0
- package/dist/trust-proxy.d.ts +24 -0
- package/package.json +15 -15
- package/res/sockethub-client.js +9 -4
- package/res/sockethub-client.min.js +11 -11
package/README.md
CHANGED
|
@@ -155,15 +155,25 @@ verification event and exit.
|
|
|
155
155
|
### Command-line params
|
|
156
156
|
|
|
157
157
|
```
|
|
158
|
-
--help
|
|
159
|
-
--
|
|
158
|
+
--help, -h : this help screen
|
|
159
|
+
--version, -v : print the version and exit
|
|
160
|
+
--info : displays some basic runtime info
|
|
160
161
|
|
|
161
|
-
--examples
|
|
162
|
+
--examples : enabled examples page and serves helper files like jquery
|
|
162
163
|
|
|
163
|
-
--
|
|
164
|
-
--
|
|
164
|
+
--config, -c : path to a config file
|
|
165
|
+
--write-config : write a default config file and exit
|
|
166
|
+
|
|
167
|
+
--host : hostname to bind to
|
|
168
|
+
--port : port to bind to
|
|
169
|
+
|
|
170
|
+
--sentry-test : send a verification event to Sentry and exit
|
|
171
|
+
--sentry-test-crash : report a synthetic fatal error to Sentry and exit
|
|
165
172
|
```
|
|
166
173
|
|
|
174
|
+
`--help`, `--version` and `--write-config` answer without loading the config
|
|
175
|
+
file or binding a port, so they work on a host already running Sockethub.
|
|
176
|
+
|
|
167
177
|
### Start
|
|
168
178
|
|
|
169
179
|
Run with debug output and examples enabled:
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argument handling for the flags that short-circuit startup.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately free of imports from the config singleton: `--help` and
|
|
5
|
+
* `--version` must answer even when the config file in the working directory
|
|
6
|
+
* is missing or invalid, and must never reach the point of binding a port.
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderHelp(): string;
|
|
9
|
+
/**
|
|
10
|
+
* The short-circuit flag present in `argv`, if any. `--help` wins over
|
|
11
|
+
* `--version` when both are given.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseInfoFlag(argv: Array<string>): "help" | "version" | undefined;
|
package/dist/index.js
CHANGED
|
@@ -10029,6 +10029,18 @@ function errorMessage(value) {
|
|
|
10029
10029
|
}
|
|
10030
10030
|
var init_error = () => {};
|
|
10031
10031
|
|
|
10032
|
+
// src/version.ts
|
|
10033
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
10034
|
+
function defaultSentryRelease() {
|
|
10035
|
+
return `sockethub@${SOCKETHUB_VERSION}`;
|
|
10036
|
+
}
|
|
10037
|
+
var require2, packageJson, SOCKETHUB_VERSION;
|
|
10038
|
+
var init_version = __esm(() => {
|
|
10039
|
+
require2 = createRequire2(import.meta.url);
|
|
10040
|
+
packageJson = require2("../package.json");
|
|
10041
|
+
SOCKETHUB_VERSION = packageJson.version;
|
|
10042
|
+
});
|
|
10043
|
+
|
|
10032
10044
|
// ../schemas/src/context.ts
|
|
10033
10045
|
function buildCanonicalContext(platform) {
|
|
10034
10046
|
const platformUrl = platform.startsWith("https://") ? platform : `${PLATFORM_CONTEXT_PREFIX}${platform}/v1.jsonld`;
|
|
@@ -16574,7 +16586,7 @@ var init_package = __esm(() => {
|
|
|
16574
16586
|
package_default = {
|
|
16575
16587
|
name: "@sockethub/schemas",
|
|
16576
16588
|
description: "JSON schema files for validating Sockethub Activity Streams",
|
|
16577
|
-
version: "3.0.0-alpha.
|
|
16589
|
+
version: "3.0.0-alpha.22",
|
|
16578
16590
|
type: "module",
|
|
16579
16591
|
private: false,
|
|
16580
16592
|
author: "Nick Jennings <nick@silverbucket.net>",
|
|
@@ -16644,7 +16656,7 @@ var init_package = __esm(() => {
|
|
|
16644
16656
|
"ajv-formats": "^2.1.1",
|
|
16645
16657
|
"ajv-formats-draft2019": "^1.6.1"
|
|
16646
16658
|
},
|
|
16647
|
-
gitHead: "
|
|
16659
|
+
gitHead: "1630010f605e85cc548e3323cb9694fbe3a7a18a",
|
|
16648
16660
|
types: "./dist/index.d.ts"
|
|
16649
16661
|
};
|
|
16650
16662
|
});
|
|
@@ -16961,6 +16973,11 @@ var init_sockethub_config = __esm(() => {
|
|
|
16961
16973
|
default: 262144,
|
|
16962
16974
|
description: "Maximum size in bytes of a single Socket.IO message."
|
|
16963
16975
|
},
|
|
16976
|
+
trustProxy: {
|
|
16977
|
+
type: ["boolean", "number", "string"],
|
|
16978
|
+
default: false,
|
|
16979
|
+
description: "Express 'trust proxy' setting, deciding whether " + "'x-forwarded-for' is believed when determining a " + "client's IP for HTTP rate limiting. false trusts no " + "proxy; a number trusts that many hops; a string " + "takes an address, subnet or preset ('loopback'). " + "Only enable behind a reverse proxy that overwrites " + "the header. When left false while " + "credentialCheck.reconnectIpSource is 'proxy' and " + "credentialCheck.proxyHeader is 'x-forwarded-for', " + "one hop is trusted so both paths agree; a custom " + "proxyHeader requires setting this explicitly."
|
|
16980
|
+
},
|
|
16964
16981
|
cors: {
|
|
16965
16982
|
type: "object",
|
|
16966
16983
|
additionalProperties: false,
|
|
@@ -29228,6 +29245,11 @@ var init_config_schema = __esm(() => {
|
|
|
29228
29245
|
env: "SOCKETHUB_MAX_PAYLOAD_BYTES",
|
|
29229
29246
|
emptyEnvIsUnset: true
|
|
29230
29247
|
},
|
|
29248
|
+
"sockethub.trustProxy": {
|
|
29249
|
+
format: "*",
|
|
29250
|
+
env: "SOCKETHUB_TRUST_PROXY",
|
|
29251
|
+
emptyEnvIsUnset: true
|
|
29252
|
+
},
|
|
29231
29253
|
"sockethub.cors.origin": {
|
|
29232
29254
|
env: "SOCKETHUB_CORS_ORIGIN",
|
|
29233
29255
|
arg: "cors.origin"
|
|
@@ -29411,7 +29433,7 @@ var init_debug_build = __esm(() => {
|
|
|
29411
29433
|
|
|
29412
29434
|
// ../../node_modules/@sentry/core/build/esm/utils/version.js
|
|
29413
29435
|
var SDK_VERSION = "10.70.0";
|
|
29414
|
-
var
|
|
29436
|
+
var init_version2 = () => {};
|
|
29415
29437
|
|
|
29416
29438
|
// ../../node_modules/@sentry/core/build/esm/utils/worldwide.js
|
|
29417
29439
|
var GLOBAL_OBJ;
|
|
@@ -29435,7 +29457,7 @@ function getGlobalSingleton(name, creator, obj = GLOBAL_OBJ) {
|
|
|
29435
29457
|
return carrier[name] || (carrier[name] = creator());
|
|
29436
29458
|
}
|
|
29437
29459
|
var init_carrier = __esm(() => {
|
|
29438
|
-
|
|
29460
|
+
init_version2();
|
|
29439
29461
|
init_worldwide();
|
|
29440
29462
|
});
|
|
29441
29463
|
|
|
@@ -34510,7 +34532,7 @@ function applySdkMetadata(options, name, names = [name], source = "npm") {
|
|
|
34510
34532
|
}
|
|
34511
34533
|
}
|
|
34512
34534
|
var init_sdkMetadata = __esm(() => {
|
|
34513
|
-
|
|
34535
|
+
init_version2();
|
|
34514
34536
|
});
|
|
34515
34537
|
|
|
34516
34538
|
// ../../node_modules/@sentry/core/build/esm/utils/traceData.js
|
|
@@ -42121,7 +42143,7 @@ var init_esm = __esm(() => {
|
|
|
42121
42143
|
init_url();
|
|
42122
42144
|
init_lru();
|
|
42123
42145
|
init_propagationContext();
|
|
42124
|
-
|
|
42146
|
+
init_version2();
|
|
42125
42147
|
init_randomSafeContext();
|
|
42126
42148
|
init_server_runtime_client();
|
|
42127
42149
|
init_node_stack_trace();
|
|
@@ -55258,17 +55280,17 @@ function _getModules() {
|
|
|
55258
55280
|
function getPackageJson() {
|
|
55259
55281
|
try {
|
|
55260
55282
|
const filePath = join3(process.cwd(), "package.json");
|
|
55261
|
-
const
|
|
55262
|
-
return
|
|
55283
|
+
const packageJson2 = JSON.parse(readFileSync(filePath, "utf8"));
|
|
55284
|
+
return packageJson2;
|
|
55263
55285
|
} catch {
|
|
55264
55286
|
return {};
|
|
55265
55287
|
}
|
|
55266
55288
|
}
|
|
55267
55289
|
function getModulesFromPackageJson() {
|
|
55268
|
-
const
|
|
55290
|
+
const packageJson2 = getPackageJson();
|
|
55269
55291
|
return {
|
|
55270
|
-
...
|
|
55271
|
-
...
|
|
55292
|
+
...packageJson2.dependencies,
|
|
55293
|
+
...packageJson2.devDependencies
|
|
55272
55294
|
};
|
|
55273
55295
|
}
|
|
55274
55296
|
var moduleCache, INTEGRATION_NAME15 = "Modules", _modulesIntegration = () => {
|
|
@@ -66514,18 +66536,6 @@ var init_sentry_config = __esm(() => {
|
|
|
66514
66536
|
logger = createLogger("sentry:config");
|
|
66515
66537
|
});
|
|
66516
66538
|
|
|
66517
|
-
// src/version.ts
|
|
66518
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
66519
|
-
function defaultSentryRelease() {
|
|
66520
|
-
return `sockethub@${SOCKETHUB_VERSION}`;
|
|
66521
|
-
}
|
|
66522
|
-
var require2, packageJson, SOCKETHUB_VERSION;
|
|
66523
|
-
var init_version2 = __esm(() => {
|
|
66524
|
-
require2 = createRequire2(import.meta.url);
|
|
66525
|
-
packageJson = require2("../package.json");
|
|
66526
|
-
SOCKETHUB_VERSION = packageJson.version;
|
|
66527
|
-
});
|
|
66528
|
-
|
|
66529
66539
|
// ../../node_modules/@sentry/profiling-node/node_modules/@sentry/core/build/esm/utils/version.js
|
|
66530
66540
|
var SDK_VERSION2 = "10.36.0";
|
|
66531
66541
|
var init_version3 = () => {};
|
|
@@ -71448,7 +71458,9 @@ var init_esm7 = __esm(() => {
|
|
|
71448
71458
|
// src/sentry.ts
|
|
71449
71459
|
var exports_sentry = {};
|
|
71450
71460
|
__export(exports_sentry, {
|
|
71461
|
+
SENTRY_FLUSH_TIMEOUT_MS: () => SENTRY_FLUSH_TIMEOUT_MS,
|
|
71451
71462
|
count: () => count2,
|
|
71463
|
+
flush: () => flush3,
|
|
71452
71464
|
gauge: () => gauge2,
|
|
71453
71465
|
reportError: () => reportError,
|
|
71454
71466
|
sendTestEvent: () => sendTestEvent,
|
|
@@ -71458,6 +71470,9 @@ function reportError(err) {
|
|
|
71458
71470
|
logger2.warn("reporting error");
|
|
71459
71471
|
captureException(err);
|
|
71460
71472
|
}
|
|
71473
|
+
function flush3(timeoutMs = SENTRY_FLUSH_TIMEOUT_MS) {
|
|
71474
|
+
return flush(timeoutMs);
|
|
71475
|
+
}
|
|
71461
71476
|
function count2(name, value = 1, attributes = {}) {
|
|
71462
71477
|
if (sentryConfig.enableMetrics) {
|
|
71463
71478
|
exports_public_api.count(name, value, { attributes });
|
|
@@ -71494,13 +71509,13 @@ async function sendTestEvent() {
|
|
|
71494
71509
|
captureMessage("Sockethub Sentry verification event", "info");
|
|
71495
71510
|
return flush(5000);
|
|
71496
71511
|
}
|
|
71497
|
-
var logger2, sentryConfig, integrations;
|
|
71512
|
+
var SENTRY_FLUSH_TIMEOUT_MS = 2000, logger2, sentryConfig, integrations;
|
|
71498
71513
|
var init_sentry = __esm(async () => {
|
|
71499
71514
|
init_esm5();
|
|
71500
71515
|
init_src();
|
|
71501
71516
|
init_observability();
|
|
71502
71517
|
init_sentry_config();
|
|
71503
|
-
|
|
71518
|
+
init_version();
|
|
71504
71519
|
logger2 = createLogger("sentry");
|
|
71505
71520
|
sentryConfig = resolveSentryConfig();
|
|
71506
71521
|
if (!sentryConfig.dsn) {
|
|
@@ -137916,7 +137931,7 @@ var require_package2 = __commonJS(function(exports, module) {
|
|
|
137916
137931
|
module.exports = {
|
|
137917
137932
|
name: "@sockethub/server",
|
|
137918
137933
|
description: "A polyglot messaging service, server libraries",
|
|
137919
|
-
version: "5.0.0-alpha.
|
|
137934
|
+
version: "5.0.0-alpha.22",
|
|
137920
137935
|
type: "module",
|
|
137921
137936
|
private: false,
|
|
137922
137937
|
author: "Nick Jennings <nick@silverbucket.net>",
|
|
@@ -137967,11 +137982,11 @@ var require_package2 = __commonJS(function(exports, module) {
|
|
|
137967
137982
|
dependencies: {
|
|
137968
137983
|
"@sentry/node": "^10.36.0",
|
|
137969
137984
|
"@sentry/profiling-node": "10.36.0",
|
|
137970
|
-
"@sockethub/client": "^5.0.0-alpha.
|
|
137971
|
-
"@sockethub/data-layer": "^1.0.0-alpha.
|
|
137972
|
-
"@sockethub/logger": "^1.0.0-alpha.
|
|
137973
|
-
"@sockethub/schemas": "^3.0.0-alpha.
|
|
137974
|
-
"@sockethub/util": "^1.0.0-alpha.
|
|
137985
|
+
"@sockethub/client": "^5.0.0-alpha.22",
|
|
137986
|
+
"@sockethub/data-layer": "^1.0.0-alpha.22",
|
|
137987
|
+
"@sockethub/logger": "^1.0.0-alpha.22",
|
|
137988
|
+
"@sockethub/schemas": "^3.0.0-alpha.22",
|
|
137989
|
+
"@sockethub/util": "^1.0.0-alpha.10",
|
|
137975
137990
|
chalk: "^5.6.2",
|
|
137976
137991
|
convict: "^6.2.5",
|
|
137977
137992
|
ejs: "^3.1.10",
|
|
@@ -138002,16 +138017,16 @@ var require_package2 = __commonJS(function(exports, module) {
|
|
|
138002
138017
|
"web-streams-polyfill": "^3.3.3"
|
|
138003
138018
|
},
|
|
138004
138019
|
optionalDependencies: {
|
|
138005
|
-
"@sockethub/examples": "^1.0.0-alpha.
|
|
138006
|
-
"@sockethub/platform-caldav": "^1.0.0-alpha.
|
|
138007
|
-
"@sockethub/platform-carddav": "^1.0.0-alpha.
|
|
138008
|
-
"@sockethub/platform-dummy": "^3.0.0-alpha.
|
|
138009
|
-
"@sockethub/platform-feeds": "^4.0.0-alpha.
|
|
138010
|
-
"@sockethub/platform-irc": "^4.0.0-alpha.
|
|
138011
|
-
"@sockethub/platform-metadata": "^1.0.1-alpha.
|
|
138012
|
-
"@sockethub/platform-xmpp": "^5.0.0-alpha.
|
|
138013
|
-
},
|
|
138014
|
-
gitHead: "
|
|
138020
|
+
"@sockethub/examples": "^1.0.0-alpha.22",
|
|
138021
|
+
"@sockethub/platform-caldav": "^1.0.0-alpha.6",
|
|
138022
|
+
"@sockethub/platform-carddav": "^1.0.0-alpha.3",
|
|
138023
|
+
"@sockethub/platform-dummy": "^3.0.0-alpha.22",
|
|
138024
|
+
"@sockethub/platform-feeds": "^4.0.0-alpha.22",
|
|
138025
|
+
"@sockethub/platform-irc": "^4.0.0-alpha.22",
|
|
138026
|
+
"@sockethub/platform-metadata": "^1.0.1-alpha.17",
|
|
138027
|
+
"@sockethub/platform-xmpp": "^5.0.0-alpha.22"
|
|
138028
|
+
},
|
|
138029
|
+
gitHead: "1630010f605e85cc548e3323cb9694fbe3a7a18a",
|
|
138015
138030
|
types: "./dist/index.d.ts"
|
|
138016
138031
|
};
|
|
138017
138032
|
});
|
|
@@ -196033,6 +196048,36 @@ var init_routes = __esm(() => {
|
|
|
196033
196048
|
routes_default = routes;
|
|
196034
196049
|
});
|
|
196035
196050
|
|
|
196051
|
+
// src/trust-proxy.ts
|
|
196052
|
+
function normalize5(value) {
|
|
196053
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
196054
|
+
return value;
|
|
196055
|
+
}
|
|
196056
|
+
if (typeof value !== "string") {
|
|
196057
|
+
return false;
|
|
196058
|
+
}
|
|
196059
|
+
const trimmed = value.trim();
|
|
196060
|
+
if (trimmed === "" || trimmed === "false") {
|
|
196061
|
+
return false;
|
|
196062
|
+
}
|
|
196063
|
+
if (trimmed === "true") {
|
|
196064
|
+
return true;
|
|
196065
|
+
}
|
|
196066
|
+
if (/^\d+$/.test(trimmed)) {
|
|
196067
|
+
return Number(trimmed);
|
|
196068
|
+
}
|
|
196069
|
+
return trimmed;
|
|
196070
|
+
}
|
|
196071
|
+
function resolveTrustProxy(configured, reconnectIpSource, proxyHeader) {
|
|
196072
|
+
const normalized = normalize5(configured);
|
|
196073
|
+
if (normalized !== false || reconnectIpSource !== "proxy") {
|
|
196074
|
+
return normalized;
|
|
196075
|
+
}
|
|
196076
|
+
const header = typeof proxyHeader === "string" && proxyHeader.trim() !== "" ? proxyHeader.trim().toLowerCase() : EXPRESS_FORWARDED_HEADER;
|
|
196077
|
+
return header === EXPRESS_FORWARDED_HEADER ? 1 : false;
|
|
196078
|
+
}
|
|
196079
|
+
var EXPRESS_FORWARDED_HEADER = "x-forwarded-for";
|
|
196080
|
+
|
|
196036
196081
|
// src/listener.ts
|
|
196037
196082
|
import { existsSync as existsSync2, writeFileSync } from "node:fs";
|
|
196038
196083
|
import * as HTTP from "node:http";
|
|
@@ -196134,6 +196179,11 @@ class Listener {
|
|
|
196134
196179
|
}
|
|
196135
196180
|
static initExpress() {
|
|
196136
196181
|
const app = import_express3.default();
|
|
196182
|
+
const trustProxy = resolveTrustProxy(config_default.get("sockethub:trustProxy"), config_default.get("credentialCheck:reconnectIpSource"), config_default.get("credentialCheck:proxyHeader"));
|
|
196183
|
+
app.set("trust proxy", trustProxy);
|
|
196184
|
+
if (trustProxy !== false) {
|
|
196185
|
+
log9.info(`trusting proxy headers (trust proxy: ${trustProxy})`);
|
|
196186
|
+
}
|
|
196137
196187
|
app.set("view engine", "ejs");
|
|
196138
196188
|
app.use(import_express3.default.urlencoded({ extended: true }));
|
|
196139
196189
|
return app;
|
|
@@ -196156,7 +196206,7 @@ var init_listener = __esm(() => {
|
|
|
196156
196206
|
init_config();
|
|
196157
196207
|
init_cors();
|
|
196158
196208
|
init_routes();
|
|
196159
|
-
|
|
196209
|
+
init_version();
|
|
196160
196210
|
import_express3 = __toESM(require_express(), 1);
|
|
196161
196211
|
require3 = createRequire5(import.meta.url);
|
|
196162
196212
|
log9 = createLogger("server:listener");
|
|
@@ -198270,6 +198320,50 @@ init_src();
|
|
|
198270
198320
|
init_error();
|
|
198271
198321
|
import path5 from "node:path";
|
|
198272
198322
|
|
|
198323
|
+
// src/cli.ts
|
|
198324
|
+
init_version();
|
|
198325
|
+
function renderHelp() {
|
|
198326
|
+
return `Sockethub v${SOCKETHUB_VERSION} — a protocol gateway for web applications
|
|
198327
|
+
|
|
198328
|
+
Usage: sockethub [options]
|
|
198329
|
+
|
|
198330
|
+
Options:
|
|
198331
|
+
-c, --config <path> Path to a config file (default: ./sockethub.config.json,
|
|
198332
|
+
or the SOCKETHUB_CONFIG environment variable)
|
|
198333
|
+
--write-config [path] Write a default config file and exit ("-" for stdout,
|
|
198334
|
+
default: ./sockethub.config.json)
|
|
198335
|
+
--host <host> Address to bind (config: sockethub.host)
|
|
198336
|
+
--port <port> Port to bind (config: sockethub.port)
|
|
198337
|
+
--redis.url <url> Redis connection URL (config: redis.url)
|
|
198338
|
+
--cors.origin <list> Allowed CORS origin(s), comma-separated
|
|
198339
|
+
(config: sockethub.cors.origin)
|
|
198340
|
+
--sentry.dsn <dsn> Sentry DSN to report to (config: sentry.dsn)
|
|
198341
|
+
--sentry-test Send a test event to Sentry and exit, reporting
|
|
198342
|
+
whether it was accepted
|
|
198343
|
+
--sentry-test-crash Report a synthetic fatal error to Sentry and exit
|
|
198344
|
+
non-zero, exercising the crash-reporting path
|
|
198345
|
+
--examples Serve the bundled example pages
|
|
198346
|
+
--info Print runtime information
|
|
198347
|
+
-v, --version Print the version and exit
|
|
198348
|
+
-h, --help Print this help and exit
|
|
198349
|
+
|
|
198350
|
+
Every config file setting can also be set by environment variable; see
|
|
198351
|
+
docs/configuration.md for the full list.
|
|
198352
|
+
`;
|
|
198353
|
+
}
|
|
198354
|
+
function parseInfoFlag(argv) {
|
|
198355
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
198356
|
+
return "help";
|
|
198357
|
+
}
|
|
198358
|
+
if (argv.includes("--version") || argv.includes("-v")) {
|
|
198359
|
+
return "version";
|
|
198360
|
+
}
|
|
198361
|
+
return;
|
|
198362
|
+
}
|
|
198363
|
+
|
|
198364
|
+
// src/index.ts
|
|
198365
|
+
init_version();
|
|
198366
|
+
|
|
198273
198367
|
// src/write-config.ts
|
|
198274
198368
|
init_src2();
|
|
198275
198369
|
init_config_schema();
|
|
@@ -198322,19 +198416,43 @@ function writeDefaultConfig(target) {
|
|
|
198322
198416
|
var sentry = {
|
|
198323
198417
|
reportError: (_err) => {}
|
|
198324
198418
|
};
|
|
198419
|
+
async function reportFatal(err, code = 1) {
|
|
198420
|
+
sentry.reportError(err);
|
|
198421
|
+
try {
|
|
198422
|
+
if (await sentry.flush?.() === false) {
|
|
198423
|
+
console.error("fatal-error-flush timed out; event may be lost");
|
|
198424
|
+
}
|
|
198425
|
+
} catch (flushErr) {
|
|
198426
|
+
console.error(`fatal-error-flush failed: ${toError(flushErr).message}`);
|
|
198427
|
+
}
|
|
198428
|
+
process.exit(code);
|
|
198429
|
+
}
|
|
198325
198430
|
async function server() {
|
|
198326
|
-
const
|
|
198431
|
+
const argv = process.argv.slice(2);
|
|
198432
|
+
const infoFlag = parseInfoFlag(argv);
|
|
198433
|
+
if (infoFlag === "help") {
|
|
198434
|
+
process.stdout.write(renderHelp());
|
|
198435
|
+
process.exitCode = 0;
|
|
198436
|
+
return;
|
|
198437
|
+
}
|
|
198438
|
+
if (infoFlag === "version") {
|
|
198439
|
+
console.log(SOCKETHUB_VERSION);
|
|
198440
|
+
process.exitCode = 0;
|
|
198441
|
+
return;
|
|
198442
|
+
}
|
|
198443
|
+
const writeConfigTarget = parseWriteConfigTarget(argv);
|
|
198327
198444
|
if (writeConfigTarget !== undefined) {
|
|
198328
198445
|
try {
|
|
198329
198446
|
const message = writeDefaultConfig(writeConfigTarget);
|
|
198330
198447
|
if (message) {
|
|
198331
198448
|
console.log(message);
|
|
198332
198449
|
}
|
|
198333
|
-
process.
|
|
198450
|
+
process.exitCode = 0;
|
|
198334
198451
|
} catch (err) {
|
|
198335
198452
|
console.error(toError(err).message);
|
|
198336
|
-
process.
|
|
198453
|
+
process.exitCode = 1;
|
|
198337
198454
|
}
|
|
198455
|
+
return;
|
|
198338
198456
|
}
|
|
198339
198457
|
const { default: config2 } = await Promise.resolve().then(() => (init_config(), exports_config));
|
|
198340
198458
|
const loggingConfig = config2.get("logging");
|
|
@@ -198351,7 +198469,18 @@ async function server() {
|
|
|
198351
198469
|
log13.info("initializing sentry");
|
|
198352
198470
|
sentry = await init_sentry().then(() => exports_sentry);
|
|
198353
198471
|
}
|
|
198354
|
-
|
|
198472
|
+
process.once("uncaughtException", (err) => {
|
|
198473
|
+
const error4 = toError(err);
|
|
198474
|
+
console.error(`${new Date().toUTCString()} UNCAUGHT EXCEPTION
|
|
198475
|
+
`, error4.stack);
|
|
198476
|
+
reportFatal(error4);
|
|
198477
|
+
});
|
|
198478
|
+
process.once("unhandledRejection", (err) => {
|
|
198479
|
+
console.error(`${new Date().toUTCString()} UNHANDLED REJECTION
|
|
198480
|
+
`, err);
|
|
198481
|
+
reportFatal(toError(err));
|
|
198482
|
+
});
|
|
198483
|
+
if (argv.includes("--sentry-test")) {
|
|
198355
198484
|
if (!sentry.sendTestEvent) {
|
|
198356
198485
|
console.error("Sentry is not configured; no test event was sent");
|
|
198357
198486
|
process.exit(1);
|
|
@@ -198360,27 +198489,22 @@ async function server() {
|
|
|
198360
198489
|
console.log(sent ? "Sentry test event sent" : "Sentry test event failed");
|
|
198361
198490
|
process.exit(sent ? 0 : 1);
|
|
198362
198491
|
}
|
|
198492
|
+
if (argv.includes("--sentry-test-crash")) {
|
|
198493
|
+
if (!sentry.flush) {
|
|
198494
|
+
console.error("Sentry is not configured; no crash was reported");
|
|
198495
|
+
process.exit(1);
|
|
198496
|
+
}
|
|
198497
|
+
console.error("Reporting a synthetic fatal error to Sentry");
|
|
198498
|
+
await reportFatal(new Error("Sockethub Sentry verification crash"));
|
|
198499
|
+
}
|
|
198363
198500
|
const { default: Sockethub2 } = await Promise.resolve().then(() => (init_sockethub(), exports_sockethub));
|
|
198364
198501
|
try {
|
|
198365
198502
|
sockethub = new Sockethub2;
|
|
198366
198503
|
} catch (err) {
|
|
198367
198504
|
const error4 = toError(err);
|
|
198368
|
-
sentry.reportError(error4);
|
|
198369
198505
|
console.error(error4);
|
|
198370
|
-
|
|
198506
|
+
await reportFatal(error4);
|
|
198371
198507
|
}
|
|
198372
|
-
process.once("uncaughtException", (err) => {
|
|
198373
|
-
console.error(`${new Date().toUTCString()} UNCAUGHT EXCEPTION
|
|
198374
|
-
`, err.stack);
|
|
198375
|
-
sentry.reportError(err);
|
|
198376
|
-
process.exit(1);
|
|
198377
|
-
});
|
|
198378
|
-
process.once("unhandledRejection", (err) => {
|
|
198379
|
-
console.error(`${new Date().toUTCString()} UNHANDLED REJECTION
|
|
198380
|
-
`, err);
|
|
198381
|
-
sentry.reportError(toError(err));
|
|
198382
|
-
process.exit(1);
|
|
198383
|
-
});
|
|
198384
198508
|
const gracefulShutdown = async (signal) => {
|
|
198385
198509
|
console.log(`Received ${signal} signal. Shutting down sockethub...`);
|
|
198386
198510
|
try {
|
|
@@ -198388,9 +198512,8 @@ async function server() {
|
|
|
198388
198512
|
process.exit(0);
|
|
198389
198513
|
} catch (err) {
|
|
198390
198514
|
const error4 = toError(err);
|
|
198391
|
-
sentry.reportError(error4);
|
|
198392
198515
|
console.error(error4);
|
|
198393
|
-
|
|
198516
|
+
await reportFatal(error4);
|
|
198394
198517
|
}
|
|
198395
198518
|
};
|
|
198396
198519
|
process.once("SIGTERM", () => {
|
|
@@ -198403,13 +198526,12 @@ async function server() {
|
|
|
198403
198526
|
await sockethub.boot();
|
|
198404
198527
|
} catch (err) {
|
|
198405
198528
|
const error4 = toError(err);
|
|
198406
|
-
sentry.reportError(error4);
|
|
198407
198529
|
console.error(error4);
|
|
198408
|
-
|
|
198530
|
+
await reportFatal(error4);
|
|
198409
198531
|
}
|
|
198410
198532
|
}
|
|
198411
198533
|
export {
|
|
198412
198534
|
server
|
|
198413
198535
|
};
|
|
198414
198536
|
|
|
198415
|
-
//# debugId=
|
|
198537
|
+
//# debugId=E054626A88B96F6264756E2164756E21
|