sockethub 5.0.0-alpha.0 → 5.0.0-alpha.3

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 (102) hide show
  1. package/bin/sockethub +2 -29
  2. package/build.js +21 -0
  3. package/package.json +15 -65
  4. package/{dist/defaults.json → sockethub.config.json} +8 -7
  5. package/tsconfig.json +6 -68
  6. package/README.md +0 -98
  7. package/config.json.example +0 -32
  8. package/coverage/tmp/coverage-15699-1646422276150-0.json +0 -1
  9. package/dist/bootstrap/init.js +0 -74
  10. package/dist/bootstrap/init.js.map +0 -1
  11. package/dist/bootstrap/platforms.js +0 -103
  12. package/dist/common.js +0 -20
  13. package/dist/common.js.map +0 -1
  14. package/dist/config.js +0 -60
  15. package/dist/config.js.map +0 -1
  16. package/dist/crypto.js +0 -38
  17. package/dist/crypto.js.map +0 -1
  18. package/dist/janitor.js +0 -98
  19. package/dist/janitor.js.map +0 -1
  20. package/dist/middleware/create-activity-object.js +0 -19
  21. package/dist/middleware/create-activity-object.js.map +0 -1
  22. package/dist/middleware/expand-activity-stream.js +0 -33
  23. package/dist/middleware/expand-activity-stream.js.map +0 -1
  24. package/dist/middleware/expand-activity-stream.test.data.js +0 -360
  25. package/dist/middleware/expand-activity-stream.test.data.js.map +0 -1
  26. package/dist/middleware/store-credentials.js +0 -19
  27. package/dist/middleware/store-credentials.js.map +0 -1
  28. package/dist/middleware/validate.js +0 -77
  29. package/dist/middleware/validate.js.map +0 -1
  30. package/dist/middleware/validate.test.data.js +0 -321
  31. package/dist/middleware/validate.test.data.js.map +0 -1
  32. package/dist/middleware.js +0 -54
  33. package/dist/middleware.js.map +0 -1
  34. package/dist/platform-instance.js +0 -226
  35. package/dist/platform-instance.js.map +0 -1
  36. package/dist/platform.js +0 -186
  37. package/dist/platform.js.map +0 -1
  38. package/dist/process-manager.js +0 -78
  39. package/dist/process-manager.js.map +0 -1
  40. package/dist/routes.js +0 -84
  41. package/dist/routes.js.map +0 -1
  42. package/dist/serve.js +0 -102
  43. package/dist/serve.js.map +0 -1
  44. package/dist/sockethub-client.js +0 -2604
  45. package/dist/sockethub-client.js.map +0 -1
  46. package/dist/sockethub-client.min.js +0 -2
  47. package/dist/sockethub-client.min.js.LICENSE.txt +0 -24
  48. package/dist/sockethub.js +0 -130
  49. package/dist/sockethub.js.map +0 -1
  50. package/dist/store.js +0 -17
  51. package/dist/store.js.map +0 -1
  52. package/src/bootstrap/init.d.ts +0 -8
  53. package/src/bootstrap/init.ts +0 -91
  54. package/src/bootstrap/platforms.js +0 -103
  55. package/src/common.test.ts +0 -54
  56. package/src/common.ts +0 -14
  57. package/src/config.d.ts +0 -2
  58. package/src/config.test.ts +0 -28
  59. package/src/config.ts +0 -72
  60. package/src/crypto.d.ts +0 -5
  61. package/src/crypto.test.ts +0 -41
  62. package/src/crypto.ts +0 -41
  63. package/src/defaults.json +0 -32
  64. package/src/janitor.d.ts +0 -8
  65. package/src/janitor.ts +0 -89
  66. package/src/middleware/create-activity-object.test.ts +0 -10
  67. package/src/middleware/create-activity-object.ts +0 -13
  68. package/src/middleware/expand-activity-stream.test.data.ts +0 -365
  69. package/src/middleware/expand-activity-stream.test.ts +0 -78
  70. package/src/middleware/expand-activity-stream.ts +0 -27
  71. package/src/middleware/store-credentials.test.ts +0 -72
  72. package/src/middleware/store-credentials.ts +0 -16
  73. package/src/middleware/validate.d.ts +0 -1
  74. package/src/middleware/validate.test.data.ts +0 -320
  75. package/src/middleware/validate.test.ts +0 -47
  76. package/src/middleware/validate.ts +0 -49
  77. package/src/middleware.d.ts +0 -21
  78. package/src/middleware.test.ts +0 -148
  79. package/src/middleware.ts +0 -52
  80. package/src/platform-instance.test.ts +0 -237
  81. package/src/platform-instance.ts +0 -236
  82. package/src/platform.ts +0 -189
  83. package/src/process-manager.ts +0 -64
  84. package/src/routes.test.ts +0 -100
  85. package/src/routes.ts +0 -93
  86. package/src/serve.ts +0 -79
  87. package/src/sockethub-client.test.ts +0 -235
  88. package/src/sockethub-client.ts +0 -164
  89. package/src/sockethub.d.ts +0 -1
  90. package/src/sockethub.ts +0 -184
  91. package/src/store.test.ts +0 -26
  92. package/src/store.ts +0 -17
  93. package/test/init-suite.js +0 -41
  94. package/test/sockethub-suite.js +0 -25
  95. package/views/examples/dummy.ejs +0 -93
  96. package/views/examples/feeds.ejs +0 -90
  97. package/views/examples/irc.ejs +0 -239
  98. package/views/examples/shared.js +0 -72
  99. package/views/examples/xmpp.ejs +0 -191
  100. package/views/index.ejs +0 -17
  101. package/webpack.minified.config.js +0 -14
  102. package/webpack.normal.config.js +0 -14
