@streamr/node 100.0.0-rc.0
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/LICENSE +78 -0
- package/README.md +54 -0
- package/bin/broker.ts +36 -0
- package/bin/config-wizard.js +4 -0
- package/bin/config-wizard.ts +17 -0
- package/bin/delete-expired-data.ts +41 -0
- package/bin/entry-point.ts +27 -0
- package/configs/development-1.env.json +68 -0
- package/configs/development-2.env.json +53 -0
- package/configs/development-3.env.json +53 -0
- package/configs/development-prod-resend.env.json +21 -0
- package/configs/docker-1.env.json +72 -0
- package/configs/docker-2.env.json +58 -0
- package/configs/docker-3.env.json +58 -0
- package/configuration.md +38 -0
- package/dist/bin/broker.d.ts +2 -0
- package/dist/bin/broker.js +42 -0
- package/dist/bin/broker.js.map +1 -0
- package/dist/bin/config-wizard.d.ts +2 -0
- package/dist/bin/config-wizard.js +22 -0
- package/dist/bin/config-wizard.js.map +1 -0
- package/dist/bin/delete-expired-data.d.ts +2 -0
- package/dist/bin/delete-expired-data.js +44 -0
- package/dist/bin/delete-expired-data.js.map +1 -0
- package/dist/bin/entry-point.d.ts +2 -0
- package/dist/bin/entry-point.js +28 -0
- package/dist/bin/entry-point.js.map +1 -0
- package/dist/package.json +78 -0
- package/dist/src/Plugin.d.ts +33 -0
- package/dist/src/Plugin.js +43 -0
- package/dist/src/Plugin.js.map +1 -0
- package/dist/src/apiAuthentication.d.ts +4 -0
- package/dist/src/apiAuthentication.js +16 -0
- package/dist/src/apiAuthentication.js.map +1 -0
- package/dist/src/broker.d.ts +8 -0
- package/dist/src/broker.js +69 -0
- package/dist/src/broker.js.map +1 -0
- package/dist/src/config/ConfigWizard.d.ts +5 -0
- package/dist/src/config/ConfigWizard.js +466 -0
- package/dist/src/config/ConfigWizard.js.map +1 -0
- package/dist/src/config/config.d.ts +26 -0
- package/dist/src/config/config.js +92 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/config.schema.json +86 -0
- package/dist/src/config/definitions.schema.json +35 -0
- package/dist/src/config/migration.d.ts +6 -0
- package/dist/src/config/migration.js +210 -0
- package/dist/src/config/migration.js.map +1 -0
- package/dist/src/config/validateConfig.d.ts +4 -0
- package/dist/src/config/validateConfig.js +40 -0
- package/dist/src/config/validateConfig.js.map +1 -0
- package/dist/src/exports.d.ts +3 -0
- package/dist/src/exports.js +6 -0
- package/dist/src/exports.js.map +1 -0
- package/dist/src/helpers/PayloadFormat.d.ts +19 -0
- package/dist/src/helpers/PayloadFormat.js +85 -0
- package/dist/src/helpers/PayloadFormat.js.map +1 -0
- package/dist/src/helpers/applyPluginClientConfigs.d.ts +3 -0
- package/dist/src/helpers/applyPluginClientConfigs.js +29 -0
- package/dist/src/helpers/applyPluginClientConfigs.js.map +1 -0
- package/dist/src/helpers/fetchOrThrow.d.ts +2 -0
- package/dist/src/helpers/fetchOrThrow.js +20 -0
- package/dist/src/helpers/fetchOrThrow.js.map +1 -0
- package/dist/src/helpers/generateMnemonicFromAddress.d.ts +5 -0
- package/dist/src/helpers/generateMnemonicFromAddress.js +16 -0
- package/dist/src/helpers/generateMnemonicFromAddress.js.map +1 -0
- package/dist/src/helpers/multiply.d.ts +1 -0
- package/dist/src/helpers/multiply.js +10 -0
- package/dist/src/helpers/multiply.js.map +1 -0
- package/dist/src/helpers/parser.d.ts +9 -0
- package/dist/src/helpers/parser.js +62 -0
- package/dist/src/helpers/parser.js.map +1 -0
- package/dist/src/helpers/partitions.d.ts +8 -0
- package/dist/src/helpers/partitions.js +32 -0
- package/dist/src/helpers/partitions.js.map +1 -0
- package/dist/src/helpers/weightedSample.d.ts +16 -0
- package/dist/src/helpers/weightedSample.js +35 -0
- package/dist/src/helpers/weightedSample.js.map +1 -0
- package/dist/src/httpServer.d.ts +16 -0
- package/dist/src/httpServer.js +71 -0
- package/dist/src/httpServer.js.map +1 -0
- package/dist/src/pluginRegistry.d.ts +3 -0
- package/dist/src/pluginRegistry.js +35 -0
- package/dist/src/pluginRegistry.js.map +1 -0
- package/dist/src/plugins/consoleMetrics/ConsoleMetricsPlugin.d.ts +12 -0
- package/dist/src/plugins/consoleMetrics/ConsoleMetricsPlugin.js +36 -0
- package/dist/src/plugins/consoleMetrics/ConsoleMetricsPlugin.js.map +1 -0
- package/dist/src/plugins/consoleMetrics/config.schema.json +18 -0
- package/dist/src/plugins/http/HttpPlugin.d.ts +8 -0
- package/dist/src/plugins/http/HttpPlugin.js +23 -0
- package/dist/src/plugins/http/HttpPlugin.js.map +1 -0
- package/dist/src/plugins/http/config.schema.json +12 -0
- package/dist/src/plugins/http/publishEndpoint.d.ts +3 -0
- package/dist/src/plugins/http/publishEndpoint.js +72 -0
- package/dist/src/plugins/http/publishEndpoint.js.map +1 -0
- package/dist/src/plugins/info/InfoPlugin.d.ts +9 -0
- package/dist/src/plugins/info/InfoPlugin.js +31 -0
- package/dist/src/plugins/info/InfoPlugin.js.map +1 -0
- package/dist/src/plugins/info/config.schema.json +12 -0
- package/dist/src/plugins/mqtt/Bridge.d.ts +40 -0
- package/dist/src/plugins/mqtt/Bridge.js +136 -0
- package/dist/src/plugins/mqtt/Bridge.js.map +1 -0
- package/dist/src/plugins/mqtt/MqttPlugin.d.ts +14 -0
- package/dist/src/plugins/mqtt/MqttPlugin.js +30 -0
- package/dist/src/plugins/mqtt/MqttPlugin.js.map +1 -0
- package/dist/src/plugins/mqtt/MqttServer.d.ts +22 -0
- package/dist/src/plugins/mqtt/MqttServer.js +109 -0
- package/dist/src/plugins/mqtt/MqttServer.js.map +1 -0
- package/dist/src/plugins/mqtt/config.schema.json +26 -0
- package/dist/src/plugins/operator/ConsistentHashRing.d.ts +20 -0
- package/dist/src/plugins/operator/ConsistentHashRing.js +64 -0
- package/dist/src/plugins/operator/ConsistentHashRing.js.map +1 -0
- package/dist/src/plugins/operator/ContractFacade.d.ts +80 -0
- package/dist/src/plugins/operator/ContractFacade.js +364 -0
- package/dist/src/plugins/operator/ContractFacade.js.map +1 -0
- package/dist/src/plugins/operator/MaintainTopologyHelper.d.ts +23 -0
- package/dist/src/plugins/operator/MaintainTopologyHelper.js +75 -0
- package/dist/src/plugins/operator/MaintainTopologyHelper.js.map +1 -0
- package/dist/src/plugins/operator/MaintainTopologyService.d.ts +11 -0
- package/dist/src/plugins/operator/MaintainTopologyService.js +57 -0
- package/dist/src/plugins/operator/MaintainTopologyService.js.map +1 -0
- package/dist/src/plugins/operator/OperatorFleetState.d.ts +33 -0
- package/dist/src/plugins/operator/OperatorFleetState.js +112 -0
- package/dist/src/plugins/operator/OperatorFleetState.js.map +1 -0
- package/dist/src/plugins/operator/OperatorPlugin.d.ts +50 -0
- package/dist/src/plugins/operator/OperatorPlugin.js +159 -0
- package/dist/src/plugins/operator/OperatorPlugin.js.map +1 -0
- package/dist/src/plugins/operator/StreamPartAssignments.d.ts +28 -0
- package/dist/src/plugins/operator/StreamPartAssignments.js +104 -0
- package/dist/src/plugins/operator/StreamPartAssignments.js.map +1 -0
- package/dist/src/plugins/operator/announceNodeToContract.d.ts +3 -0
- package/dist/src/plugins/operator/announceNodeToContract.js +39 -0
- package/dist/src/plugins/operator/announceNodeToContract.js.map +1 -0
- package/dist/src/plugins/operator/announceNodeToStream.d.ts +3 -0
- package/dist/src/plugins/operator/announceNodeToStream.js +25 -0
- package/dist/src/plugins/operator/announceNodeToStream.js.map +1 -0
- package/dist/src/plugins/operator/checkOperatorValueBreach.d.ts +2 -0
- package/dist/src/plugins/operator/checkOperatorValueBreach.js +21 -0
- package/dist/src/plugins/operator/checkOperatorValueBreach.js.map +1 -0
- package/dist/src/plugins/operator/closeExpiredFlags.d.ts +3 -0
- package/dist/src/plugins/operator/closeExpiredFlags.js +24 -0
- package/dist/src/plugins/operator/closeExpiredFlags.js.map +1 -0
- package/dist/src/plugins/operator/config.schema.json +152 -0
- package/dist/src/plugins/operator/createIsLeaderFn.d.ts +4 -0
- package/dist/src/plugins/operator/createIsLeaderFn.js +14 -0
- package/dist/src/plugins/operator/createIsLeaderFn.js.map +1 -0
- package/dist/src/plugins/operator/fetchRedundancyFactor.d.ts +2 -0
- package/dist/src/plugins/operator/fetchRedundancyFactor.js +43 -0
- package/dist/src/plugins/operator/fetchRedundancyFactor.js.map +1 -0
- package/dist/src/plugins/operator/formCoordinationStreamId.d.ts +3 -0
- package/dist/src/plugins/operator/formCoordinationStreamId.js +9 -0
- package/dist/src/plugins/operator/formCoordinationStreamId.js.map +1 -0
- package/dist/src/plugins/operator/heartbeatUtils.d.ts +67 -0
- package/dist/src/plugins/operator/heartbeatUtils.js +26 -0
- package/dist/src/plugins/operator/heartbeatUtils.js.map +1 -0
- package/dist/src/plugins/operator/inspectOverTime.d.ts +22 -0
- package/dist/src/plugins/operator/inspectOverTime.js +146 -0
- package/dist/src/plugins/operator/inspectOverTime.js.map +1 -0
- package/dist/src/plugins/operator/inspectRandomNode.d.ts +8 -0
- package/dist/src/plugins/operator/inspectRandomNode.js +44 -0
- package/dist/src/plugins/operator/inspectRandomNode.js.map +1 -0
- package/dist/src/plugins/operator/inspectionUtils.d.ts +23 -0
- package/dist/src/plugins/operator/inspectionUtils.js +120 -0
- package/dist/src/plugins/operator/inspectionUtils.js.map +1 -0
- package/dist/src/plugins/operator/maintainOperatorValue.d.ts +2 -0
- package/dist/src/plugins/operator/maintainOperatorValue.js +21 -0
- package/dist/src/plugins/operator/maintainOperatorValue.js.map +1 -0
- package/dist/src/plugins/operator/reviewSuspectNode.d.ts +24 -0
- package/dist/src/plugins/operator/reviewSuspectNode.js +56 -0
- package/dist/src/plugins/operator/reviewSuspectNode.js.map +1 -0
- package/dist/src/plugins/storage/Batch.d.ts +51 -0
- package/dist/src/plugins/storage/Batch.js +121 -0
- package/dist/src/plugins/storage/Batch.js.map +1 -0
- package/dist/src/plugins/storage/BatchManager.d.ts +27 -0
- package/dist/src/plugins/storage/BatchManager.js +117 -0
- package/dist/src/plugins/storage/BatchManager.js.map +1 -0
- package/dist/src/plugins/storage/Bucket.d.ts +23 -0
- package/dist/src/plugins/storage/Bucket.js +90 -0
- package/dist/src/plugins/storage/Bucket.js.map +1 -0
- package/dist/src/plugins/storage/BucketManager.d.ts +56 -0
- package/dist/src/plugins/storage/BucketManager.js +306 -0
- package/dist/src/plugins/storage/BucketManager.js.map +1 -0
- package/dist/src/plugins/storage/DataQueryFormat.d.ts +10 -0
- package/dist/src/plugins/storage/DataQueryFormat.js +51 -0
- package/dist/src/plugins/storage/DataQueryFormat.js.map +1 -0
- package/dist/src/plugins/storage/DeleteExpiredCmd.d.ts +28 -0
- package/dist/src/plugins/storage/DeleteExpiredCmd.js +155 -0
- package/dist/src/plugins/storage/DeleteExpiredCmd.js.map +1 -0
- package/dist/src/plugins/storage/SetMembershipSynchronizer.d.ts +33 -0
- package/dist/src/plugins/storage/SetMembershipSynchronizer.js +102 -0
- package/dist/src/plugins/storage/SetMembershipSynchronizer.js.map +1 -0
- package/dist/src/plugins/storage/Storage.d.ts +47 -0
- package/dist/src/plugins/storage/Storage.js +459 -0
- package/dist/src/plugins/storage/Storage.js.map +1 -0
- package/dist/src/plugins/storage/StorageConfig.d.ts +43 -0
- package/dist/src/plugins/storage/StorageConfig.js +83 -0
- package/dist/src/plugins/storage/StorageConfig.js.map +1 -0
- package/dist/src/plugins/storage/StorageEventListener.d.ts +17 -0
- package/dist/src/plugins/storage/StorageEventListener.js +46 -0
- package/dist/src/plugins/storage/StorageEventListener.js.map +1 -0
- package/dist/src/plugins/storage/StoragePlugin.d.ts +32 -0
- package/dist/src/plugins/storage/StoragePlugin.js +103 -0
- package/dist/src/plugins/storage/StoragePlugin.js.map +1 -0
- package/dist/src/plugins/storage/StoragePoller.d.ts +15 -0
- package/dist/src/plugins/storage/StoragePoller.js +47 -0
- package/dist/src/plugins/storage/StoragePoller.js.map +1 -0
- package/dist/src/plugins/storage/config.schema.json +88 -0
- package/dist/src/plugins/storage/dataMetadataEndpoint.d.ts +3 -0
- package/dist/src/plugins/storage/dataMetadataEndpoint.js +35 -0
- package/dist/src/plugins/storage/dataMetadataEndpoint.js.map +1 -0
- package/dist/src/plugins/storage/dataQueryEndpoint.d.ts +6 -0
- package/dist/src/plugins/storage/dataQueryEndpoint.js +181 -0
- package/dist/src/plugins/storage/dataQueryEndpoint.js.map +1 -0
- package/dist/src/plugins/storage/storageConfigEndpoint.d.ts +3 -0
- package/dist/src/plugins/storage/storageConfigEndpoint.js +31 -0
- package/dist/src/plugins/storage/storageConfigEndpoint.js.map +1 -0
- package/dist/src/plugins/subscriber/SubscriberPlugin.d.ts +16 -0
- package/dist/src/plugins/subscriber/SubscriberPlugin.js +22 -0
- package/dist/src/plugins/subscriber/SubscriberPlugin.js.map +1 -0
- package/dist/src/plugins/subscriber/config.schema.json +31 -0
- package/dist/src/plugins/websocket/Connection.d.ts +9 -0
- package/dist/src/plugins/websocket/Connection.js +45 -0
- package/dist/src/plugins/websocket/Connection.js.map +1 -0
- package/dist/src/plugins/websocket/PublishConnection.d.ts +12 -0
- package/dist/src/plugins/websocket/PublishConnection.js +46 -0
- package/dist/src/plugins/websocket/PublishConnection.js.map +1 -0
- package/dist/src/plugins/websocket/SubscribeConnection.d.ts +13 -0
- package/dist/src/plugins/websocket/SubscribeConnection.js +50 -0
- package/dist/src/plugins/websocket/SubscribeConnection.js.map +1 -0
- package/dist/src/plugins/websocket/WebsocketPlugin.d.ts +19 -0
- package/dist/src/plugins/websocket/WebsocketPlugin.js +26 -0
- package/dist/src/plugins/websocket/WebsocketPlugin.js.map +1 -0
- package/dist/src/plugins/websocket/WebsocketServer.d.ts +16 -0
- package/dist/src/plugins/websocket/WebsocketServer.js +132 -0
- package/dist/src/plugins/websocket/WebsocketServer.js.map +1 -0
- package/dist/src/plugins/websocket/config.schema.json +51 -0
- package/package.json +78 -0
- package/plugins.md +318 -0
package/configuration.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
See [config.schema.json](src/config/config.schema.json).
|
|
4
|
+
|
|
5
|
+
### Environment variables
|
|
6
|
+
|
|
7
|
+
You may use environment variables to define any configuration option. This is not the recommended way to use configuration: it is better to modify the actual configuration file, is possible.
|
|
8
|
+
|
|
9
|
+
E.g. if you want to set the private key, you can define a variable like this:
|
|
10
|
+
```
|
|
11
|
+
STREAMR__BROKER__CLIENT__AUTH__PRIVATE_KEY = '0x1234'
|
|
12
|
+
````
|
|
13
|
+
|
|
14
|
+
It corresponds to this configuration file:
|
|
15
|
+
```
|
|
16
|
+
{
|
|
17
|
+
"client": {
|
|
18
|
+
"auth": {
|
|
19
|
+
"privateKey": "0x1234"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
...
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
All environment variable names start with `STREAMR__BROKER__` and each configuration block is separated by double underscore. Blocks and properties are defined in *CONSTANT_CASE* instead of *camelCase*.
|
|
27
|
+
|
|
28
|
+
If the value is defined both in an environment variable and a configuration file, the environment variable value is used.
|
|
29
|
+
|
|
30
|
+
It is possible to define arrays by adding a numeration suffix to a block/property:
|
|
31
|
+
```
|
|
32
|
+
STREAMR__BROKER__CLIENT__NETWORK__TRACKERS_1__ID = '0x1234'
|
|
33
|
+
STREAMR__BROKER__CLIENT__NETWORK__TRACKERS_2__ID = '0x5678'
|
|
34
|
+
STREAMR__BROKER__AUTHENTICATION__KEYS_1 = 'foo'
|
|
35
|
+
STREAMR__BROKER__AUTHENTICATION__KEYS_2 = 'bar'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Note that the first item of an array has index `1` (not `0`).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
+
const broker_1 = require("../src/broker");
|
|
10
|
+
const migration_1 = require("../src/config/migration");
|
|
11
|
+
const config_1 = require("../src/config/config");
|
|
12
|
+
commander_1.program
|
|
13
|
+
.version(package_json_1.default.version)
|
|
14
|
+
.name('broker')
|
|
15
|
+
.description('Run broker under environment specified by given configuration file.')
|
|
16
|
+
.arguments('[configFile]')
|
|
17
|
+
.option('--test', 'test the configuration (does not start the broker)')
|
|
18
|
+
.action(async (configFile) => {
|
|
19
|
+
try {
|
|
20
|
+
const config = (0, migration_1.readConfigAndMigrateIfNeeded)(configFile);
|
|
21
|
+
(0, config_1.overrideConfigToEnvVarsIfGiven)(config);
|
|
22
|
+
const broker = await (0, broker_1.createBroker)(config);
|
|
23
|
+
if (!commander_1.program.opts().test) {
|
|
24
|
+
await broker.start();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.info('the configuration is valid');
|
|
29
|
+
// TODO remove process.exit(0)
|
|
30
|
+
// We should not need explicit exit call if all setTimeouts are cleared.
|
|
31
|
+
// Currently there is only one leaking timeout in PingPongWs (created
|
|
32
|
+
// by NodeClientWsEndpoint from the createNetworkNode() call)
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.error(err);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.parse(process.argv);
|
|
42
|
+
//# sourceMappingURL=broker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../bin/broker.ts"],"names":[],"mappings":";;;;;;AACA,yCAAmC;AACnC,mEAAiC;AAEjC,0CAA4C;AAC5C,uDAAsE;AACtE,iDAAqE;AAErE,mBAAO;KACF,OAAO,CAAC,sBAAG,CAAC,OAAO,CAAC;KACpB,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,qEAAqE,CAAC;KAClF,SAAS,CAAC,cAAc,CAAC;KACzB,MAAM,CAAC,QAAQ,EAAE,oDAAoD,CAAC;KACtE,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;IACzB,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,wCAA4B,EAAC,UAAU,CAAC,CAAA;QACvD,IAAA,uCAA8B,EAAC,MAAM,CAAC,CAAA;QACtC,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAA;QACzC,IAAI,CAAC,mBAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACvB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACxB,CAAC;aAAM,CAAC;YACJ,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;YAC1C,8BAA8B;YAC9B,wEAAwE;YACxE,qEAAqE;YACrE,6DAA6D;YAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;AACL,CAAC,CAAC;KACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
+
const ConfigWizard_1 = require("../src/config/ConfigWizard");
|
|
10
|
+
commander_1.program
|
|
11
|
+
.version(package_json_1.default.version)
|
|
12
|
+
.name('broker-config-wizard')
|
|
13
|
+
.description('Run the configuration wizard for the broker');
|
|
14
|
+
(async () => {
|
|
15
|
+
try {
|
|
16
|
+
await (0, ConfigWizard_1.start)();
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.error('Streamr Node Config Wizard encountered an error:\n', e);
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
//# sourceMappingURL=config-wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-wizard.js","sourceRoot":"","sources":["../../bin/config-wizard.ts"],"names":[],"mappings":";;;;;;AACA,yCAAmC;AACnC,mEAAiC;AACjC,6DAAkD;AAElD,mBAAO;KACF,OAAO,CAAC,sBAAG,CAAC,OAAO,CAAC;KACpB,IAAI,CAAC,sBAAsB,CAAC;KAC5B,WAAW,CAAC,6CAA6C,CAAC,CAE9D;AAAA,CAAC,KAAK,IAAI,EAAE;IACT,IAAI,CAAC;QACD,MAAM,IAAA,oBAAK,GAAE,CAAA;IACjB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,oDAAoD,EAAE,CAAC,CAAC,CAAA;IAC1E,CAAC;AACL,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
+
const DeleteExpiredCmd_1 = require("../src/plugins/storage/DeleteExpiredCmd");
|
|
10
|
+
commander_1.program
|
|
11
|
+
.version(package_json_1.default.version)
|
|
12
|
+
.requiredOption('--cassandra-username <username>')
|
|
13
|
+
.requiredOption('--cassandra-password <password>')
|
|
14
|
+
.requiredOption('--cassandra-hosts <hosts_delimited_by_comma>')
|
|
15
|
+
.requiredOption('--cassandra-datacenter <datacenter>')
|
|
16
|
+
.requiredOption('--cassandra-keyspace <keyspace>')
|
|
17
|
+
.requiredOption('--streamr-base-url <baseUrl>')
|
|
18
|
+
.requiredOption('--bucket-limit <bucketLimit>', 'max number of buckets to fetch')
|
|
19
|
+
.option('--real-run', 'delete data for real', false)
|
|
20
|
+
.description('Delete expired data')
|
|
21
|
+
.parse(process.argv);
|
|
22
|
+
const deleteExpiredCommand = new DeleteExpiredCmd_1.DeleteExpiredCmd({
|
|
23
|
+
cassandraUsername: commander_1.program.opts().cassandraUsername,
|
|
24
|
+
cassandraPassword: commander_1.program.opts().cassandraPassword,
|
|
25
|
+
cassandraHosts: commander_1.program.opts().cassandraHosts.split(','),
|
|
26
|
+
cassandraDatacenter: commander_1.program.opts().cassandraDatacenter,
|
|
27
|
+
cassandraKeyspace: commander_1.program.opts().cassandraKeyspace,
|
|
28
|
+
streamrBaseUrl: commander_1.program.opts().streamrBaseUrl,
|
|
29
|
+
bucketLimit: commander_1.program.opts().bucketLimit,
|
|
30
|
+
dryRun: !commander_1.program.opts().realRun
|
|
31
|
+
});
|
|
32
|
+
async function run() {
|
|
33
|
+
try {
|
|
34
|
+
// @ts-expect-error TODO fix
|
|
35
|
+
await deleteExpiredCommand.run();
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.error(err);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
run();
|
|
44
|
+
//# sourceMappingURL=delete-expired-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-expired-data.js","sourceRoot":"","sources":["../../bin/delete-expired-data.ts"],"names":[],"mappings":";;;;;;AACA,yCAAmC;AACnC,mEAAiC;AACjC,8EAA0E;AAE1E,mBAAO;KACF,OAAO,CAAC,sBAAG,CAA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;AACL,CAAC;AAED,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const config_1 = require("@streamr/config");
|
|
5
|
+
const dht_1 = require("@streamr/dht");
|
|
6
|
+
const main = async () => {
|
|
7
|
+
const entryPoint = config_1.config.dev2.entryPoints[0];
|
|
8
|
+
const peerDescriptor = {
|
|
9
|
+
...entryPoint,
|
|
10
|
+
nodeId: (0, dht_1.getRawFromDhtAddress)(entryPoint.nodeId),
|
|
11
|
+
type: dht_1.NodeType.NODEJS // TODO remove this when NET-1070 done
|
|
12
|
+
};
|
|
13
|
+
const dhtNode = new dht_1.DhtNode({
|
|
14
|
+
nodeId: entryPoint.nodeId,
|
|
15
|
+
websocketHost: entryPoint.websocket.host,
|
|
16
|
+
websocketPortRange: {
|
|
17
|
+
min: entryPoint.websocket.port,
|
|
18
|
+
max: entryPoint.websocket.port
|
|
19
|
+
},
|
|
20
|
+
websocketServerEnableTls: false,
|
|
21
|
+
entryPoints: [peerDescriptor]
|
|
22
|
+
});
|
|
23
|
+
await dhtNode.start();
|
|
24
|
+
await dhtNode.joinDht([peerDescriptor]);
|
|
25
|
+
console.info('Entry point started');
|
|
26
|
+
};
|
|
27
|
+
main();
|
|
28
|
+
//# sourceMappingURL=entry-point.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../bin/entry-point.ts"],"names":[],"mappings":";;;AACA,4CAAwD;AACxD,sCAAkF;AAElF,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IACpB,MAAM,UAAU,GAAG,eAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;IACnD,MAAM,cAAc,GAAG;QACnB,GAAG,UAAU;QACb,MAAM,EAAE,IAAA,0BAAoB,EAAC,UAAU,CAAC,MAAoB,CAAC;QAC7D,IAAI,EAAE,cAAQ,CAAC,MAAM,CAAE,sCAAsC;KAChE,CAAA;IACD,MAAM,OAAO,GAAG,IAAI,aAAO,CAAC;QACxB,MAAM,EAAE,UAAU,CAAC,MAAoB;QACvC,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI;QACxC,kBAAkB,EAAE;YAChB,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI;YAC9B,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI;SACjC;QACD,wBAAwB,EAAE,KAAK;QAC/B,WAAW,EAAE,CAAC,cAAc,CAAC;KAChC,CAAC,CAAA;IACF,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrB,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAA;IACvC,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;AACvC,CAAC,CAAA;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@streamr/node",
|
|
3
|
+
"version": "100.0.0-rc.0",
|
|
4
|
+
"description": "A full-featured node implementation for the Streamr Network",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/streamr-dev/network.git",
|
|
8
|
+
"directory": "packages/broker"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"streamr-broker": "dist/bin/broker.js",
|
|
12
|
+
"streamr-broker-init": "dist/bin/config-wizard.js",
|
|
13
|
+
"delete-expired-data": "dist/bin/delete-expired-data.js",
|
|
14
|
+
"entry-point": "dist/bin/entry-point.js"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/src/exports.js",
|
|
17
|
+
"types": "./dist/src/exports.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -b tsconfig.node.json",
|
|
20
|
+
"check": "tsc -p ./tsconfig.jest.json --noEmit",
|
|
21
|
+
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
22
|
+
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
23
|
+
"test": "npm run test-unit && npm run test-integration && npm run test-sequential",
|
|
24
|
+
"test-unit": "jest test/unit",
|
|
25
|
+
"test-sequential": "jest --bail --forceExit --maxWorkers=1 test/sequential # always run sequential tests with maxWorkers=1",
|
|
26
|
+
"test-integration": "jest --bail --forceExit test/integration && npm run test-sequential"
|
|
27
|
+
},
|
|
28
|
+
"author": "Streamr Network AG <contact@streamr.network>",
|
|
29
|
+
"license": "STREAMR NETWORK OPEN SOURCE LICENSE",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@ethersproject/hdnode": "^5.4.0",
|
|
32
|
+
"@inquirer/prompts": "^4.0.0",
|
|
33
|
+
"@streamr/config": "^5.1.2",
|
|
34
|
+
"@streamr/network-contracts": "^7.0.8",
|
|
35
|
+
"@streamr/protocol": "100.0.0-rc.0",
|
|
36
|
+
"@streamr/sdk": "100.0.0-rc.0",
|
|
37
|
+
"@streamr/utils": "100.0.0-rc.0",
|
|
38
|
+
"aedes": "^0.51.0",
|
|
39
|
+
"ajv": "^8.8.2",
|
|
40
|
+
"ajv-formats": "^2.1.1",
|
|
41
|
+
"cassandra-driver": "^4.7.2",
|
|
42
|
+
"chalk": "^4.0.0",
|
|
43
|
+
"commander": "^12.0.0",
|
|
44
|
+
"consistent-hash": "^1.1.1",
|
|
45
|
+
"cors": "^2.8.5",
|
|
46
|
+
"ethers": "^5.4.7",
|
|
47
|
+
"express": "^4.17.1",
|
|
48
|
+
"heap": "^0.2.6",
|
|
49
|
+
"lodash": "^4.17.21",
|
|
50
|
+
"merge2": "^1.4.1",
|
|
51
|
+
"nat-type-identifier": "^2.0.9",
|
|
52
|
+
"node-fetch": "^2.7.0",
|
|
53
|
+
"p-limit": "^3.1.0",
|
|
54
|
+
"qs": "^6.10.1",
|
|
55
|
+
"uuid": "^9.0.1",
|
|
56
|
+
"ws": "^8.16.0",
|
|
57
|
+
"zod": "^3.22.4"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@inquirer/testing": "^2.1.11",
|
|
61
|
+
"@streamr/dht": "100.0.0-rc.0",
|
|
62
|
+
"@streamr/test-utils": "100.0.0-rc.0",
|
|
63
|
+
"@types/cors": "^2.8.17",
|
|
64
|
+
"@types/express": "^4.17.21",
|
|
65
|
+
"@types/heap": "^0.2.34",
|
|
66
|
+
"@types/lodash": "^4.14.202",
|
|
67
|
+
"@types/merge2": "^1.4.4",
|
|
68
|
+
"@types/node-fetch": "^2.6.4",
|
|
69
|
+
"@types/qs": "^6.9.11",
|
|
70
|
+
"@types/stream-to-array": "^2.3.3",
|
|
71
|
+
"@types/supertest": "^6.0.2",
|
|
72
|
+
"@types/uuid": "^9.0.8",
|
|
73
|
+
"@types/ws": "^8.5.10",
|
|
74
|
+
"async-mqtt": "^2.6.1",
|
|
75
|
+
"stream-to-array": "^2.3.0",
|
|
76
|
+
"supertest": "^6.3.4"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StrictConfig } from './config/config';
|
|
2
|
+
import { Schema } from 'ajv';
|
|
3
|
+
import { StreamrClient } from '@streamr/sdk';
|
|
4
|
+
import { Endpoint } from './httpServer';
|
|
5
|
+
import { ApiAuthentication } from './apiAuthentication';
|
|
6
|
+
export interface ApiPluginConfig {
|
|
7
|
+
apiAuthentication?: ApiAuthentication | null;
|
|
8
|
+
}
|
|
9
|
+
export type HttpServerEndpoint = Omit<Endpoint, 'apiAuthentication'>;
|
|
10
|
+
export declare abstract class Plugin<T extends object> {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly pluginConfig: T;
|
|
13
|
+
readonly brokerConfig: StrictConfig;
|
|
14
|
+
private readonly httpServerEndpoints;
|
|
15
|
+
constructor(name: string, brokerConfig: StrictConfig);
|
|
16
|
+
getApiAuthentication(): ApiAuthentication | undefined;
|
|
17
|
+
addHttpServerEndpoint(endpoint: HttpServerEndpoint): void;
|
|
18
|
+
getHttpServerEndpoints(): HttpServerEndpoint[];
|
|
19
|
+
/**
|
|
20
|
+
* This lifecycle method is called once when Broker starts
|
|
21
|
+
*/
|
|
22
|
+
abstract start(streamrClient: StreamrClient): Promise<unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* This lifecycle method is called once when Broker stops
|
|
25
|
+
* It is be called only if the plugin was started successfully
|
|
26
|
+
*/
|
|
27
|
+
abstract stop(): Promise<unknown>;
|
|
28
|
+
getConfigSchema(): Schema | undefined;
|
|
29
|
+
getClientConfig(): {
|
|
30
|
+
path: string;
|
|
31
|
+
value: any;
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Plugin = void 0;
|
|
4
|
+
const validateConfig_1 = require("./config/validateConfig");
|
|
5
|
+
class Plugin {
|
|
6
|
+
name;
|
|
7
|
+
pluginConfig;
|
|
8
|
+
brokerConfig;
|
|
9
|
+
httpServerEndpoints = [];
|
|
10
|
+
constructor(name, brokerConfig) {
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.brokerConfig = brokerConfig;
|
|
13
|
+
this.pluginConfig = brokerConfig.plugins[this.name];
|
|
14
|
+
const configSchema = this.getConfigSchema();
|
|
15
|
+
if (configSchema !== undefined) {
|
|
16
|
+
(0, validateConfig_1.validateConfig)(this.pluginConfig, configSchema, `${this.name} plugin`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
getApiAuthentication() {
|
|
20
|
+
if ('apiAuthentication' in this.pluginConfig) {
|
|
21
|
+
return this.pluginConfig.apiAuthentication ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return this.brokerConfig.apiAuthentication;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
addHttpServerEndpoint(endpoint) {
|
|
28
|
+
this.httpServerEndpoints.push(endpoint);
|
|
29
|
+
}
|
|
30
|
+
getHttpServerEndpoints() {
|
|
31
|
+
return this.httpServerEndpoints;
|
|
32
|
+
}
|
|
33
|
+
// eslint-disable-next-line class-methods-use-this
|
|
34
|
+
getConfigSchema() {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line class-methods-use-this
|
|
38
|
+
getClientConfig() {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Plugin = Plugin;
|
|
43
|
+
//# sourceMappingURL=Plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":";;;AACA,4DAAwD;AAYxD,MAAsB,MAAM;IAEf,IAAI,CAAQ;IACZ,YAAY,CAAG;IACf,YAAY,CAAc;IAClB,mBAAmB,GAAyB,EAAE,CAAA;IAE/D,YAAY,IAAY,EAAE,YAA0B;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;QAC3C,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAA,+BAAc,EAAC,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,IAAI,SAAS,CAAC,CAAA;QAC1E,CAAC;IACL,CAAC;IAED,oBAAoB;QAChB,IAAI,mBAAmB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3C,OAAQ,IAAI,CAAC,YAAY,CAAC,iBAAgD,IAAI,SAAS,CAAA;QAC3F,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAA;QAC9C,CAAC;IACL,CAAC;IAED,qBAAqB,CAAC,QAA4B;QAC9C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3C,CAAC;IAED,sBAAsB;QAClB,OAAO,IAAI,CAAC,mBAAmB,CAAA;IACnC,CAAC;IAaD,kDAAkD;IAClD,eAAe;QACX,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,kDAAkD;IAClD,eAAe;QACX,OAAO,EAAE,CAAA;IACb,CAAC;CACJ;AArDD,wBAqDC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidAuthentication = void 0;
|
|
4
|
+
const isValidAuthentication = (apiKey, apiAuthentication) => {
|
|
5
|
+
if (apiAuthentication !== undefined) {
|
|
6
|
+
if (apiKey === undefined) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return apiAuthentication.keys.includes(apiKey);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.isValidAuthentication = isValidAuthentication;
|
|
16
|
+
//# sourceMappingURL=apiAuthentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiAuthentication.js","sourceRoot":"","sources":["../../src/apiAuthentication.ts"],"names":[],"mappings":";;;AAIO,MAAM,qBAAqB,GAAG,CAAC,MAAe,EAAE,iBAAqC,EAAW,EAAE;IACrG,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,KAAK,CAAA;QAChB,CAAC;QACD,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAClD,CAAC;SAAM,CAAC;QACJ,OAAO,IAAI,CAAA;IACf,CAAC;AACL,CAAC,CAAA;AATY,QAAA,qBAAqB,yBASjC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import StreamrClient from '@streamr/sdk';
|
|
2
|
+
import { Config } from './config/config';
|
|
3
|
+
export interface Broker {
|
|
4
|
+
getStreamrClient: () => StreamrClient;
|
|
5
|
+
start: () => Promise<unknown>;
|
|
6
|
+
stop: () => Promise<unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare const createBroker: (configWithoutDefaults: Config) => Promise<Broker>;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.createBroker = void 0;
|
|
7
|
+
const utils_1 = require("@streamr/utils");
|
|
8
|
+
const sdk_1 = __importDefault(require("@streamr/sdk"));
|
|
9
|
+
const package_json_1 = require("../package.json");
|
|
10
|
+
const config_schema_json_1 = __importDefault(require("./config/config.schema.json"));
|
|
11
|
+
const validateConfig_1 = require("./config/validateConfig");
|
|
12
|
+
const applyPluginClientConfigs_1 = require("./helpers/applyPluginClientConfigs");
|
|
13
|
+
const generateMnemonicFromAddress_1 = require("./helpers/generateMnemonicFromAddress");
|
|
14
|
+
const httpServer_1 = require("./httpServer");
|
|
15
|
+
const pluginRegistry_1 = require("./pluginRegistry");
|
|
16
|
+
const logger = new utils_1.Logger(module);
|
|
17
|
+
const createBroker = async (configWithoutDefaults) => {
|
|
18
|
+
const config = (0, validateConfig_1.validateConfig)(configWithoutDefaults, config_schema_json_1.default);
|
|
19
|
+
const plugins = Object.keys(config.plugins).map((name) => (0, pluginRegistry_1.createPlugin)(name, config));
|
|
20
|
+
(0, applyPluginClientConfigs_1.applyPluginClientConfigs)(plugins, config.client);
|
|
21
|
+
const streamrClient = new sdk_1.default(config.client);
|
|
22
|
+
let httpServer;
|
|
23
|
+
return {
|
|
24
|
+
getStreamrClient: () => {
|
|
25
|
+
return streamrClient;
|
|
26
|
+
},
|
|
27
|
+
start: async () => {
|
|
28
|
+
logger.info(`Start Streamr node version ${package_json_1.version}`);
|
|
29
|
+
await Promise.all(plugins.map((plugin) => plugin.start(streamrClient)));
|
|
30
|
+
const httpServerEndpoints = plugins.flatMap((plugin) => {
|
|
31
|
+
return plugin.getHttpServerEndpoints().map((endpoint) => {
|
|
32
|
+
return { ...endpoint, apiAuthentication: plugin.getApiAuthentication() };
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
if (httpServerEndpoints.length > 0) {
|
|
36
|
+
httpServer = await (0, httpServer_1.startServer)(httpServerEndpoints, config.httpServer);
|
|
37
|
+
}
|
|
38
|
+
const nodeId = await streamrClient.getNodeId();
|
|
39
|
+
const brokerAddress = await streamrClient.getAddress();
|
|
40
|
+
const mnemonic = (0, generateMnemonicFromAddress_1.generateMnemonicFromAddress)((0, utils_1.toEthereumAddress)(brokerAddress));
|
|
41
|
+
logger.info(`Welcome to the Streamr Network. Your node's generated name is ${mnemonic}.`);
|
|
42
|
+
logger.info(`Network node ${nodeId} running`);
|
|
43
|
+
logger.info(`Node address ${brokerAddress}`);
|
|
44
|
+
logger.info(`Plugins: ${JSON.stringify(plugins.map((p) => p.name))}`);
|
|
45
|
+
if (!config.client.network?.controlLayer?.webrtcAllowPrivateAddresses) {
|
|
46
|
+
logger.warn('WebRTC private address probing is disabled. ' +
|
|
47
|
+
'This makes it impossible to create network layer connections directly via local routers ' +
|
|
48
|
+
'More info: https://github.com/streamr-dev/network-monorepo/wiki/WebRTC-private-addresses');
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
stop: async () => {
|
|
52
|
+
if (httpServer !== undefined) {
|
|
53
|
+
await (0, httpServer_1.stopServer)(httpServer);
|
|
54
|
+
}
|
|
55
|
+
await Promise.all(plugins.map((plugin) => plugin.stop()));
|
|
56
|
+
await streamrClient.destroy();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.createBroker = createBroker;
|
|
61
|
+
process.on('uncaughtException', (err) => {
|
|
62
|
+
logger.fatal('Encountered uncaughtException', { err });
|
|
63
|
+
process.exit(1);
|
|
64
|
+
});
|
|
65
|
+
process.on('unhandledRejection', (err) => {
|
|
66
|
+
logger.fatal('Encountered unhandledRejection', { err });
|
|
67
|
+
process.exit(1);
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=broker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../src/broker.ts"],"names":[],"mappings":";;;;;;AAAA,0CAA0D;AAG1D,uDAAwC;AACxC,kDAA4D;AAG5D,qFAA8D;AAC9D,4DAAwD;AACxD,iFAA6E;AAC7E,uFAAmF;AACnF,6CAAyE;AACzE,qDAA+C;AAE/C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAQ1B,MAAM,YAAY,GAAG,KAAK,EAAE,qBAA6B,EAAmB,EAAE;IACjF,MAAM,MAAM,GAAG,IAAA,+BAAc,EAAC,qBAAqB,EAAE,4BAAoB,CAAC,CAAA;IAC1E,MAAM,OAAO,GAAkB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,6BAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;IACpG,IAAA,mDAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAEtD,IAAI,UAAgD,CAAA;IAEpD,OAAO;QACH,gBAAgB,EAAE,GAAG,EAAE;YACnB,OAAO,aAAa,CAAA;QACxB,CAAC;QACD,KAAK,EAAE,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