sockethub 5.0.0-alpha.2 → 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 (101) 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/dist/bootstrap/init.js +0 -74
  9. package/dist/bootstrap/init.js.map +0 -1
  10. package/dist/bootstrap/platforms.js +0 -103
  11. package/dist/common.js +0 -20
  12. package/dist/common.js.map +0 -1
  13. package/dist/config.js +0 -60
  14. package/dist/config.js.map +0 -1
  15. package/dist/crypto.js +0 -38
  16. package/dist/crypto.js.map +0 -1
  17. package/dist/janitor.js +0 -98
  18. package/dist/janitor.js.map +0 -1
  19. package/dist/middleware/create-activity-object.js +0 -19
  20. package/dist/middleware/create-activity-object.js.map +0 -1
  21. package/dist/middleware/expand-activity-stream.js +0 -33
  22. package/dist/middleware/expand-activity-stream.js.map +0 -1
  23. package/dist/middleware/expand-activity-stream.test.data.js +0 -360
  24. package/dist/middleware/expand-activity-stream.test.data.js.map +0 -1
  25. package/dist/middleware/store-credentials.js +0 -19
  26. package/dist/middleware/store-credentials.js.map +0 -1
  27. package/dist/middleware/validate.js +0 -77
  28. package/dist/middleware/validate.js.map +0 -1
  29. package/dist/middleware/validate.test.data.js +0 -321
  30. package/dist/middleware/validate.test.data.js.map +0 -1
  31. package/dist/middleware.js +0 -54
  32. package/dist/middleware.js.map +0 -1
  33. package/dist/platform-instance.js +0 -226
  34. package/dist/platform-instance.js.map +0 -1
  35. package/dist/platform.js +0 -186
  36. package/dist/platform.js.map +0 -1
  37. package/dist/process-manager.js +0 -78
  38. package/dist/process-manager.js.map +0 -1
  39. package/dist/routes.js +0 -84
  40. package/dist/routes.js.map +0 -1
  41. package/dist/serve.js +0 -102
  42. package/dist/serve.js.map +0 -1
  43. package/dist/sockethub-client.js +0 -2604
  44. package/dist/sockethub-client.js.map +0 -1
  45. package/dist/sockethub-client.min.js +0 -2
  46. package/dist/sockethub-client.min.js.LICENSE.txt +0 -24
  47. package/dist/sockethub.js +0 -130
  48. package/dist/sockethub.js.map +0 -1
  49. package/dist/store.js +0 -17
  50. package/dist/store.js.map +0 -1
  51. package/src/bootstrap/init.d.ts +0 -8
  52. package/src/bootstrap/init.ts +0 -91
  53. package/src/bootstrap/platforms.js +0 -103
  54. package/src/common.test.ts +0 -54
  55. package/src/common.ts +0 -14
  56. package/src/config.d.ts +0 -2
  57. package/src/config.test.ts +0 -28
  58. package/src/config.ts +0 -72
  59. package/src/crypto.d.ts +0 -5
  60. package/src/crypto.test.ts +0 -41
  61. package/src/crypto.ts +0 -41
  62. package/src/defaults.json +0 -32
  63. package/src/janitor.d.ts +0 -8
  64. package/src/janitor.ts +0 -89
  65. package/src/middleware/create-activity-object.test.ts +0 -10
  66. package/src/middleware/create-activity-object.ts +0 -13
  67. package/src/middleware/expand-activity-stream.test.data.ts +0 -365
  68. package/src/middleware/expand-activity-stream.test.ts +0 -78
  69. package/src/middleware/expand-activity-stream.ts +0 -27
  70. package/src/middleware/store-credentials.test.ts +0 -72
  71. package/src/middleware/store-credentials.ts +0 -16
  72. package/src/middleware/validate.d.ts +0 -1
  73. package/src/middleware/validate.test.data.ts +0 -320
  74. package/src/middleware/validate.test.ts +0 -47
  75. package/src/middleware/validate.ts +0 -49
  76. package/src/middleware.d.ts +0 -21
  77. package/src/middleware.test.ts +0 -148
  78. package/src/middleware.ts +0 -52
  79. package/src/platform-instance.test.ts +0 -237
  80. package/src/platform-instance.ts +0 -236
  81. package/src/platform.ts +0 -189
  82. package/src/process-manager.ts +0 -64
  83. package/src/routes.test.ts +0 -100
  84. package/src/routes.ts +0 -93
  85. package/src/serve.ts +0 -79
  86. package/src/sockethub-client.test.ts +0 -235
  87. package/src/sockethub-client.ts +0 -164
  88. package/src/sockethub.d.ts +0 -1
  89. package/src/sockethub.ts +0 -184
  90. package/src/store.test.ts +0 -26
  91. package/src/store.ts +0 -17
  92. package/test/init-suite.js +0 -41
  93. package/test/sockethub-suite.js +0 -25
  94. package/views/examples/dummy.ejs +0 -93
  95. package/views/examples/feeds.ejs +0 -90
  96. package/views/examples/irc.ejs +0 -239
  97. package/views/examples/shared.js +0 -72
  98. package/views/examples/xmpp.ejs +0 -191
  99. package/views/index.ejs +0 -17
  100. package/webpack.minified.config.js +0 -14
  101. 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.2",
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.2",
52
- "sockethub-platform-xmpp": "^5.0.0-alpha.2",
53
- "sockethub-schemas": "^3.0.0-alpha.2",
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": "29e87681a6ec6dab526efd28348881fbcc7bcb6f"
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
- }
@@ -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":"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"}
@@ -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
@@ -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"}