@sockethub/server 5.0.0-alpha.4 → 5.0.0-alpha.6
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 +54 -60
- package/bin/sockethub +4 -3
- package/package.json +42 -54
- package/res/socket.io.js +4908 -0
- package/res/sockethub-client.js +602 -0
- package/res/sockethub-client.min.js +19 -0
- package/sockethub.config.example.json +2 -3
- package/src/bootstrap/init.d.ts +16 -13
- package/src/bootstrap/init.test.ts +211 -0
- package/src/bootstrap/init.ts +152 -76
- package/src/bootstrap/load-platforms.ts +151 -0
- package/src/config.test.ts +27 -22
- package/src/config.ts +82 -86
- package/src/defaults.json +24 -16
- package/src/index.ts +61 -22
- package/src/janitor.test.ts +191 -169
- package/src/janitor.ts +141 -118
- package/src/listener.ts +148 -58
- package/src/middleware/create-activity-object.test.ts +28 -8
- package/src/middleware/create-activity-object.ts +16 -10
- package/src/middleware/expand-activity-stream.test.data.ts +331 -345
- package/src/middleware/expand-activity-stream.test.ts +65 -66
- package/src/middleware/expand-activity-stream.ts +26 -21
- package/src/middleware/store-credentials.test.ts +74 -60
- package/src/middleware/store-credentials.ts +14 -8
- package/src/middleware/validate.test.data.ts +240 -242
- package/src/middleware/validate.test.ts +39 -78
- package/src/middleware/validate.ts +62 -36
- package/src/middleware.test.ts +168 -138
- package/src/middleware.ts +57 -55
- package/src/platform-instance.test.ts +508 -214
- package/src/platform-instance.ts +324 -231
- package/src/platform.test.ts +375 -0
- package/src/platform.ts +306 -117
- package/src/process-manager.ts +75 -51
- package/src/routes.test.ts +43 -89
- package/src/routes.ts +40 -78
- package/src/sentry.test.ts +106 -0
- package/src/sentry.ts +19 -0
- package/src/sockethub.ts +190 -129
- package/src/util.ts +5 -0
- package/coverage/tmp/coverage-39338-1663949520416-0.json +0 -1
- package/dist/bootstrap/init.d.ts +0 -18
- package/dist/bootstrap/init.js +0 -64
- package/dist/bootstrap/init.js.map +0 -1
- package/dist/bootstrap/platforms.js +0 -75
- package/dist/config.d.ts +0 -12
- package/dist/config.js +0 -107
- package/dist/config.js.map +0 -1
- package/dist/defaults.json +0 -28
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -29
- package/dist/index.js.map +0 -1
- package/dist/janitor.d.ts +0 -30
- package/dist/janitor.js +0 -120
- package/dist/janitor.js.map +0 -1
- package/dist/listener.d.ts +0 -31
- package/dist/listener.js +0 -94
- package/dist/listener.js.map +0 -1
- package/dist/middleware/create-activity-object.d.ts +0 -8
- 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.d.ts +0 -3
- package/dist/middleware/expand-activity-stream.js +0 -36
- package/dist/middleware/expand-activity-stream.js.map +0 -1
- package/dist/middleware/expand-activity-stream.test.data.d.ts +0 -480
- 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.d.ts +0 -3
- package/dist/middleware/store-credentials.js +0 -9
- package/dist/middleware/store-credentials.js.map +0 -1
- package/dist/middleware/validate.d.ts +0 -2
- package/dist/middleware/validate.js +0 -56
- package/dist/middleware/validate.js.map +0 -1
- package/dist/middleware/validate.test.data.d.ts +0 -532
- package/dist/middleware/validate.test.data.js +0 -263
- package/dist/middleware/validate.test.data.js.map +0 -1
- package/dist/middleware.d.ts +0 -21
- package/dist/middleware.js +0 -56
- package/dist/middleware.js.map +0 -1
- package/dist/platform-instance.d.ts +0 -78
- package/dist/platform-instance.js +0 -226
- package/dist/platform-instance.js.map +0 -1
- package/dist/platform.d.ts +0 -6
- package/dist/platform.js +0 -176
- package/dist/platform.js.map +0 -1
- package/dist/process-manager.d.ts +0 -11
- package/dist/process-manager.js +0 -82
- package/dist/process-manager.js.map +0 -1
- package/dist/routes.d.ts +0 -13
- package/dist/routes.js +0 -83
- package/dist/routes.js.map +0 -1
- package/dist/sockethub.d.ts +0 -18
- package/dist/sockethub.js +0 -112
- package/dist/sockethub.js.map +0 -1
- package/src/bootstrap/platforms.js +0 -75
- package/test/init-suite.js +0 -41
- package/test/sockethub-suite.js +0 -25
- package/tsconfig.json +0 -18
- package/views/examples/dummy.ejs +0 -95
- 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 -217
- package/views/index.ejs +0 -17
package/README.md
CHANGED
|
@@ -1,100 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# Sockethub
|
|
4
|
-
|
|
5
|
-
A protocol gateway for the web.
|
|
1
|
+
# @sockethub/server
|
|
6
2
|
|
|
7
3
|
## About
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
impractical to use from in-browser JavaScript.
|
|
12
|
-
|
|
13
|
-
Using [ActivityStream](http://activitystrea.ms/) (AS) objects to pass messages
|
|
14
|
-
to and from the web app, Sockethub acts as a smart proxy server/agent, which
|
|
15
|
-
can maintain state, and connect to sockets, endpoints and networks that would
|
|
16
|
-
otherwise be restricted from an application running in the browser.
|
|
17
|
-
|
|
18
|
-
Originally inspired as a sister project to
|
|
19
|
-
[RemoteStorage](https://remotestorage.io), and assisting in the development of
|
|
20
|
-
[unhosted](http://unhosted.org) and [noBackend](http://nobackend.org)
|
|
21
|
-
applications, Sockethub's functionality can also fit into a more traditional
|
|
22
|
-
development stack, removing the need for custom code to handle various protocol
|
|
23
|
-
specifics at the application layer.
|
|
24
|
-
|
|
25
|
-
Example uses of Sockethub are:
|
|
26
|
-
|
|
27
|
-
* Writing and receiving messages (SMTP, IMAP, Facebook, Twitter, ...)
|
|
28
|
-
|
|
29
|
-
* Instant messaging (XMPP, IRC, MSN, FB Messenger, Hangouts, ...)
|
|
30
|
-
|
|
31
|
-
* Discovery (WebFinger, RDF(a), ...)
|
|
32
|
-
|
|
33
|
-
The architecture of Sockethub is extensible and supports easy implementation
|
|
34
|
-
of additional 'platforms' to carry out tasks.
|
|
35
|
-
|
|
36
|
-
## Docs
|
|
37
|
-
|
|
38
|
-
See the [Sockethub wiki](https://github.com/sockethub/sockethub/wiki) for
|
|
39
|
-
documentation.
|
|
5
|
+
The core Sockethub server package that handles client connections, manages platform
|
|
6
|
+
instances, and orchestrates message routing between web clients and protocol platforms.
|
|
40
7
|
|
|
41
|
-
|
|
8
|
+
This package can be used independently if you want to build a custom Sockethub
|
|
9
|
+
deployment or integrate server functionality into your own application. For a complete
|
|
10
|
+
setup with all platforms and dependencies, use the main `sockethub` package instead.
|
|
42
11
|
|
|
43
|
-
|
|
44
|
-
'@type's which identify the underlying action. For example, using the XMPP
|
|
45
|
-
platform, a friend request/accept cycle would use the activity stream types
|
|
46
|
-
'request-friend', 'remove-friend', 'make-friend'.
|
|
12
|
+
## Architecture
|
|
47
13
|
|
|
48
|
-
|
|
49
|
-
both the completed and not yet implemented ones. They are all implemented in
|
|
50
|
-
Sockethub platforms (each in their own repository) and can be enabled/disabled
|
|
51
|
-
in the `config.json`.
|
|
14
|
+
The server implements:
|
|
52
15
|
|
|
53
|
-
|
|
16
|
+
- **Socket.IO Connection Management**: Handles web client connections and real-time communication
|
|
17
|
+
- **Platform Instance Management**: Spawns and manages child processes for each protocol platform
|
|
18
|
+
- **Job Queue Integration**: Uses Redis and BullMQ for reliable message queuing
|
|
19
|
+
- **Middleware Pipeline**: Extensible request processing including validation and credential storage
|
|
20
|
+
- **Session Management**: Per-connection credential isolation and state management
|
|
21
|
+
- **Error Reporting**: Optional Sentry integration for production error monitoring and debugging
|
|
54
22
|
|
|
55
|
-
|
|
23
|
+
## Documentation
|
|
56
24
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* [XMPP](../platform-xmpp)
|
|
25
|
+
For complete Sockethub documentation, see the [main repository README](../../README.md)
|
|
26
|
+
and [Sockethub wiki](https://github.com/sockethub/sockethub/wiki).
|
|
60
27
|
|
|
61
28
|
## Install
|
|
62
29
|
|
|
63
|
-
`$
|
|
30
|
+
`$ bun install -g @sockethub/server`
|
|
64
31
|
|
|
65
32
|
## Running
|
|
66
33
|
|
|
34
|
+
`$ DEBUG=sockethub* bunx @sockethub/server`
|
|
35
|
+
|
|
67
36
|
### Environment Variables
|
|
68
37
|
|
|
69
|
-
|
|
38
|
+
- PORT
|
|
70
39
|
|
|
71
40
|
Default: `10550`
|
|
72
41
|
|
|
73
|
-
|
|
42
|
+
- HOST
|
|
74
43
|
|
|
75
44
|
Default: `localhost`
|
|
76
45
|
|
|
77
|
-
|
|
46
|
+
- DEBUG
|
|
78
47
|
|
|
79
|
-
Specify the namespace to console log,
|
|
48
|
+
Specify the namespace to console log, e.g. `sockethub*` will print all sockethub
|
|
80
49
|
related debug statements, whereas `*` will also print any other modules debug
|
|
81
50
|
statements that use the `debug` module.
|
|
82
51
|
|
|
83
|
-
|
|
52
|
+
- REDIS_PORT
|
|
84
53
|
|
|
85
54
|
Default: `6379`
|
|
86
55
|
|
|
87
|
-
|
|
56
|
+
- REDIS_HOST
|
|
88
57
|
|
|
89
58
|
Default: `localhost`
|
|
90
59
|
|
|
91
60
|
***OR***
|
|
92
61
|
|
|
93
|
-
|
|
62
|
+
- REDIS_URL
|
|
94
63
|
|
|
95
64
|
Overrides `REDIS_HOST` and `REDIS_PORT`, can specify a full redis connect URL
|
|
96
65
|
(eq. `redis://username:password@host:port`)
|
|
97
66
|
|
|
67
|
+
#### Sentry Configuration
|
|
68
|
+
|
|
69
|
+
Sentry error reporting can be configured via environment variable or config file:
|
|
70
|
+
|
|
71
|
+
**Environment Variable:**
|
|
72
|
+
|
|
73
|
+
- SENTRY_DSN - Set this to enable basic Sentry error reporting
|
|
74
|
+
|
|
75
|
+
**Config File:**
|
|
76
|
+
For more advanced Sentry configuration, add a `sentry` section to your
|
|
77
|
+
`sockethub.config.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"sentry": {
|
|
82
|
+
"dsn": "https://your-dsn@sentry.io/project-id",
|
|
83
|
+
"environment": "production",
|
|
84
|
+
"traceSampleRate": 1.0
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
When configured, the server automatically reports errors to Sentry for monitoring and
|
|
90
|
+
debugging in production environments.
|
|
91
|
+
|
|
98
92
|
### Command-line params
|
|
99
93
|
|
|
100
94
|
```
|
|
@@ -111,14 +105,14 @@ Overrides `REDIS_HOST` and `REDIS_PORT`, can specify a full redis connect URL
|
|
|
111
105
|
|
|
112
106
|
Run with debug output and examples enabled:
|
|
113
107
|
|
|
114
|
-
`$ DEBUG=sockethub* sockethub --examples`
|
|
108
|
+
`$ DEBUG=sockethub* bin/sockethub --examples`
|
|
115
109
|
|
|
116
110
|
You should then be able to browse to `http://localhost:10550/examples` and try
|
|
117
111
|
out the examples.
|
|
118
112
|
|
|
119
113
|
For production, with examples disabled.
|
|
120
114
|
|
|
121
|
-
`$ DEBUG=sockethub* sockethub`
|
|
115
|
+
`$ DEBUG=sockethub* bin/sockethub`
|
|
122
116
|
|
|
123
117
|
## License
|
|
124
118
|
|
package/bin/sockethub
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import("@sockethub/server").then((sockethub) => {
|
|
3
|
+
sockethub.server();
|
|
4
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sockethub/server",
|
|
3
3
|
"description": "A polyglot messaging service, server libraries",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.6",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"private": false,
|
|
6
7
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
7
8
|
"license": "LGPL-3.0+",
|
|
8
|
-
"
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"main": "src/index.ts",
|
|
9
13
|
"bin": "bin/sockethub",
|
|
10
14
|
"preferGlobal": true,
|
|
15
|
+
"engines": {
|
|
16
|
+
"bun": ">=1.2.4"
|
|
17
|
+
},
|
|
11
18
|
"keywords": [
|
|
12
19
|
"sockethub",
|
|
13
20
|
"messaging",
|
|
@@ -34,64 +41,45 @@
|
|
|
34
41
|
},
|
|
35
42
|
"homepage": "https://sockethub.org",
|
|
36
43
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@sockethub/
|
|
39
|
-
"@sockethub/
|
|
40
|
-
"@sockethub/
|
|
41
|
-
"@sockethub/
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
44
|
+
"@sentry/bun": "^10.15.0",
|
|
45
|
+
"@sockethub/activity-streams": "^4.4.0-alpha.6",
|
|
46
|
+
"@sockethub/client": "^5.0.0-alpha.6",
|
|
47
|
+
"@sockethub/crypto": "^1.0.0-alpha.6",
|
|
48
|
+
"@sockethub/data-layer": "^1.0.0-alpha.6",
|
|
49
|
+
"@sockethub/schemas": "^3.0.0-alpha.6",
|
|
50
|
+
"body-parser": "1.20.3",
|
|
51
|
+
"chalk": "^5.3.0",
|
|
52
|
+
"debug": "4.3.4",
|
|
53
|
+
"ejs": "3.1.10",
|
|
54
|
+
"express": "4.20.0",
|
|
55
|
+
"express-rate-limit": "^8.2.1",
|
|
56
|
+
"jquery": "3.7.1",
|
|
57
|
+
"nconf": "0.12.1",
|
|
58
|
+
"socket.io": "4.7.5"
|
|
50
59
|
},
|
|
51
60
|
"scripts": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"compliance": "yarn run lint && yarn run test && yarn run coverage",
|
|
55
|
-
"test": "c8 -x src/bootstrap -x \"src/**/*.test.*\" mocha -r ts-node/register src/*.test.ts src/**/*.test.ts",
|
|
56
|
-
"coverage": "c8 check-coverage --statements 90 --branches 80 --functions 82 --lines 90",
|
|
57
|
-
"start": "DEBUG=sockethub* ./bin/sockethub",
|
|
58
|
-
"dev": "yarn run build && DEBUG=sockethub* ./bin/sockethub --examples",
|
|
59
|
-
"lint": "eslint \"**/*.ts\" ./bin/sockethub",
|
|
60
|
-
"lint:fix": "eslint --fix \"**/*.ts\" ./bin/sockethub",
|
|
61
|
-
"build": "npx rimraf dist && tsc && cp ./src/defaults.json ./dist/defaults.json && cp src/bootstrap/platforms.js dist/bootstrap/"
|
|
62
|
-
},
|
|
63
|
-
"engines": {
|
|
64
|
-
"node": ">= 14"
|
|
61
|
+
"dev": "DEBUG=sockethub* bun run --hot ./bin/sockethub --examples",
|
|
62
|
+
"start": "DEBUG=sockethub* bun run ./bin/sockethub"
|
|
65
63
|
},
|
|
66
64
|
"devDependencies": {
|
|
67
|
-
"@types/body-parser": "1.19.
|
|
68
|
-
"@types/
|
|
69
|
-
"@types/debug": "4.1.
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/nconf": "0.10.3",
|
|
75
|
-
"@types/node": "17.0.13",
|
|
76
|
-
"@types/proxyquire": "1.3.28",
|
|
77
|
-
"@types/sinon": "10.0.13",
|
|
78
|
-
"@typescript-eslint/parser": "5.37.0",
|
|
79
|
-
"c8": "7.12.0",
|
|
80
|
-
"chai": "4.3.6",
|
|
81
|
-
"eslint": "8.23.1",
|
|
82
|
-
"eslint-cli": "1.1.1",
|
|
65
|
+
"@types/body-parser": "1.19.5",
|
|
66
|
+
"@types/bun": "latest",
|
|
67
|
+
"@types/debug": "4.1.12",
|
|
68
|
+
"@types/express": "4.17.21",
|
|
69
|
+
"@types/jquery": "3.5.29",
|
|
70
|
+
"@types/nconf": "0.10.6",
|
|
71
|
+
"@types/sinon": "17.0.2",
|
|
83
72
|
"jaribu": "2.2.3",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"sinon": "14.0.0",
|
|
87
|
-
"ts-node": "10.9.1",
|
|
88
|
-
"typescript": "4.8.3"
|
|
73
|
+
"sinon": "17.0.1",
|
|
74
|
+
"web-streams-polyfill": "^3.3.3"
|
|
89
75
|
},
|
|
90
76
|
"optionalDependencies": {
|
|
91
|
-
"@sockethub/
|
|
92
|
-
"@sockethub/platform-
|
|
93
|
-
"@sockethub/platform-
|
|
94
|
-
"@sockethub/platform-
|
|
77
|
+
"@sockethub/examples": "^1.0.0-alpha.6",
|
|
78
|
+
"@sockethub/platform-dummy": "3.0.0-alpha.6",
|
|
79
|
+
"@sockethub/platform-feeds": "4.0.0-alpha.6",
|
|
80
|
+
"@sockethub/platform-irc": "4.0.0-alpha.6",
|
|
81
|
+
"@sockethub/platform-metadata": "1.0.1-alpha.1",
|
|
82
|
+
"@sockethub/platform-xmpp": "5.0.0-alpha.6"
|
|
95
83
|
},
|
|
96
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f8a937e071e7a209f94b94f63e68faa27784e00e"
|
|
97
85
|
}
|