package/bin/sockethub CHANGED
@@ -1,30 +1,3 @@
1
1
  #!/usr/bin/env node
2
- const baseDir = process.env.DEV ? 'src' : 'dist';
3
- const Sockethub = require(`./../${baseDir}/sockethub`).default;
4
- const sockethub = new Sockethub();
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
+ const sockethubServer = require('@sockethub/server');
3
+ sockethubServer();
package/build.js ADDED
@@ -0,0 +1,21 @@
1
+
2
+ const fs = require('fs');
3
+ const packageJSON = require('./package.json');
4
+ const moduleList = Object.keys(packageJSON.dependencies);
5
+
6
+ const rx = new RegExp('^@sockethub/platform-', 'i');
7
+ const platforms = [];
8
+
9
+ for (let moduleName of moduleList) {
10
+ if (rx.test(moduleName)) {
11
+ platforms.push(moduleName);
12
+ }
13
+ }
14
+
15
+ const data = fs.readFileSync(
16
+ 'node_modules/@sockethub/server/sockethub.config.example.json', 'utf8');
17
+ const config = JSON.parse(data);
18
+ config.platforms = platforms;
19
+
20
+ fs.writeFileSync(
21
+ './sockethub.config.json', data);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "sockethub",
3
3
  "description": "A polyglot messaging service",
4
- "version": "5.0.0-alpha.0",
4
+ "version": "5.0.0-alpha.3",
5
5
  "private": false,
6
6
  "author": "Nick Jennings <nick@silverbucket.net>",
7
7
  "license": "LGPL-3.0+",
8
- "main": "./dist/sockethub.js",
9
- "bin": "./bin/sockethub",
8
+ "main": "",
9
+ "bin": "bin/sockethub",
10
10
  "preferGlobal": true,
11
11
  "keywords": [
12
12
  "sockethub",
@@ -30,74 +30,24 @@
30
30
  "repository": {
31
31
  "type": "git",
32
32
  "url": "git+https://github.com/sockethub/sockethub.git",
33
- "directory": "packages/sockethub"
33
+ "directory": "apps/sockethub"
34
34
  },
35
35
  "homepage": "https://sockethub.org",
36
36
  "dependencies": {
37
- "activity-streams": "^4.4.0-alpha.0",
38
- "body-parser": "^1.19.0",
39
- "bull": "^4.0.0",
40
- "debug": "^4.3.1",
41
- "ejs": "^3.0.1",
42
- "express": "^4.17.1",
43
- "findup-sync": "^5.0.0",
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.0",
52
- "sockethub-platform-xmpp": "^5.0.0-alpha.0",
53
- "sockethub-schemas": "^3.0.0-alpha.0",
54
- "urijs": "^1.19.2"
37
+ "@sockethub/platform-dummy": "^3.0.0-alpha.3",
38
+ "@sockethub/platform-feeds": "^3.0.0-alpha.3",
39
+ "@sockethub/platform-irc": "^4.0.0-alpha.3",
40
+ "@sockethub/platform-xmpp": "^5.0.0-alpha.3",
41
+ "@sockethub/server": "^5.0.0-alpha.3"
55
42
  },
56
43
  "scripts": {
57
- "compliance": "yarn run lint && yarn run test && yarn run coverage",
58
- "test": "c8 -x src/bootstrap -x \"src/**/*.test.*\" mocha -r ts-node/register src/*.test.ts src/**/*.test.ts",
59
- "coverage": "c8 check-coverage --statements 90 --branches 80 --functions 90 --lines 90",
60
- "start": "DEBUG=sockethub* ./bin/sockethub",
61
- "dev": "yarn run build && DEBUG=sockethub* ./bin/sockethub --examples",
62
- "lint": "eslint \"**/*.ts\" ./bin/sockethub",
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"
44
+ "build": "node build.js && test -f sockethub.config.json",
45
+ "clean:deps": "npx rimraf node_modules",
46
+ "dev": "DEBUG=sockethub* ./bin/sockethub --examples -c sockethub.config.json",
47
+ "start": "DEBUG=sockethub* ./bin/sockethub -c sockethub.config.json"
68
48
  },
69
49
  "engines": {
70
- "node": ">= 12.0.0"
50
+ "node": ">= 12.4.0"
71
51
  },
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"
101
- },
102
- "gitHead": "75337bd147d2d61a203a8f222551d3054fcedade"
52
+ "gitHead": "f02238a478b7ffd3f31d8deea292eb67e630a86b"
103
53
  }
