@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
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getNodeMnemonic = exports.start = void 0;
|
|
30
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
31
|
+
const config_1 = require("@streamr/config");
|
|
32
|
+
const utils_1 = require("@streamr/utils");
|
|
33
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
34
|
+
const ethers_1 = require("ethers");
|
|
35
|
+
const utils_2 = require("ethers/lib/utils");
|
|
36
|
+
const fs_1 = require("fs");
|
|
37
|
+
const capitalize_1 = __importDefault(require("lodash/capitalize"));
|
|
38
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
39
|
+
const path_1 = __importDefault(require("path"));
|
|
40
|
+
const uuid_1 = require("uuid");
|
|
41
|
+
const zod_1 = require("zod");
|
|
42
|
+
const migration_1 = require("../config/migration");
|
|
43
|
+
const generateMnemonicFromAddress_1 = require("../helpers/generateMnemonicFromAddress");
|
|
44
|
+
const MqttConfigSchema = __importStar(require("../plugins/mqtt/config.schema.json"));
|
|
45
|
+
const WebsocketConfigSchema = __importStar(require("../plugins/websocket/config.schema.json"));
|
|
46
|
+
const config_2 = require("./config");
|
|
47
|
+
const BrokerConfigSchema = __importStar(require("./config.schema.json"));
|
|
48
|
+
const MIN_BALANCE = ethers_1.utils.parseEther('0.1');
|
|
49
|
+
async function start() {
|
|
50
|
+
log(`
|
|
51
|
+
>
|
|
52
|
+
> ***Welcome to the Streamr Network!***
|
|
53
|
+
> This Config Wizard will help you setup your node.
|
|
54
|
+
>
|
|
55
|
+
> The steps are documented here:
|
|
56
|
+
> *https://docs.streamr.network/guides/how-to-run-streamr-node#config-wizard*
|
|
57
|
+
>
|
|
58
|
+
`);
|
|
59
|
+
try {
|
|
60
|
+
const privateKey = await getPrivateKey();
|
|
61
|
+
const nodeAddress = new ethers_1.Wallet(privateKey).address;
|
|
62
|
+
const environmentId = await getEnvironmentId();
|
|
63
|
+
const operator = await getOperatorAddress();
|
|
64
|
+
const operatorPlugins = operator ? {
|
|
65
|
+
operator: {
|
|
66
|
+
operatorContractAddress: operator,
|
|
67
|
+
},
|
|
68
|
+
} : {};
|
|
69
|
+
const { http, ...pubsubPlugins } = await getPubsubPlugins();
|
|
70
|
+
/**
|
|
71
|
+
* Port number for the `http` plugin has to be defined within
|
|
72
|
+
* the `httpServer` object in the config's root. See below.
|
|
73
|
+
*/
|
|
74
|
+
if (http) {
|
|
75
|
+
Object.assign(pubsubPlugins, {
|
|
76
|
+
http: (0, omit_1.default)(http, 'port'),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const httpServer = http?.port ? { port: http.port } : undefined;
|
|
80
|
+
const storagePath = await getStoragePath();
|
|
81
|
+
const apiKey = Buffer.from((0, uuid_1.v4)().replace(/-/g, ''))
|
|
82
|
+
.toString('base64')
|
|
83
|
+
.replace(/[^\da-z]/gi, '');
|
|
84
|
+
const config = {
|
|
85
|
+
$schema: (0, migration_1.formSchemaUrl)(migration_1.CURRENT_CONFIGURATION_VERSION),
|
|
86
|
+
client: {
|
|
87
|
+
auth: {
|
|
88
|
+
privateKey,
|
|
89
|
+
},
|
|
90
|
+
environment: environmentId,
|
|
91
|
+
},
|
|
92
|
+
plugins: {
|
|
93
|
+
...operatorPlugins,
|
|
94
|
+
...pubsubPlugins,
|
|
95
|
+
},
|
|
96
|
+
httpServer,
|
|
97
|
+
apiAuthentication: {
|
|
98
|
+
keys: [apiKey],
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
persistConfig(storagePath, config);
|
|
102
|
+
log(`
|
|
103
|
+
>
|
|
104
|
+
> ~ *Congratulations, you've setup your Streamr node!*
|
|
105
|
+
> Your node address is ${chalk_1.default.greenBright(nodeAddress)}
|
|
106
|
+
> Your node's generated name is ${chalk_1.default.greenBright(getNodeMnemonic(privateKey))}
|
|
107
|
+
`);
|
|
108
|
+
if (operator) {
|
|
109
|
+
const resume = animateLine((spinner) => style(`> Your node address has *${spinner} MATIC* _– checking balance…_`));
|
|
110
|
+
try {
|
|
111
|
+
const balance = await getNativeBalance(environmentId, nodeAddress);
|
|
112
|
+
const content = `Your node address has *${Number(ethers_1.utils.formatEther(balance)).toFixed(2)} MATIC*`;
|
|
113
|
+
resume();
|
|
114
|
+
if (balance.lt(MIN_BALANCE)) {
|
|
115
|
+
log(`
|
|
116
|
+
> ! ${content}. You'll need to fund it with a small amount of MATIC tokens.
|
|
117
|
+
`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
log(`> ${content}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
resume();
|
|
125
|
+
log('> x Failed to fetch node\'s balance');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (operator) {
|
|
129
|
+
log('> ');
|
|
130
|
+
const resume = animateLine((spinner) => style(`
|
|
131
|
+
> _Checking if your node has been paired with your Operator… ${spinner}_
|
|
132
|
+
`));
|
|
133
|
+
try {
|
|
134
|
+
const nodes = await getOperatorNodeAddresses(environmentId, operator);
|
|
135
|
+
resume();
|
|
136
|
+
const hub = environmentId === 'polygon'
|
|
137
|
+
? 'https://streamr.network/hub'
|
|
138
|
+
: 'https://mumbai.streamr.network/hub';
|
|
139
|
+
if (nodes !== undefined) {
|
|
140
|
+
if (!nodes.includes(nodeAddress.toLowerCase())) {
|
|
141
|
+
log('> ! You will need to pair your node with your Operator:');
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
log('> Your node has been paired with your Operator:');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
log(`
|
|
149
|
+
> x Your Operator could not be found on the **${(0, capitalize_1.default)(environmentId)}** network, see
|
|
150
|
+
`);
|
|
151
|
+
}
|
|
152
|
+
log(`> *${hub}/network/operators/${operator}*`);
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
resume();
|
|
156
|
+
log('> x Failed to fetch operator nodes');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
log(`
|
|
160
|
+
>
|
|
161
|
+
> You can start your Streamr node now with
|
|
162
|
+
> *streamr-broker ${storagePath}*
|
|
163
|
+
>
|
|
164
|
+
> For environment specific run instructions, see
|
|
165
|
+
> *https://docs.streamr.network/guides/how-to-run-streamr-node*
|
|
166
|
+
>
|
|
167
|
+
`);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
if (typeof e.message === 'string' && /force closed/i.test(e.message)) {
|
|
171
|
+
/**
|
|
172
|
+
* Hitting ctrl+c key combination causes the `inquirer` library to throw
|
|
173
|
+
* the "User force closed the prompt" exception. Let's ignore it.
|
|
174
|
+
*/
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
throw e;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.start = start;
|
|
181
|
+
/**
|
|
182
|
+
* Generates a mnemonic for a given private key.
|
|
183
|
+
*/
|
|
184
|
+
function getNodeMnemonic(privateKey) {
|
|
185
|
+
return (0, generateMnemonicFromAddress_1.generateMnemonicFromAddress)((0, utils_1.toEthereumAddress)(new ethers_1.Wallet(privateKey).address));
|
|
186
|
+
}
|
|
187
|
+
exports.getNodeMnemonic = getNodeMnemonic;
|
|
188
|
+
/**
|
|
189
|
+
* Lets the user generate a private key or import an existing private key.
|
|
190
|
+
*/
|
|
191
|
+
async function getPrivateKey() {
|
|
192
|
+
const privateKeySource = await (0, prompts_1.select)({
|
|
193
|
+
message: 'Do you want to generate a new Ethereum private key or import an existing one?',
|
|
194
|
+
choices: [{ value: 'Generate' }, { value: 'Import' }],
|
|
195
|
+
});
|
|
196
|
+
const privateKey = await (async () => {
|
|
197
|
+
if (privateKeySource === 'Generate') {
|
|
198
|
+
return ethers_1.Wallet.createRandom().privateKey;
|
|
199
|
+
}
|
|
200
|
+
return (0, prompts_1.password)({
|
|
201
|
+
message: 'Please provide the private key to import',
|
|
202
|
+
validate(value) {
|
|
203
|
+
try {
|
|
204
|
+
new ethers_1.Wallet(value);
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
catch (_) {
|
|
208
|
+
return 'Invalid private key provided.';
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
})();
|
|
213
|
+
if (privateKeySource === 'Generate') {
|
|
214
|
+
await (0, prompts_1.confirm)({
|
|
215
|
+
message:
|
|
216
|
+
// eslint-disable-next-line max-len
|
|
217
|
+
'We strongly recommend backing up your private key. It will be written into the config file, but would you also like to see this sensitive information on screen now?',
|
|
218
|
+
default: false,
|
|
219
|
+
transformer(value) {
|
|
220
|
+
return value ? `Your node's private key: ${privateKey}` : 'no';
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return privateKey;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Lets the user decide the desired network for their node.
|
|
228
|
+
*/
|
|
229
|
+
async function getEnvironmentId() {
|
|
230
|
+
return (0, prompts_1.select)({
|
|
231
|
+
message: 'Which network do you want to configure your node to connect to?',
|
|
232
|
+
choices: [
|
|
233
|
+
{ value: 'polygon', name: 'Streamr 1.0 testnet + Polygon' },
|
|
234
|
+
{
|
|
235
|
+
value: 'mumbai',
|
|
236
|
+
name: 'Streamr 1.0 testing environment + Mumbai',
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
default: 'polygon',
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Lets the user gather and configure desired operator plugins.
|
|
244
|
+
* @returns A valid Ethereum address if the user decide to participate
|
|
245
|
+
* in earning rewards, and `undefined` otherwise.
|
|
246
|
+
*/
|
|
247
|
+
async function getOperatorAddress() {
|
|
248
|
+
const setupOperator = await (0, prompts_1.confirm)({
|
|
249
|
+
message: 'Do you wish to participate in earning rewards by staking on stream Sponsorships?',
|
|
250
|
+
default: true,
|
|
251
|
+
});
|
|
252
|
+
if (!setupOperator) {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
const operator = await (0, prompts_1.input)({
|
|
256
|
+
message: 'Enter your Operator address:',
|
|
257
|
+
validate(value) {
|
|
258
|
+
return (0, utils_2.isAddress)(value) ? true : 'Invalid ethereum address';
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
return operator.toLowerCase();
|
|
262
|
+
}
|
|
263
|
+
const DEFAULT_PORTS = {
|
|
264
|
+
websocket: WebsocketConfigSchema.properties.port.default,
|
|
265
|
+
mqtt: MqttConfigSchema.properties.port.default,
|
|
266
|
+
http: BrokerConfigSchema.properties.httpServer.properties.port.default,
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Lets the user select and configure desired pub/sub plugins.
|
|
270
|
+
*/
|
|
271
|
+
async function getPubsubPlugins() {
|
|
272
|
+
const setupPubsub = await (0, prompts_1.confirm)({
|
|
273
|
+
message: 'Do you wish to use your node for data publishing/subscribing?',
|
|
274
|
+
default: true,
|
|
275
|
+
});
|
|
276
|
+
if (!setupPubsub) {
|
|
277
|
+
return {};
|
|
278
|
+
}
|
|
279
|
+
const keys = await (0, prompts_1.checkbox)({
|
|
280
|
+
message: 'Select the plugins to enable',
|
|
281
|
+
choices: [
|
|
282
|
+
{ value: 'websocket', name: 'WebSocket' },
|
|
283
|
+
{ value: 'mqtt', name: 'MQTT' },
|
|
284
|
+
{ value: 'http', name: 'HTTP' },
|
|
285
|
+
],
|
|
286
|
+
});
|
|
287
|
+
const pubsubPlugins = {};
|
|
288
|
+
for (const key of keys) {
|
|
289
|
+
const defaultPort = DEFAULT_PORTS[key];
|
|
290
|
+
const port = Number(await (0, prompts_1.input)({
|
|
291
|
+
message: `Provide a port for the ${key} plugin`,
|
|
292
|
+
default: defaultPort.toString(),
|
|
293
|
+
validate(value) {
|
|
294
|
+
try {
|
|
295
|
+
zod_1.z.coerce
|
|
296
|
+
.number({
|
|
297
|
+
invalid_type_error: 'Non-numeric value provided',
|
|
298
|
+
})
|
|
299
|
+
.int('Non-integer value provided')
|
|
300
|
+
.min(1024)
|
|
301
|
+
.max(49151)
|
|
302
|
+
.superRefine((value, ctx) => {
|
|
303
|
+
const [pluginKey] = Object.entries(pubsubPlugins).find(([pluginKey, plugin]) => value ===
|
|
304
|
+
(plugin.port ||
|
|
305
|
+
DEFAULT_PORTS[pluginKey])) || [];
|
|
306
|
+
if (pluginKey) {
|
|
307
|
+
ctx.addIssue({
|
|
308
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
309
|
+
message: `Port ${value} is taken by ${pluginKey}`,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
.parse(value);
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
catch (e) {
|
|
317
|
+
return e.issues
|
|
318
|
+
.map(({ message }) => message)
|
|
319
|
+
.join(', ');
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
}));
|
|
323
|
+
pubsubPlugins[key] = port !== defaultPort ? { port } : {};
|
|
324
|
+
}
|
|
325
|
+
return pubsubPlugins;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Lets the user decide where to write the config file.
|
|
329
|
+
*/
|
|
330
|
+
async function getStoragePath() {
|
|
331
|
+
// eslint-disable-next-line no-constant-condition
|
|
332
|
+
while (true) {
|
|
333
|
+
const path = await (0, prompts_1.input)({
|
|
334
|
+
message: 'Select a path to store the generated config in',
|
|
335
|
+
default: (0, config_2.getDefaultFile)(),
|
|
336
|
+
});
|
|
337
|
+
const proceed = !(0, fs_1.existsSync)(path) ||
|
|
338
|
+
(await (0, prompts_1.confirm)({
|
|
339
|
+
message: `The selected destination ${path} already exists. Do you want to overwrite it?`,
|
|
340
|
+
default: false,
|
|
341
|
+
}));
|
|
342
|
+
if (proceed) {
|
|
343
|
+
return path;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Writes the config into a file.
|
|
349
|
+
*/
|
|
350
|
+
function persistConfig(storagePath, config) {
|
|
351
|
+
const dirPath = path_1.default.dirname(storagePath);
|
|
352
|
+
if (!(0, fs_1.existsSync)(dirPath)) {
|
|
353
|
+
(0, fs_1.mkdirSync)(dirPath, {
|
|
354
|
+
recursive: true,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
(0, fs_1.writeFileSync)(storagePath, JSON.stringify(config, null, 4));
|
|
358
|
+
(0, fs_1.chmodSync)(storagePath, '600');
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Gets a wallet balance of the network-native token for the given
|
|
362
|
+
* wallet address.
|
|
363
|
+
*/
|
|
364
|
+
async function getNativeBalance(environmentId, address) {
|
|
365
|
+
const url = config_1.config[environmentId].rpcEndpoints[0]?.url;
|
|
366
|
+
if (!url || !/^https?:/i.test(url)) {
|
|
367
|
+
throw new Error('Invalid RPC');
|
|
368
|
+
}
|
|
369
|
+
return new ethers_1.providers.JsonRpcProvider(url).getBalance(address);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Gets an array of node addresses associated with the given operator
|
|
373
|
+
* contract address on the given network.
|
|
374
|
+
*/
|
|
375
|
+
async function getOperatorNodeAddresses(environmentId, operatorAddress) {
|
|
376
|
+
const url = config_1.config[environmentId].theGraphUrl;
|
|
377
|
+
const resp = await fetch(url, {
|
|
378
|
+
method: 'POST',
|
|
379
|
+
body: JSON.stringify({
|
|
380
|
+
query: `query { operator(id: "${operatorAddress}") { nodes } }`,
|
|
381
|
+
}),
|
|
382
|
+
});
|
|
383
|
+
const { data } = zod_1.z
|
|
384
|
+
.object({
|
|
385
|
+
data: zod_1.z.object({
|
|
386
|
+
operator: zod_1.z.union([
|
|
387
|
+
zod_1.z.null(),
|
|
388
|
+
zod_1.z.object({ nodes: zod_1.z.array(zod_1.z.string()) }),
|
|
389
|
+
]),
|
|
390
|
+
}),
|
|
391
|
+
})
|
|
392
|
+
.parse(await resp.json());
|
|
393
|
+
return data.operator ? data.operator.nodes : undefined;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Prints out an animated busyness indicator and does not move on
|
|
397
|
+
* to the next line until torn down.
|
|
398
|
+
* @returns A teardown callback that cleans up the line and brings
|
|
399
|
+
* the cursor to BOL.
|
|
400
|
+
*/
|
|
401
|
+
function animateLine(fn) {
|
|
402
|
+
const frames = '◢◣◤◥';
|
|
403
|
+
let frameNo = 0;
|
|
404
|
+
function tick() {
|
|
405
|
+
/**
|
|
406
|
+
* `isTTY` is false in CI which also means `clearLine` and
|
|
407
|
+
* `cursorTo` are not functions.
|
|
408
|
+
*/
|
|
409
|
+
if (process.stdout.isTTY) {
|
|
410
|
+
process.stdout.clearLine(0);
|
|
411
|
+
process.stdout.cursorTo(0);
|
|
412
|
+
}
|
|
413
|
+
process.stdout.write(fn(frames[frameNo]));
|
|
414
|
+
frameNo = (frameNo + 1) % frames.length;
|
|
415
|
+
}
|
|
416
|
+
tick();
|
|
417
|
+
const intervalId = setInterval(tick, 400);
|
|
418
|
+
return () => {
|
|
419
|
+
clearInterval(intervalId);
|
|
420
|
+
/**
|
|
421
|
+
* `isTTY` is false in CI which also means `clearLine` and
|
|
422
|
+
* `cursorTo` are not functions.
|
|
423
|
+
*/
|
|
424
|
+
if (process.stdout.isTTY) {
|
|
425
|
+
process.stdout.clearLine(0);
|
|
426
|
+
process.stdout.cursorTo(0);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Formats the given message with colors and styles with the use
|
|
432
|
+
* of a markdown-ish syntax, like:
|
|
433
|
+
* - \*\*bold\*\*,
|
|
434
|
+
* - \_dim\_,
|
|
435
|
+
* - \*bright white\*,
|
|
436
|
+
* - \> indent normally,
|
|
437
|
+
* - \> ! indent as a warning,
|
|
438
|
+
* - \> x indent as an error, and
|
|
439
|
+
* - \> ~ indent as a confirmation or success.
|
|
440
|
+
*/
|
|
441
|
+
function style(message) {
|
|
442
|
+
let result = message;
|
|
443
|
+
const filters = [
|
|
444
|
+
[/\*\*([^*]+)\*\*/g, chalk_1.default.bold],
|
|
445
|
+
[/\*([^*]+)\*/g, chalk_1.default.whiteBright],
|
|
446
|
+
[/_([^_]+)_/g, chalk_1.default.gray],
|
|
447
|
+
];
|
|
448
|
+
for (const [regexp, colorer] of filters) {
|
|
449
|
+
result = result.replace(regexp, (_, m) => colorer(m));
|
|
450
|
+
}
|
|
451
|
+
return result
|
|
452
|
+
.replace(/^[^\S\r\n]*(>?)[^\S\r\n]*([!x~]?)[^\S\r\n]*/gim, (_, indent, decorator) => [
|
|
453
|
+
indent && chalk_1.default.bgGray(' '),
|
|
454
|
+
decorator === '!' && chalk_1.default.yellowBright.bold(' ! '),
|
|
455
|
+
decorator === 'x' && chalk_1.default.redBright.bold(' ✗ '),
|
|
456
|
+
decorator === '~' && chalk_1.default.greenBright.bold(' ✓ '),
|
|
457
|
+
decorator === '' && ' ',
|
|
458
|
+
]
|
|
459
|
+
.filter(Boolean)
|
|
460
|
+
.join(''))
|
|
461
|
+
.trim();
|
|
462
|
+
}
|
|
463
|
+
function log(message = '') {
|
|
464
|
+
console.info(style(message));
|
|
465
|
+
}
|
|
466
|
+
//# sourceMappingURL=ConfigWizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigWizard.js","sourceRoot":"","sources":["../../../src/config/ConfigWizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA8E;AAC9E,4CAAyD;AACzD,0CAAkD;AAClD,kDAAyB;AACzB,mCAA4D;AAC5D,4CAA4C;AAC5C,2BAAoE;AACpE,mEAA0C;AAC1C,uDAA8B;AAC9B,gDAAuB;AACvB,+BAAiC;AACjC,6BAAuB;AACvB,mDAG4B;AAC5B,wFAAoF;AACpF,qFAAsE;AACtE,+FAAgF;AAChF,qCAAqD;AACrD,yEAA0D;AAE1D,MAAM,WAAW,GAAG,cAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAIpC,KAAK,UAAU,KAAK;IACvB,GAAG,CAAC;;;;;;;;KAQH,CAAC,CAAA;IAEF,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,aAAa,EAAE,CAAA;QAExC,MAAM,WAAW,GAAG,IAAI,eAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAA;QAElD,MAAM,aAAa,GAAG,MAAM,gBAAgB,EAAE,CAAA;QAE9C,MAAM,QAAQ,GAAG,MAAM,kBAAkB,EAAE,CAAA;QAE3C,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC;YAC/B,QAAQ,EAAE;gBACN,uBAAuB,EAAE,QAAQ;aACpC;SACJ,CAAC,CAAC,CAAC,EAAE,CAAA;QAEN,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,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C;QAC3B,SAAS,KAAK,GAAG,IAAI,eAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QACnD,SAAS,KAAK,GAAG,IAAI,eAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QAChD,SAAS,KAAK,GAAG,IAAI,eAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;QAClD,SAAS,KAAK,EAAE,IAAI,KAAK;KAC5B;SACI,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,EAAE,CAAC,CACpB;SACA,IAAI,EAAE,CAAA;AACf,CAAC;AAED,SAAS,GAAG,CAAC,OAAO,GAAG,EAAE;IACrB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StreamrClientConfig } from '@streamr/sdk';
|
|
2
|
+
import { ApiAuthentication } from '../apiAuthentication';
|
|
3
|
+
export interface Config {
|
|
4
|
+
client?: StreamrClientConfig;
|
|
5
|
+
environment?: 'mumbai' | 'polygon';
|
|
6
|
+
httpServer?: {
|
|
7
|
+
port: number;
|
|
8
|
+
sslCertificate?: {
|
|
9
|
+
privateKeyFileName: string;
|
|
10
|
+
certFileName: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
apiAuthentication?: ApiAuthentication;
|
|
14
|
+
plugins?: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
export type StrictConfig = Config & {
|
|
17
|
+
client: Exclude<Config['client'], undefined>;
|
|
18
|
+
plugins: Exclude<Config['plugins'], undefined>;
|
|
19
|
+
httpServer: Exclude<Config['httpServer'], undefined>;
|
|
20
|
+
};
|
|
21
|
+
export interface ConfigFile extends Config {
|
|
22
|
+
$schema?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const getDefaultFile: () => string;
|
|
25
|
+
export declare const getLegacyDefaultFile: () => string;
|
|
26
|
+
export declare function overrideConfigToEnvVarsIfGiven(config: Config): void;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.overrideConfigToEnvVarsIfGiven = exports.getLegacyDefaultFile = exports.getDefaultFile = void 0;
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const os = __importStar(require("os"));
|
|
32
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
33
|
+
const set_1 = __importDefault(require("lodash/set"));
|
|
34
|
+
const getDefaultFile = () => {
|
|
35
|
+
const relativePath = '.streamr/config/default.json';
|
|
36
|
+
return path_1.default.join(os.homedir(), relativePath);
|
|
37
|
+
};
|
|
38
|
+
exports.getDefaultFile = getDefaultFile;
|
|
39
|
+
const getLegacyDefaultFile = () => {
|
|
40
|
+
const relativePath = '/.streamr/broker-config.json';
|
|
41
|
+
return path_1.default.join(os.homedir(), relativePath);
|
|
42
|
+
};
|
|
43
|
+
exports.getLegacyDefaultFile = getLegacyDefaultFile;
|
|
44
|
+
function overrideConfigToEnvVarsIfGiven(config) {
|
|
45
|
+
const parseValue = (value) => {
|
|
46
|
+
const number = /^-?\d+\.?\d*$/;
|
|
47
|
+
if (number.test(value)) {
|
|
48
|
+
return Number(value);
|
|
49
|
+
}
|
|
50
|
+
else if (value === 'true') {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
else if (value === 'false') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
else if (value == 'null') {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const PREFIX = 'STREAMR__BROKER__';
|
|
64
|
+
Object.keys(process.env).forEach((variableName) => {
|
|
65
|
+
if (variableName.startsWith(PREFIX)) {
|
|
66
|
+
const parts = variableName.substring(PREFIX.length).split('__').map((part) => {
|
|
67
|
+
const groups = part.match(/^([A-Z_]*[A-Z])(_\d+)?$/);
|
|
68
|
+
if (groups !== null) {
|
|
69
|
+
const base = (0, camelCase_1.default)(groups[1]);
|
|
70
|
+
const suffix = groups[2];
|
|
71
|
+
if (suffix === undefined) {
|
|
72
|
+
return base;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const index = Number(suffix.substring(1)) - 1;
|
|
76
|
+
return `${base}[${index}]`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new Error(`Malformed environment variable ${variableName}`);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const key = parts.join('.');
|
|
84
|
+
const value = parseValue(process.env[variableName]);
|
|
85
|
+
if (value !== '') {
|
|
86
|
+
(0, set_1.default)(config, key, value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.overrideConfigToEnvVarsIfGiven = overrideConfigToEnvVarsIfGiven;
|
|
92
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAAuB;AACvB,uCAAwB;AACxB,iEAAwC;AACxC,qDAA4B;AA6BrB,MAAM,cAAc,GAAG,GAAW,EAAE;IACvC,MAAM,YAAY,GAAG,8BAA8B,CAAA;IACnD,OAAO,cAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAA;AAChD,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B;AAEM,MAAM,oBAAoB,GAAG,GAAW,EAAE;IAC7C,MAAM,YAAY,GAAG,8BAA8B,CAAA;IACnD,OAAO,cAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAA;AAChD,CAAC,CAAA;AAHY,QAAA,oBAAoB,wBAGhC;AAED,SAAgB,8BAA8B,CAAC,MAAc;IAEzD,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE;QACjC,MAAM,MAAM,GAAG,eAAe,CAAA;QAC9B,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;QACxB,CAAC;aAAM,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAA;QACf,CAAC;aAAM,IA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