@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.
Files changed (105) hide show
  1. package/README.md +54 -60
  2. package/bin/sockethub +4 -3
  3. package/package.json +42 -54
  4. package/res/socket.io.js +4908 -0
  5. package/res/sockethub-client.js +602 -0
  6. package/res/sockethub-client.min.js +19 -0
  7. package/sockethub.config.example.json +2 -3
  8. package/src/bootstrap/init.d.ts +16 -13
  9. package/src/bootstrap/init.test.ts +211 -0
  10. package/src/bootstrap/init.ts +152 -76
  11. package/src/bootstrap/load-platforms.ts +151 -0
  12. package/src/config.test.ts +27 -22
  13. package/src/config.ts +82 -86
  14. package/src/defaults.json +24 -16
  15. package/src/index.ts +61 -22
  16. package/src/janitor.test.ts +191 -169
  17. package/src/janitor.ts +141 -118
  18. package/src/listener.ts +148 -58
  19. package/src/middleware/create-activity-object.test.ts +28 -8
  20. package/src/middleware/create-activity-object.ts +16 -10
  21. package/src/middleware/expand-activity-stream.test.data.ts +331 -345
  22. package/src/middleware/expand-activity-stream.test.ts +65 -66
  23. package/src/middleware/expand-activity-stream.ts +26 -21
  24. package/src/middleware/store-credentials.test.ts +74 -60
  25. package/src/middleware/store-credentials.ts +14 -8
  26. package/src/middleware/validate.test.data.ts +240 -242
  27. package/src/middleware/validate.test.ts +39 -78
  28. package/src/middleware/validate.ts +62 -36
  29. package/src/middleware.test.ts +168 -138
  30. package/src/middleware.ts +57 -55
  31. package/src/platform-instance.test.ts +508 -214
  32. package/src/platform-instance.ts +324 -231
  33. package/src/platform.test.ts +375 -0
  34. package/src/platform.ts +306 -117
  35. package/src/process-manager.ts +75 -51
  36. package/src/routes.test.ts +43 -89
  37. package/src/routes.ts +40 -78
  38. package/src/sentry.test.ts +106 -0
  39. package/src/sentry.ts +19 -0
  40. package/src/sockethub.ts +190 -129
  41. package/src/util.ts +5 -0
  42. package/coverage/tmp/coverage-39338-1663949520416-0.json +0 -1
  43. package/dist/bootstrap/init.d.ts +0 -18
  44. package/dist/bootstrap/init.js +0 -64
  45. package/dist/bootstrap/init.js.map +0 -1
  46. package/dist/bootstrap/platforms.js +0 -75
  47. package/dist/config.d.ts +0 -12
  48. package/dist/config.js +0 -107
  49. package/dist/config.js.map +0 -1
  50. package/dist/defaults.json +0 -28
  51. package/dist/index.d.ts +0 -1
  52. package/dist/index.js +0 -29
  53. package/dist/index.js.map +0 -1
  54. package/dist/janitor.d.ts +0 -30
  55. package/dist/janitor.js +0 -120
  56. package/dist/janitor.js.map +0 -1
  57. package/dist/listener.d.ts +0 -31
  58. package/dist/listener.js +0 -94
  59. package/dist/listener.js.map +0 -1
  60. package/dist/middleware/create-activity-object.d.ts +0 -8
  61. package/dist/middleware/create-activity-object.js +0 -19
  62. package/dist/middleware/create-activity-object.js.map +0 -1
  63. package/dist/middleware/expand-activity-stream.d.ts +0 -3
  64. package/dist/middleware/expand-activity-stream.js +0 -36
  65. package/dist/middleware/expand-activity-stream.js.map +0 -1
  66. package/dist/middleware/expand-activity-stream.test.data.d.ts +0 -480
  67. package/dist/middleware/expand-activity-stream.test.data.js +0 -360
  68. package/dist/middleware/expand-activity-stream.test.data.js.map +0 -1
  69. package/dist/middleware/store-credentials.d.ts +0 -3
  70. package/dist/middleware/store-credentials.js +0 -9
  71. package/dist/middleware/store-credentials.js.map +0 -1
  72. package/dist/middleware/validate.d.ts +0 -2
  73. package/dist/middleware/validate.js +0 -56
  74. package/dist/middleware/validate.js.map +0 -1
  75. package/dist/middleware/validate.test.data.d.ts +0 -532
  76. package/dist/middleware/validate.test.data.js +0 -263
  77. package/dist/middleware/validate.test.data.js.map +0 -1
  78. package/dist/middleware.d.ts +0 -21
  79. package/dist/middleware.js +0 -56
  80. package/dist/middleware.js.map +0 -1
  81. package/dist/platform-instance.d.ts +0 -78
  82. package/dist/platform-instance.js +0 -226
  83. package/dist/platform-instance.js.map +0 -1
  84. package/dist/platform.d.ts +0 -6
  85. package/dist/platform.js +0 -176
  86. package/dist/platform.js.map +0 -1
  87. package/dist/process-manager.d.ts +0 -11
  88. package/dist/process-manager.js +0 -82
  89. package/dist/process-manager.js.map +0 -1
  90. package/dist/routes.d.ts +0 -13
  91. package/dist/routes.js +0 -83
  92. package/dist/routes.js.map +0 -1
  93. package/dist/sockethub.d.ts +0 -18
  94. package/dist/sockethub.js +0 -112
  95. package/dist/sockethub.js.map +0 -1
  96. package/src/bootstrap/platforms.js +0 -75
  97. package/test/init-suite.js +0 -41
  98. package/test/sockethub-suite.js +0 -25
  99. package/tsconfig.json +0 -18
  100. package/views/examples/dummy.ejs +0 -95
  101. package/views/examples/feeds.ejs +0 -90
  102. package/views/examples/irc.ejs +0 -239
  103. package/views/examples/shared.js +0 -72
  104. package/views/examples/xmpp.ejs +0 -217
  105. package/views/index.ejs +0 -17
