sockethub 5.0.0-alpha.2 → 5.0.0-alpha.21
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 +6 -92
- package/bin/sockethub +3 -29
- package/bin/sockethub-logged +109 -0
- package/build.js +12 -0
- package/package.json +20 -66
- package/config.json.example +0 -32
- package/dist/bootstrap/init.js +0 -74
- package/dist/bootstrap/init.js.map +0 -1
- package/dist/bootstrap/platforms.js +0 -103
- package/dist/common.js +0 -20
- package/dist/common.js.map +0 -1
- package/dist/config.js +0 -60
- package/dist/config.js.map +0 -1
- package/dist/crypto.js +0 -38
- package/dist/crypto.js.map +0 -1
- package/dist/defaults.json +0 -32
- package/dist/janitor.js +0 -98
- package/dist/janitor.js.map +0 -1
- package/dist/middleware/create-activity-object.js +0 -19
- package/dist/middleware/create-activity-object.js.map +0 -1
- package/dist/middleware/expand-activity-stream.js +0 -33
- package/dist/middleware/expand-activity-stream.js.map +0 -1
- package/dist/middleware/expand-activity-stream.test.data.js +0 -360
- package/dist/middleware/expand-activity-stream.test.data.js.map +0 -1
- package/dist/middleware/store-credentials.js +0 -19
- package/dist/middleware/store-credentials.js.map +0 -1
- package/dist/middleware/validate.js +0 -77
- package/dist/middleware/validate.js.map +0 -1
- package/dist/middleware/validate.test.data.js +0 -321
- package/dist/middleware/validate.test.data.js.map +0 -1
- package/dist/middleware.js +0 -54
- package/dist/middleware.js.map +0 -1
- package/dist/platform-instance.js +0 -226
- package/dist/platform-instance.js.map +0 -1
- package/dist/platform.js +0 -186
- package/dist/platform.js.map +0 -1
- package/dist/process-manager.js +0 -78
- package/dist/process-manager.js.map +0 -1
- package/dist/routes.js +0 -84
- package/dist/routes.js.map +0 -1
- package/dist/serve.js +0 -102
- package/dist/serve.js.map +0 -1
- package/dist/sockethub-client.js +0 -2604
- package/dist/sockethub-client.js.map +0 -1
- package/dist/sockethub-client.min.js +0 -2
- package/dist/sockethub-client.min.js.LICENSE.txt +0 -24
- package/dist/sockethub.js +0 -130
- package/dist/sockethub.js.map +0 -1
- package/dist/store.js +0 -17
- package/dist/store.js.map +0 -1
- package/src/bootstrap/init.d.ts +0 -8
- package/src/bootstrap/init.ts +0 -91
- package/src/bootstrap/platforms.js +0 -103
- package/src/common.test.ts +0 -54
- package/src/common.ts +0 -14
- package/src/config.d.ts +0 -2
- package/src/config.test.ts +0 -28
- package/src/config.ts +0 -72
- package/src/crypto.d.ts +0 -5
- package/src/crypto.test.ts +0 -41
- package/src/crypto.ts +0 -41
- package/src/defaults.json +0 -32
- package/src/janitor.d.ts +0 -8
- package/src/janitor.ts +0 -89
- package/src/middleware/create-activity-object.test.ts +0 -10
- package/src/middleware/create-activity-object.ts +0 -13
- package/src/middleware/expand-activity-stream.test.data.ts +0 -365
- package/src/middleware/expand-activity-stream.test.ts +0 -78
- package/src/middleware/expand-activity-stream.ts +0 -27
- package/src/middleware/store-credentials.test.ts +0 -72
- package/src/middleware/store-credentials.ts +0 -16
- package/src/middleware/validate.d.ts +0 -1
- package/src/middleware/validate.test.data.ts +0 -320
- package/src/middleware/validate.test.ts +0 -47
- package/src/middleware/validate.ts +0 -49
- package/src/middleware.d.ts +0 -21
- package/src/middleware.test.ts +0 -148
- package/src/middleware.ts +0 -52
- package/src/platform-instance.test.ts +0 -237
- package/src/platform-instance.ts +0 -236
- package/src/platform.ts +0 -189
- package/src/process-manager.ts +0 -64
- package/src/routes.test.ts +0 -100
- package/src/routes.ts +0 -93
- package/src/serve.ts +0 -79
- package/src/sockethub-client.test.ts +0 -235
- package/src/sockethub-client.ts +0 -164
- package/src/sockethub.d.ts +0 -1
- package/src/sockethub.ts +0 -184
- package/src/store.test.ts +0 -26
- package/src/store.ts +0 -17
- package/test/init-suite.js +0 -41
- package/test/sockethub-suite.js +0 -25
- package/tsconfig.json +0 -79
- package/views/examples/dummy.ejs +0 -93
- package/views/examples/feeds.ejs +0 -90
- package/views/examples/irc.ejs +0 -239
- package/views/examples/shared.js +0 -72
- package/views/examples/xmpp.ejs +0 -191
- package/views/index.ejs +0 -17
- package/webpack.minified.config.js +0 -14
- package/webpack.normal.config.js +0 -14
package/README.md
CHANGED
|
@@ -1,98 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
# Sockethub
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Sockethub server
|
|
4
4
|
|
|
5
5
|
## About
|
|
6
|
-
Sockethub is a translation layer for web applications to communicate with other protocols and services that are traditionally either inaccessible or impractical to use from in-browser JavaScript.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Server code for the sockethub service, this can be called directly, though is usually called from the
|
|
8
|
+
parent `sockethub` package, which includes all of the dependencies and platforms.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Example uses of Sockethub are:
|
|
13
|
-
|
|
14
|
-
* Writing and receiving messages (SMTP, IMAP, Facebook, Twitter, ...)
|
|
15
|
-
* Instant messaging (XMPP, IRC, MSN, FB Messenger, Hangouts, ...)
|
|
16
|
-
* Discovery (WebFinger, RDF(a), ...)
|
|
17
|
-
|
|
18
|
-
The architecture of Sockethub is extensible and supports easy implementation of additional 'platforms' to carry out tasks.
|
|
19
|
-
|
|
20
|
-
## Docs
|
|
21
|
-
|
|
22
|
-
See the [Sockethub wiki](https://github.com/sockethub/sockethub/wiki) for documentation.
|
|
23
|
-
|
|
24
|
-
## Features
|
|
25
|
-
|
|
26
|
-
We use ActivityStreams to map the various actions of a platform to a set of AS '@type's which identify the underlying action. For example, using the XMPP platform, a friend request/accept cycle would use the activity stream types 'request-friend', 'remove-friend', 'make-friend'.
|
|
27
|
-
|
|
28
|
-
Below is a list of platform contexts we're currently working on and their types, both the completed and not yet implemented ones. They are all implemented in Sockethub platforms (each in their own repository) and can be enabled/disabled in the `config.json`.
|
|
29
|
-
|
|
30
|
-
## Platforms
|
|
31
|
-
|
|
32
|
-
* [Feeds](../sockethub-platform-feeds) *(RSS, Atom)*
|
|
33
|
-
* [IRC](../sockethub-platform-irc)
|
|
34
|
-
* [XMPP](../sockethub-platform-xmpp)
|
|
35
|
-
|
|
36
|
-
## Install
|
|
37
|
-
|
|
38
|
-
`$ npm install -g sockethub`
|
|
39
|
-
|
|
40
|
-
## Running
|
|
41
|
-
|
|
42
|
-
### Environment Variables
|
|
43
|
-
|
|
44
|
-
* PORT
|
|
45
|
-
Defaults to `10550`
|
|
46
|
-
* HOST
|
|
47
|
-
Defaults to `localhost`
|
|
48
|
-
* DEBUG
|
|
49
|
-
Specify the namespace to console log, ie. `sockethub*` will print all sockethub related debug statements, whereas `*` will also print any other modules debug statements that use the `debug` module.
|
|
50
|
-
|
|
51
|
-
* REDIS_PORT
|
|
52
|
-
Defaults to `6379`
|
|
53
|
-
* REDIS_HOST
|
|
54
|
-
Defaults to `localhost`
|
|
55
|
-
|
|
56
|
-
***OR***
|
|
57
|
-
|
|
58
|
-
* REDIS_URL
|
|
59
|
-
Overrides `REDIS_HOST` and `REDIS_PORT`, can specify a full redis connect URL (eq. `redis://username:password@host:port`)
|
|
60
|
-
|
|
61
|
-
### Command-line params
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
--help : this help screen
|
|
65
|
-
--info : displays some basic runtime info
|
|
66
|
-
|
|
67
|
-
--examples : enabled examples page and serves helper files like jquery
|
|
68
|
-
|
|
69
|
-
--host : hostname to bind to
|
|
70
|
-
--port : port to bind to
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Start
|
|
74
|
-
|
|
75
|
-
Run with debug output and examples enabled:
|
|
76
|
-
|
|
77
|
-
`$ DEBUG=sockethub* sockethub --examples`
|
|
78
|
-
|
|
79
|
-
You should then be able to browse to `http://localhost:10550/examples` and try out the examples.
|
|
80
|
-
|
|
81
|
-
For production, with examples disabled.
|
|
82
|
-
|
|
83
|
-
`$ DEBUG=sockethub* sockethub`
|
|
84
|
-
|
|
85
|
-
## License
|
|
86
|
-
|
|
87
|
-
Sockethub is licensed under the [LGPL](https://github.com/sockethub/sockethub/blob/master/LICENSE)
|
|
88
|
-
|
|
89
|
-
## Credits
|
|
90
|
-
|
|
91
|
-
Project created and maintained by [Nick Jennings](http://github.com/silverbucket)
|
|
92
|
-
|
|
93
|
-
Logo design by [Jan-Christoph Borchardt](http://jancborchardt.net)
|
|
94
|
-
|
|
95
|
-
Sponsored by [NLNET](http://nlnet.nl)
|
|
96
|
-
|
|
97
|
-
[](http://nlnet.nl)
|
|
10
|
+
This can be used individually if you wish to pick and choose other dependencies.
|
|
98
11
|
|
|
12
|
+
For full sockethub documentation see the [Sockethub README](../sockethub/README.md)
|
package/bin/sockethub
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
process.once('uncaughtException', function (err) {
|
|
8
|
-
console.log('UNCAUGHT EXCEPTION');
|
|
9
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
10
|
-
console.log(err.stack);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
process.once('SIGTERM', function () {
|
|
15
|
-
console.log('Received TERM signal. Exiting.');
|
|
16
|
-
process.exit(0);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
process.once('SIGINT', function () {
|
|
20
|
-
console.log('Received INT signal. Exiting.');
|
|
21
|
-
process.exit(0);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
process.once('exit', async function () {
|
|
25
|
-
console.log('destroying all platform instances');
|
|
26
|
-
await sockethub.removeAllPlatformInstances();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
sockethub.boot();
|
|
30
|
-
})();
|
|
2
|
+
import("@sockethub/server").then((sockethub) => {
|
|
3
|
+
sockethub.server();
|
|
4
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Sockethub launcher with split logging:
|
|
4
|
+
* - Console: filtered via namespace patterns
|
|
5
|
+
* - File: full debug output to sockethub.log
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { createWriteStream } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
|
|
11
|
+
// Console namespace filter. Include patterns show a namespace; a leading "-"
|
|
12
|
+
// excludes it; "*" matches any run of characters. (Self-contained matcher so we
|
|
13
|
+
// don't depend on the legacy `debug` package — Sockethub logs via winston.)
|
|
14
|
+
const CONSOLE_FILTER = [
|
|
15
|
+
"sockethub:init",
|
|
16
|
+
"sockethub:server:bootstrap:*",
|
|
17
|
+
"sockethub:server:core",
|
|
18
|
+
"-sockethub:server:core:*", // exclude per-session logs
|
|
19
|
+
"sockethub:server:listener",
|
|
20
|
+
"sockethub:server:janitor",
|
|
21
|
+
"sockethub:server:rate-limiter",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
function patternToRegExp(pattern: string): RegExp {
|
|
25
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
return new RegExp(`^${escaped.replace(/\*/g, ".*?")}$`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const includes = CONSOLE_FILTER.filter((p) => !p.startsWith("-")).map(
|
|
30
|
+
patternToRegExp,
|
|
31
|
+
);
|
|
32
|
+
const excludes = CONSOLE_FILTER.filter((p) => p.startsWith("-")).map((p) =>
|
|
33
|
+
patternToRegExp(p.slice(1)),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const shouldShow = (namespace: string): boolean => {
|
|
37
|
+
if (excludes.some((re) => re.test(namespace))) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return includes.some((re) => re.test(namespace));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Extract the sockethub namespace from a winston log line
|
|
44
|
+
// (e.g. "2026-… debug: sockethub:server:core message", with optional ANSI colors)
|
|
45
|
+
const namespaceRegex = /sockethub:[^\s\x1b]+/;
|
|
46
|
+
function getNamespace(line: string): string | null {
|
|
47
|
+
const match = line.match(namespaceRegex);
|
|
48
|
+
return match ? match[0] : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const logFile = createWriteStream("sockethub.log", { flags: "a" });
|
|
52
|
+
const timestamp = () => new Date().toISOString();
|
|
53
|
+
|
|
54
|
+
logFile.write(`\n--- Sockethub started at ${timestamp()} ---\n`);
|
|
55
|
+
|
|
56
|
+
const child = spawn("bun", ["run", join(dirname(import.meta.path), "sockethub")], {
|
|
57
|
+
env: { ...process.env, LOG_LEVEL: "debug" },
|
|
58
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function processLine(line: string, stream: "stdout" | "stderr") {
|
|
62
|
+
// Always write to file
|
|
63
|
+
logFile.write(`${line}\n`);
|
|
64
|
+
|
|
65
|
+
// Check if namespace passes the console filter
|
|
66
|
+
// Non-debug lines (console.log from init, errors) are always shown
|
|
67
|
+
const namespace = getNamespace(line);
|
|
68
|
+
const show = namespace
|
|
69
|
+
? shouldShow(namespace)
|
|
70
|
+
: true; // show non-debug lines (startup banner, errors, etc)
|
|
71
|
+
|
|
72
|
+
if (show) {
|
|
73
|
+
if (stream === "stderr") {
|
|
74
|
+
process.stderr.write(`${line}\n`);
|
|
75
|
+
} else {
|
|
76
|
+
process.stdout.write(`${line}\n`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let stdoutBuffer = "";
|
|
82
|
+
let stderrBuffer = "";
|
|
83
|
+
|
|
84
|
+
child.stdout?.on("data", (data) => {
|
|
85
|
+
stdoutBuffer += data.toString();
|
|
86
|
+
const lines = stdoutBuffer.split("\n");
|
|
87
|
+
stdoutBuffer = lines.pop() || "";
|
|
88
|
+
for (const line of lines) {
|
|
89
|
+
processLine(line, "stdout");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
child.stderr?.on("data", (data) => {
|
|
94
|
+
stderrBuffer += data.toString();
|
|
95
|
+
const lines = stderrBuffer.split("\n");
|
|
96
|
+
stderrBuffer = lines.pop() || "";
|
|
97
|
+
for (const line of lines) {
|
|
98
|
+
processLine(line, "stderr");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
child.on("close", (code) => {
|
|
103
|
+
logFile.write(`--- Sockethub exited with code ${code} at ${timestamp()} ---\n`);
|
|
104
|
+
logFile.close();
|
|
105
|
+
process.exit(code || 0);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
109
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
package/build.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2
|
+
const packageJSON = require("./package.json");
|
|
3
|
+
const moduleList = Object.keys(packageJSON.dependencies);
|
|
4
|
+
|
|
5
|
+
const rx = /^@sockethub\/platform-/i;
|
|
6
|
+
const platforms = [];
|
|
7
|
+
|
|
8
|
+
for (const moduleName of moduleList) {
|
|
9
|
+
if (rx.test(moduleName)) {
|
|
10
|
+
platforms.push(moduleName);
|
|
11
|
+
}
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sockethub",
|
|
3
3
|
"description": "A polyglot messaging service",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.21",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
7
7
|
"license": "LGPL-3.0+",
|
|
8
|
-
"main": "
|
|
9
|
-
"bin": "
|
|
8
|
+
"main": "",
|
|
9
|
+
"bin": "bin/sockethub",
|
|
10
10
|
"preferGlobal": true,
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=20"
|
|
13
|
+
},
|
|
11
14
|
"keywords": [
|
|
12
15
|
"sockethub",
|
|
13
16
|
"messaging",
|
|
@@ -34,70 +37,21 @@
|
|
|
34
37
|
},
|
|
35
38
|
"homepage": "https://sockethub.org",
|
|
36
39
|
"dependencies": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"jquery": "^3.4.1",
|
|
45
|
-
"nconf": "^0.11.2",
|
|
46
|
-
"object-hash": "^3.0.0",
|
|
47
|
-
"secure-store-redis": "^1.4.7",
|
|
48
|
-
"socket.io": "^4.0.1",
|
|
49
|
-
"sockethub-platform-dummy": "^3.0.0-alpha.0",
|
|
50
|
-
"sockethub-platform-feeds": "^3.0.0-alpha.0",
|
|
51
|
-
"sockethub-platform-irc": "^4.0.0-alpha.2",
|
|
52
|
-
"sockethub-platform-xmpp": "^5.0.0-alpha.2",
|
|
53
|
-
"sockethub-schemas": "^3.0.0-alpha.2",
|
|
54
|
-
"urijs": "^1.19.2"
|
|
40
|
+
"@sockethub/platform-caldav": "^1.0.0-alpha.5",
|
|
41
|
+
"@sockethub/platform-carddav": "^1.0.0-alpha.2",
|
|
42
|
+
"@sockethub/platform-dummy": "^3.0.0-alpha.21",
|
|
43
|
+
"@sockethub/platform-feeds": "^4.0.0-alpha.21",
|
|
44
|
+
"@sockethub/platform-irc": "^4.0.0-alpha.21",
|
|
45
|
+
"@sockethub/platform-xmpp": "^5.0.0-alpha.21",
|
|
46
|
+
"@sockethub/server": "^5.0.0-alpha.21"
|
|
55
47
|
},
|
|
56
48
|
"scripts": {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"lint:fix": "eslint --fix \"**/*.ts\" ./bin/sockethub",
|
|
64
|
-
"clean": "find . -maxdepth 1 -name dist -exec rm -rv {} +",
|
|
65
|
-
"build": "yarn run clean && yarn run build:server && yarn run build:client",
|
|
66
|
-
"build:server": "tsc && cp ./src/defaults.json ./dist/defaults.json && cp src/bootstrap/platforms.js dist/bootstrap/",
|
|
67
|
-
"build:client": "webpack --config webpack.minified.config.js && webpack --config webpack.normal.config.js"
|
|
68
|
-
},
|
|
69
|
-
"engines": {
|
|
70
|
-
"node": ">= 12.0.0"
|
|
71
|
-
},
|
|
72
|
-
"devDependencies": {
|
|
73
|
-
"@types/body-parser": "1.19.2",
|
|
74
|
-
"@types/chai": "4.3.0",
|
|
75
|
-
"@types/debug": "4.1.7",
|
|
76
|
-
"@types/ejs": "3.1.0",
|
|
77
|
-
"@types/eslint": "8.4.1",
|
|
78
|
-
"@types/express": "4.17.13",
|
|
79
|
-
"@types/jquery": "3.5.13",
|
|
80
|
-
"@types/mocha": "9.1.0",
|
|
81
|
-
"@types/nconf": "0.10.1",
|
|
82
|
-
"@types/node": "17.0.13",
|
|
83
|
-
"@types/object-hash": "2.2.1",
|
|
84
|
-
"@types/proxyquire": "1.3.28",
|
|
85
|
-
"@types/tv4": "1.2.31",
|
|
86
|
-
"@types/urijs": "1.19.18",
|
|
87
|
-
"@typescript-eslint/parser": "5.12.1",
|
|
88
|
-
"c8": "7.11.0",
|
|
89
|
-
"chai": "4.3.6",
|
|
90
|
-
"eslint": "8.9.0",
|
|
91
|
-
"eslint-cli": "1.1.1",
|
|
92
|
-
"eventemitter2": "6.4.5",
|
|
93
|
-
"jaribu": "2.2.3",
|
|
94
|
-
"mocha": "9.2.1",
|
|
95
|
-
"proxyquire": "2.1.3",
|
|
96
|
-
"sinon": "13.0.1",
|
|
97
|
-
"ts-node": "10.5.0",
|
|
98
|
-
"typescript": "4.5.5",
|
|
99
|
-
"webpack": "5.69.1",
|
|
100
|
-
"webpack-cli": "4.9.2"
|
|
49
|
+
"build": "bun build.js",
|
|
50
|
+
"clean:deps": "rm -rf node_modules",
|
|
51
|
+
"dev": "SOCKETHUB_HTTP_ACTIONS_ENABLED=true bun run --hot ./bin/sockethub --examples",
|
|
52
|
+
"info": "node ./bin/sockethub --info",
|
|
53
|
+
"start": "node ./bin/sockethub",
|
|
54
|
+
"start:logged": "bun ./bin/sockethub-logged"
|
|
101
55
|
},
|
|
102
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1d87ef9d415159ef624e86e929ef2a2fb7a4b50e"
|
|
103
57
|
}
|
package/config.json.example
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"activity-streams": {
|
|
3
|
-
"opts": {
|
|
4
|
-
"specialObjs": [ "credentials" ]
|
|
5
|
-
}
|
|
6
|
-
},
|
|
7
|
-
"examples": {
|
|
8
|
-
"enabled": false,
|
|
9
|
-
"secret": 1234567890
|
|
10
|
-
},
|
|
11
|
-
"service": {
|
|
12
|
-
"port": 10550,
|
|
13
|
-
"host": "localhost",
|
|
14
|
-
"path": "/sockethub"
|
|
15
|
-
},
|
|
16
|
-
"log_file": "",
|
|
17
|
-
"platforms": {
|
|
18
|
-
"whitelist": [],
|
|
19
|
-
"blacklist": []
|
|
20
|
-
},
|
|
21
|
-
"public": {
|
|
22
|
-
"protocol": "http",
|
|
23
|
-
"host": "localhost",
|
|
24
|
-
"port": 10550,
|
|
25
|
-
"path": "/"
|
|
26
|
-
},
|
|
27
|
-
"redis": {
|
|
28
|
-
"host": "redis",
|
|
29
|
-
"port": 6379
|
|
30
|
-
},
|
|
31
|
-
"workers": 1
|
|
32
|
-
}
|
package/dist/bootstrap/init.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const debug_1 = __importDefault(require("debug"));
|
|
7
|
-
const config_1 = __importDefault(require("../config"));
|
|
8
|
-
const platforms_1 = __importDefault(require("./platforms"));
|
|
9
|
-
const log = (0, debug_1.default)('sockethub:bootstrap:init');
|
|
10
|
-
log('running init routines');
|
|
11
|
-
const packageJSON = require('./../../package.json');
|
|
12
|
-
const platforms = (0, platforms_1.default)(Object.keys(packageJSON.dependencies));
|
|
13
|
-
log('loaded platforms');
|
|
14
|
-
if (config_1.default.get('help')) {
|
|
15
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
16
|
-
console.log(packageJSON.name + ' ' + packageJSON.version);
|
|
17
|
-
console.log('command line args: ');
|
|
18
|
-
console.log();
|
|
19
|
-
console.log(' --help : this help screen');
|
|
20
|
-
console.log(' --info : displays some basic runtime info');
|
|
21
|
-
console.log();
|
|
22
|
-
console.log(' --examples : enables examples page and serves helper files like jquery');
|
|
23
|
-
console.log();
|
|
24
|
-
console.log(' --host : hostname to bind to');
|
|
25
|
-
console.log(' --port : port to bind to');
|
|
26
|
-
console.log();
|
|
27
|
-
process.exit();
|
|
28
|
-
}
|
|
29
|
-
else if (config_1.default.get('info')) {
|
|
30
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
31
|
-
console.log(packageJSON.name + ' ' + packageJSON.version);
|
|
32
|
-
console.log();
|
|
33
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
34
|
-
console.log('examples enabled: ' + config_1.default.get('examples:enabled'));
|
|
35
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
36
|
-
console.log('sockethub: ' + config_1.default.get('service:host') + ':' + config_1.default.get('service:port')
|
|
37
|
-
+ config_1.default.get('service:path'));
|
|
38
|
-
if (config_1.default.get('redis:url')) {
|
|
39
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
40
|
-
console.log('redis URL: ' + config_1.default.get('redis:url'));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
44
|
-
console.log('redis: ' + config_1.default.get('redis:host') + ':' + config_1.default.get('redis:port'));
|
|
45
|
-
}
|
|
46
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
47
|
-
console.log('public url: ' + config_1.default.get('public:host') + ':' + config_1.default.get('public:port')
|
|
48
|
-
+ config_1.default.get('public:path'));
|
|
49
|
-
console.log();
|
|
50
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
51
|
-
console.log('platforms: ' + Array.from(platforms.keys()).join(', '));
|
|
52
|
-
if (platforms.size > 0) {
|
|
53
|
-
for (let platform of platforms.values()) {
|
|
54
|
-
console.log();
|
|
55
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
56
|
-
console.log(' ' + platform.id + ' v' + platform.version);
|
|
57
|
-
// eslint-disable-next-line security-node/detect-crlf
|
|
58
|
-
console.log(' AS types: ' + platform.types.join(', '));
|
|
59
|
-
}
|
|
60
|
-
console.log();
|
|
61
|
-
process.exit();
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
console.log();
|
|
65
|
-
process.exit();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
log('finished init routines');
|
|
69
|
-
const init = {
|
|
70
|
-
version: packageJSON.version,
|
|
71
|
-
platforms: platforms
|
|
72
|
-
};
|
|
73
|
-
exports.default = init;
|
|
74
|
-
//# sourceMappingURL=/bootstrap/init.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"/","sources":["bootstrap/init.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,uDAA+B;AAC/B,4DAAuC;AAEvC,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,0BAA0B,CAAC,CAAC;AAC9C,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE7B,MAAM,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACpD,MAAM,SAAS,GAAG,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;AACtE,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAExB,IAAI,gBAAM,CAAC,GAAG,CAAC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C,CAAC;AAmB9B,MAAM,IAAI,GAAgB;IACxB,OAAO,EAAE,WAAW,CAAC,OAAO;IAC5B,SAAS,EAAE,SAAS;CACrB,CAAC;AACF,kBAAe,IAAI,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* bootstrap/platforms.js
|
|
3
|
-
*
|
|
4
|
-
* A Singleton responsible for finding and loading all valid sockethub
|
|
5
|
-
* platforms, and whitelisting or blacklisting (or neither) based on the
|
|
6
|
-
* config.
|
|
7
|
-
*/
|
|
8
|
-
const debug = require('debug'),
|
|
9
|
-
schemas = require('sockethub-schemas'),
|
|
10
|
-
findup = require('findup-sync');
|
|
11
|
-
|
|
12
|
-
const config = require('../config').default;
|
|
13
|
-
const log = debug('sockethub:bootstrap:platforms');
|
|
14
|
-
|
|
15
|
-
const whitelist = config.get('platforms:whitelist'),
|
|
16
|
-
blacklist = config.get('platforms:blacklist');
|
|
17
|
-
|
|
18
|
-
log('loading platforms');
|
|
19
|
-
|
|
20
|
-
// checks platform against black and whitelist.
|
|
21
|
-
function platformIsAccepted(platformName) {
|
|
22
|
-
let willLoad = false;
|
|
23
|
-
if (whitelist.length > 0) {
|
|
24
|
-
if (whitelist.indexOf(platformName) >= 0) {
|
|
25
|
-
willLoad = true;
|
|
26
|
-
}
|
|
27
|
-
} else if (blacklist.length > 0) {
|
|
28
|
-
if (blacklist.indexOf(platformName) < 0) {
|
|
29
|
-
willLoad = true;
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
willLoad = true;
|
|
33
|
-
}
|
|
34
|
-
return willLoad;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// if the platform schema lists valid types it implements (essentially methods/verbs for
|
|
38
|
-
// sockethub to call) then add it to the supported types list.
|
|
39
|
-
function platformListsSupportedTypes(p) {
|
|
40
|
-
return ((p.schema.messages.properties) && (p.schema.messages.properties.type) &&
|
|
41
|
-
(p.schema.messages.properties.type.enum) &&
|
|
42
|
-
(p.schema.messages.properties.type.enum.length > 0));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = function platformLoad(moduleList) {
|
|
46
|
-
// load platforms from package.json
|
|
47
|
-
const rx = new RegExp('^sockethub-platform-', 'i');
|
|
48
|
-
const platforms = new Map();
|
|
49
|
-
log('finding and registering platforms from package list');
|
|
50
|
-
|
|
51
|
-
for (let moduleName of moduleList) {
|
|
52
|
-
if (rx.test(moduleName)) {
|
|
53
|
-
// found a sockethub platform
|
|
54
|
-
const platformName = moduleName.replace(rx, '');
|
|
55
|
-
log(`registering ${platformName} platform`);
|
|
56
|
-
|
|
57
|
-
if (platformIsAccepted(platformName)) {
|
|
58
|
-
// try to load platform
|
|
59
|
-
const P = require(moduleName);
|
|
60
|
-
const p = new P();
|
|
61
|
-
let path = findup(moduleName, { cwd: __dirname + '/../../node_modules' });
|
|
62
|
-
if (! path) {
|
|
63
|
-
path = findup(moduleName, { cwd: 'node_modules' });
|
|
64
|
-
}
|
|
65
|
-
const packageJson = require(path + '/package.json');
|
|
66
|
-
let types = [];
|
|
67
|
-
|
|
68
|
-
const err = schemas.validator.validatePlatformSchema(p.schema);
|
|
69
|
-
if (err) {
|
|
70
|
-
throw new Error(`${platformName} ${err}`);
|
|
71
|
-
} else if (typeof p.config !== 'object') {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`${platformName} platform must have a config property that is an object.`);
|
|
74
|
-
} else {
|
|
75
|
-
if (p.schema.credentials) {
|
|
76
|
-
// register the platforms credentials schema
|
|
77
|
-
types.push('credentials');
|
|
78
|
-
} else {
|
|
79
|
-
p.config.noCredentials = true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (platformListsSupportedTypes(p)) {
|
|
84
|
-
types = [...types, ...p.schema.messages.properties.type.enum];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
platforms.set(platformName, {
|
|
88
|
-
id: platformName,
|
|
89
|
-
moduleName: moduleName,
|
|
90
|
-
config: p.config,
|
|
91
|
-
schemas: {
|
|
92
|
-
credentials: p.schema.credentials || {},
|
|
93
|
-
messages: p.schema.messages || {}
|
|
94
|
-
},
|
|
95
|
-
version: packageJson.version,
|
|
96
|
-
types: types
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return platforms;
|
|
103
|
-
};
|
package/dist/common.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decryptJobData = exports.getPlatformId = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("./crypto"));
|
|
8
|
-
function getPlatformId(platform, actor) {
|
|
9
|
-
return actor ? crypto_1.default.hash(platform + actor) : crypto_1.default.hash(platform);
|
|
10
|
-
}
|
|
11
|
-
exports.getPlatformId = getPlatformId;
|
|
12
|
-
function decryptJobData(job, secret) {
|
|
13
|
-
return {
|
|
14
|
-
title: job.data.title,
|
|
15
|
-
msg: crypto_1.default.decrypt(job.data.msg, secret),
|
|
16
|
-
sessionId: job.data.sessionId
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.decryptJobData = decryptJobData;
|
|
20
|
-
//# sourceMappingURL=/common.js.map
|
package/dist/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"/","sources":["common.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAG9B,SAAgB,aAAa,CAAC,QAAgB,EAAE,KAAc;IAC5D,OAAO,KAAK,CAAC,CAAC,CAAC,gBAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAFD,sCAEC;AAED,SAAgB,cAAc,CAAC,GAAiB,EAAE,MAAc;IAC9D,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;QACrB,GAAG,EAAE,gBAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;QACzC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS;KAC9B,CAAC;AACJ,CAAC;AAND,wCAMC"}
|
package/dist/config.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Config = void 0;
|
|
7
|
-
const nconf_1 = __importDefault(require("nconf"));
|
|
8
|
-
const debug_1 = require("debug");
|
|
9
|
-
const log = (0, debug_1.debug)('sockethub:bootstrap:config');
|
|
10
|
-
class Config {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.get = (key) => nconf_1.default.get(key);
|
|
13
|
-
log('initializing config');
|
|
14
|
-
// assign config loading priorities (command-line, environment, cfg, defaults)
|
|
15
|
-
nconf_1.default.argv({
|
|
16
|
-
'port': {
|
|
17
|
-
alias: 'service.port'
|
|
18
|
-
},
|
|
19
|
-
'host': {
|
|
20
|
-
alias: 'service.host'
|
|
21
|
-
},
|
|
22
|
-
'redis_host': {
|
|
23
|
-
alias: 'redis.host'
|
|
24
|
-
},
|
|
25
|
-
'redis_port': {
|
|
26
|
-
alias: 'redis.port'
|
|
27
|
-
},
|
|
28
|
-
'redis_url': {
|
|
29
|
-
alias: 'redis.url'
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
nconf_1.default.env();
|
|
33
|
-
// get value of flags defined by any command-line params
|
|
34
|
-
const examples = nconf_1.default.get('examples');
|
|
35
|
-
// Load the main config
|
|
36
|
-
nconf_1.default.file(__dirname + '/../config.json');
|
|
37
|
-
// only override config file if explicitly mentioned in command-line params
|
|
38
|
-
nconf_1.default.set('examples:enabled', (examples ? true : nconf_1.default.get('examples:enabled')));
|
|
39
|
-
// load defaults
|
|
40
|
-
const defaults = require(__dirname + '/defaults.json');
|
|
41
|
-
nconf_1.default.defaults(defaults);
|
|
42
|
-
nconf_1.default.required(['platforms:whitelist', 'platforms:blacklist']);
|
|
43
|
-
function defaultEnvParams(host, port, prop) {
|
|
44
|
-
nconf_1.default.set(prop + ':host', host);
|
|
45
|
-
nconf_1.default.set(prop + ':port', port);
|
|
46
|
-
}
|
|
47
|
-
defaultEnvParams(process.env.HOST || nconf_1.default.get('service:host'), process.env.PORT || nconf_1.default.get('service:port'), 'service');
|
|
48
|
-
defaultEnvParams(process.env.REDIS_HOST || nconf_1.default.get('redis:host'), process.env.REDIS_PORT || nconf_1.default.get('redis:port'), 'redis');
|
|
49
|
-
// allow a redis://user:host:port url, takes precedence
|
|
50
|
-
if (process.env.REDIS_URL) {
|
|
51
|
-
nconf_1.default.set('redis:url', process.env.REDIS_URL);
|
|
52
|
-
nconf_1.default.clear('redis:host');
|
|
53
|
-
nconf_1.default.clear('redis:port');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.Config = Config;
|
|
58
|
-
const config = new Config();
|
|
59
|
-
exports.default = config;
|
|
60
|
-
//# sourceMappingURL=/config.js.map
|