@@ -8,16 +8,18 @@
8
8
  "enabled": false,
9
9
  "secret": 1234567890
10
10
  },
11
- "service": {
11
+ "sockethub": {
12
12
  "port": 10550,
13
13
  "host": "localhost",
14
14
  "path": "/sockethub"
15
15
  },
16
16
  "log_file": "",
17
- "platforms": {
18
- "whitelist": [],
19
- "blacklist": []
20
- },
17
+ "platforms": [
18
+ "@sockethub/platform-dummy",
19
+ "@sockethub/platform-feeds",
20
+ "@sockethub/platform-irc",
21
+ "@sockethub/platform-xmpp"
22
+ ],
21
23
  "public": {
22
24
  "protocol": "http",
23
25
  "host": "localhost",
@@ -27,6 +29,5 @@
27
29
  "redis": {
28
30
  "host": "127.0.0.1",
29
31
  "port": 6379
30
- },
31
- "workers": 1
32
+ }
32
33
  }
package/tsconfig.json CHANGED
@@ -1,79 +1,17 @@
1
1
  {
2
+ "extends": "../../tsconfig.base.json",
2
3
  "compilerOptions": {
3
- /* Basic Options */
4
- // "incremental": true, /* Enable incremental compilation */
5
- "target": "es6",
6
- /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
7
- "module": "commonjs",
8
- /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
9
- "lib": ["esnext"], /* Specify library files to be included in the compilation. */
10
4
  "allowJs": false,
11
- /* Allow javascript files to be compiled. */
12
- // "checkJs": true, /* Report errors in .js files. */
13
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14
- // "declaration": true, /* Generates corresponding '.d.ts' file. */
15
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16
- "sourceMap": true,
17
- /* Generates corresponding '.map' file. */
18
- // "outFile": "./", /* Concatenate and emit output to single file. */
19
5
  "outDir": "dist",
20
- /* Redirect output structure to the directory. */
21
- "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
22
- // "composite": true, /* Enable project compilation */
23
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
24
- // "removeComments": true, /* Do not emit comments to output. */
25
- // "noEmit": true, /* Do not emit outputs. */
26
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
27
- "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
28
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
29
-
30
- /* Strict Type-Checking Options */
31
- // "strict": true, /* Enable all strict type-checking options. */
32
- "noImplicitAny": false,
33
- /* Raise error on expressions and declarations with an implied 'any' type. */
34
- // "strictNullChecks": true, /* Enable strict null checks. */
35
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
36
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
37
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
38
- "noImplicitThis": false,
39
- /* Raise error on 'this' expressions with an implied 'any' type. */
40
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
41
-
42
- /* Additional Checks */
43
- // "noUnusedLocals": true, /* Report errors on unused locals. */
44
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
45
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
46
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
47
-
48
- /* Module Resolution Options */
49
- "moduleResolution": "node",
50
- /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
51
- "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
52
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
53
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
54
- // "typeRoots": [], /* List of folders to include type definitions from. */
55
- "types": ["mocha", "node"], /* Type declaration files to be included in compilation. */
56
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
57
- "esModuleInterop": true,
58
- /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
59
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
60
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
61
-
62
- /* Source Map Options */
63
- "sourceRoot": "/", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
64
- "mapRoot": "/", /* Specify the location where debugger should locate map files instead of generated locations. */
65
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
66
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
67
-
68
- /* Experimental Options */
69
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
70
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
71
- "resolveJsonModule": true
6
+ "rootDir": "src",
7
+ "baseUrl": "/",
8
+ "sourceRoot": "/",
9
+ "mapRoot": "/",
72
10
  },
73
11
  "include": [
74
12
  "src"
75
13
  ],
76
14
  "exclude": [
77
- "**/test", "**/node_modules", "**/dist", "**/*.test.ts"
15
+ "**/*.test.ts"
78
16
  ]
79
17
  }
package/README.md DELETED
@@ -1,98 +0,0 @@
1
- [![Sockethub](http://sockethub.org/res/img/sockethub-logo.svg)](http://sockethub.org)
2
-
3
- A protocol gateway for the web.
4
-
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
-
8
- Using [ActivityStream](http://activitystrea.ms/) (AS) objects to pass messages to and from the web app, Sockethub acts as a smart proxy server/agent, which can maintain state, and connect to sockets, endpoints and networks that would otherwise be restricted from an application running in the browser.
9
-
10
- Originally inspired as a sister project to [RemoteStorage](https://remotestorage.io), and assisting in the development of [unhosted](http://unhosted.org) and [noBackend](http://nobackend.org) applications, Sockethub's functionality can also fit into a more traditional development stack, removing the need for custom code to handle various protocol specifics at the application layer.
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
- [![NLNET Logo](http://sockethub.org/res/img/nlnet-logo.svg)](http://nlnet.nl)
98
-
@@ -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
- }