package/README.md CHANGED
@@ -1,100 +1,94 @@
1
- [![Sockethub](http://sockethub.org/res/img/sockethub-logo.svg)](http://sockethub.org)
2
-
3
- # Sockethub
4
-
5
- A protocol gateway for the web.
1
+ # @sockethub/server
6
2
 
7
3
  ## About
8
4
 
9
- Sockethub is a translation layer for web applications to communicate with
10
- other protocols and services that are traditionally either inaccessible or
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
- ## Features
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
- We use ActivityStreams to map the various actions of a platform to a set of AS
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
- Below is a list of platform contexts we're currently working on and their types,
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
- ## Platforms
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
- * [Feeds](../platform-feeds) *(RSS, Atom)*
23
+ ## Documentation
56
24
 
57
- * [IRC](../platform-irc)
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
- `$ npm install -g @sockethub/server`
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
- * PORT
38
+ - PORT
70
39
 
71
40
  Default: `10550`
72
41
 
73
- * HOST
42
+ - HOST
74
43
 
75
44
  Default: `localhost`
76
45
 
77
- * DEBUG
46
+ - DEBUG
78
47
 
79
- Specify the namespace to console log, ie. `sockethub*` will print all sockethub
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
- * REDIS_PORT
52
+ - REDIS_PORT
84
53
 
85
54
  Default: `6379`
86
55
 
87
- * REDIS_HOST
56
+ - REDIS_HOST
88
57
 
89
58
  Default: `localhost`
90
59
 
91
60
  ***OR***
92
61
 
93
- * REDIS_URL
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 node
2
- const sockethubServer = require(`./../dist/index`);
3
- sockethubServer();
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",
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
- "main": "dist/index.js",
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
- "@sockethub/activity-streams": "^4.4.0-alpha.4",
38
- "@sockethub/client": "^5.0.0-alpha.4",
39
- "@sockethub/crypto": "^1.0.0-alpha.4",
40
- "@sockethub/data-layer": "^1.0.0-alpha.4",
41
- "@sockethub/schemas": "^3.0.0-alpha.4",
42
- "body-parser": "^1.19.0",
43
- "debug": "^4.3.1",
44
- "ejs": "^3.0.1",
45
- "express": "^4.17.1",
46
- "jquery": "^3.4.1",
47
- "nconf": "^0.12.0",
48
- "npm": "8.19.2",
49
- "socket.io": "^4.0.1"
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
- "clean": "npx rimraf dist coverage",
53
- "clean:deps": "npx rimraf node_modules",
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.2",
68
- "@types/chai": "4.3.3",
69
- "@types/debug": "4.1.7",
70
- "@types/eslint": "8.4.6",
71
- "@types/express": "4.17.14",
72
- "@types/jquery": "3.5.14",
73
- "@types/mocha": "9.1.1",
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
- "mocha": "10.0.0",
85
- "proxyquire": "2.1.3",
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/platform-dummy": "^3.0.0-alpha.4",
92
- "@sockethub/platform-feeds": "^3.0.0-alpha.4",
93
- "@sockethub/platform-irc": "^4.0.0-alpha.4",
94
- "@sockethub/platform-xmpp": "^5.0.0-alpha.4"
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": "c6d34ff44d2be479e4ea42c46da649612342a680"
84
+ "gitHead": "f8a937e071e7a209f94b94f63e68faa27784e00e"
97
85
  }