@peerbit/server 5.0.33 → 5.0.34-3a75d6e
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/dist/src/aws.browser.d.ts +1 -0
- package/dist/src/aws.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/aws.d.ts +1 -0
- package/dist/src/aws.d.ts.map +1 -0
- package/{lib/esm → dist/src}/aws.js +43 -44
- package/dist/src/aws.js.map +1 -0
- package/dist/src/bin.d.ts +3 -0
- package/dist/src/bin.d.ts.map +1 -0
- package/{lib/esm → dist/src}/bin.js.map +1 -1
- package/{lib/esm → dist/src}/cli.d.ts +1 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/{lib/esm → dist/src}/cli.js +107 -106
- package/dist/src/cli.js.map +1 -0
- package/{lib/esm → dist/src}/client.d.ts +6 -5
- package/dist/src/client.d.ts.map +1 -0
- package/{lib/esm → dist/src}/client.js +28 -36
- package/dist/src/client.js.map +1 -0
- package/dist/src/config.browser.d.ts +1 -0
- package/dist/src/config.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -0
- package/{lib/esm → dist/src}/config.js +6 -6
- package/dist/src/config.js.map +1 -0
- package/dist/src/docker.browser.d.ts +1 -0
- package/dist/src/docker.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/docker.d.ts +1 -0
- package/dist/src/docker.d.ts.map +1 -0
- package/{lib/esm → dist/src}/docker.js +2 -2
- package/dist/src/docker.js.map +1 -0
- package/{lib/esm → dist/src}/domain.d.ts +1 -7
- package/dist/src/domain.d.ts.map +1 -0
- package/{lib/esm → dist/src}/domain.js +6 -13
- package/dist/src/domain.js.map +1 -0
- package/{lib/esm → dist/src}/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{lib/esm → dist/src}/peerbit.d.ts +2 -1
- package/dist/src/peerbit.d.ts.map +1 -0
- package/{lib/esm → dist/src}/peerbit.js +10 -9
- package/dist/src/peerbit.js.map +1 -0
- package/dist/src/remotes.browser.d.ts +1 -0
- package/dist/src/remotes.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/remotes.d.ts +1 -0
- package/dist/src/remotes.d.ts.map +1 -0
- package/{lib/esm → dist/src}/remotes.js +1 -1
- package/{lib/esm → dist/src}/routes.d.ts +1 -0
- package/dist/src/routes.d.ts.map +1 -0
- package/dist/src/server.browser.d.ts +1 -0
- package/dist/src/server.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/server.d.ts +2 -2
- package/dist/src/server.d.ts.map +1 -0
- package/{lib/esm → dist/src}/server.js +25 -27
- package/dist/src/server.js.map +1 -0
- package/{lib/esm → dist/src}/session.d.ts +2 -2
- package/dist/src/session.d.ts.map +1 -0
- package/{lib/esm → dist/src}/session.js +2 -2
- package/{lib/esm/signes-request.d.ts → dist/src/signed-request.d.ts} +3 -3
- package/dist/src/signed-request.d.ts.map +1 -0
- package/{lib/esm/signes-request.js → dist/src/signed-request.js} +3 -3
- package/{lib/esm/signes-request.js.map → dist/src/signed-request.js.map} +1 -1
- package/dist/src/trust.browser.d.ts +1 -0
- package/dist/src/trust.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/trust.d.ts +1 -0
- package/dist/src/trust.d.ts.map +1 -0
- package/{lib/esm → dist/src}/types.d.ts +1 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/test/api.spec.d.ts +2 -0
- package/dist/test/api.spec.d.ts.map +1 -0
- package/dist/test/api.spec.js +223 -0
- package/dist/test/api.spec.js.map +1 -0
- package/dist/test/cli.spec.d.ts +2 -0
- package/dist/test/cli.spec.d.ts.map +1 -0
- package/dist/test/cli.spec.js +264 -0
- package/dist/test/cli.spec.js.map +1 -0
- package/dist/test/client.spec.d.ts +2 -0
- package/dist/test/client.spec.d.ts.map +1 -0
- package/dist/test/client.spec.js +23 -0
- package/dist/test/client.spec.js.map +1 -0
- package/dist/test/config.spec.d.ts +2 -0
- package/dist/test/config.spec.d.ts.map +1 -0
- package/dist/test/config.spec.js +12 -0
- package/dist/test/config.spec.js.map +1 -0
- package/dist/test/domain.integration.spec.d.ts +2 -0
- package/dist/test/domain.integration.spec.d.ts.map +1 -0
- package/dist/test/domain.integration.spec.js +101 -0
- package/dist/test/domain.integration.spec.js.map +1 -0
- package/dist/test/launch.spec.d.ts +1 -0
- package/dist/test/launch.spec.d.ts.map +1 -0
- package/dist/test/launch.spec.js +23 -0
- package/dist/test/launch.spec.js.map +1 -0
- package/dist/test/signed-request.spec.d.ts +2 -0
- package/dist/test/signed-request.spec.d.ts.map +1 -0
- package/dist/test/signed-request.spec.js +35 -0
- package/dist/test/signed-request.spec.js.map +1 -0
- package/dist/test/utils.d.ts +3 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/test/utils.js +6 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/ui/assets/index-BNL2lkmu.js +128 -0
- package/dist/ui/assets/index-q5H34Jar.js +6 -0
- package/{lib → dist}/ui/index.html +3 -3
- package/package.json +90 -78
- package/src/aws.ts +57 -58
- package/src/bin.ts +1 -0
- package/src/cli.ts +149 -146
- package/src/client.ts +66 -81
- package/src/config.ts +12 -12
- package/src/docker.ts +3 -3
- package/src/domain.ts +16 -23
- package/src/peerbit.ts +10 -10
- package/src/remotes.ts +2 -2
- package/src/server.ts +58 -68
- package/src/session.ts +7 -7
- package/src/{signes-request.ts → signed-request.ts} +8 -8
- package/src/trust.ts +1 -1
- package/lib/esm/aws.browser.d.ts +0 -0
- package/lib/esm/aws.js.map +0 -1
- package/lib/esm/bin.d.ts +0 -2
- package/lib/esm/cli.js.map +0 -1
- package/lib/esm/client.js.map +0 -1
- package/lib/esm/config.browser.d.ts +0 -0
- package/lib/esm/config.js.map +0 -1
- package/lib/esm/docker.browser.d.ts +0 -0
- package/lib/esm/docker.js.map +0 -1
- package/lib/esm/domain.js.map +0 -1
- package/lib/esm/peerbit.js.map +0 -1
- package/lib/esm/remotes.browser.d.ts +0 -0
- package/lib/esm/server.browser.d.ts +0 -0
- package/lib/esm/server.js.map +0 -1
- package/lib/esm/trust.browser.d.ts +0 -0
- package/lib/ui/assets/index-BSyx7bor.js +0 -6
- package/lib/ui/assets/index-DUhlTXpa.js +0 -77
- package/lib/ui/assets/manifest-DSoGU8T2.json +0 -25
- /package/{lib/esm → dist}/nginx-template.conf +0 -0
- /package/{lib/esm → dist/src}/aws.browser.js +0 -0
- /package/{lib/esm → dist/src}/aws.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/bin.js +0 -0
- /package/{lib/esm → dist/src}/config.browser.js +0 -0
- /package/{lib/esm → dist/src}/config.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/docker.browser.js +0 -0
- /package/{lib/esm → dist/src}/docker.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/index.js +0 -0
- /package/{lib/esm → dist/src}/index.js.map +0 -0
- /package/{lib/esm → dist/src}/remotes.browser.js +0 -0
- /package/{lib/esm → dist/src}/remotes.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/remotes.js.map +0 -0
- /package/{lib/esm → dist/src}/routes.js +0 -0
- /package/{lib/esm → dist/src}/routes.js.map +0 -0
- /package/{lib/esm → dist/src}/server.browser.js +0 -0
- /package/{lib/esm → dist/src}/server.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/session.js.map +0 -0
- /package/{lib/esm → dist/src}/trust.browser.js +0 -0
- /package/{lib/esm → dist/src}/trust.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/trust.js +0 -0
- /package/{lib/esm → dist/src}/trust.js.map +0 -0
- /package/{lib/esm → dist/src}/types.js +0 -0
- /package/{lib/esm → dist/src}/types.js.map +0 -0
- /package/{lib → dist}/ui/android-chrome-192x192.png +0 -0
- /package/{lib → dist}/ui/android-chrome-512x512.png +0 -0
- /package/{lib → dist}/ui/assets/favicon-BYZpRdSr.ico +0 -0
- /package/{lib → dist}/ui/assets/index-BDBx6C_I.css +0 -0
- /package/{lib → dist}/ui/favicon-16x16.png +0 -0
- /package/{lib → dist}/ui/favicon-32x32.png +0 -0
- /package/{lib → dist}/ui/favicon.ico +0 -0
- /package/{lib → dist}/ui/manifest.json +0 -0
- /package/{lib → dist}/ui/robots.txt +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getHomeConfigDir, getKeypair, getPackageName, getRemotesPath } from "./config.js";
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { peerIdFromString } from "@libp2p/peer-id";
|
|
3
|
+
import { toBase64 } from "@peerbit/crypto";
|
|
5
4
|
import chalk from "chalk";
|
|
6
|
-
import { createClient, waitForDomain } from "./client.js";
|
|
7
|
-
import { exit } from "process";
|
|
8
|
-
import readline from "readline";
|
|
9
5
|
import fs from "fs";
|
|
10
6
|
import path from "path";
|
|
11
|
-
import {
|
|
7
|
+
import { exit } from "process";
|
|
8
|
+
import readline from "readline";
|
|
9
|
+
import Table from "tty-table";
|
|
10
|
+
import { AWS_LINUX_ARM_AMIs, createRecord, launchNodes, terminateNode, } from "./aws.js";
|
|
11
|
+
import { createClient, waitForDomain } from "./client.js";
|
|
12
|
+
import { getHomeConfigDir, getKeypair, getPackageName, getRemotesPath, } from "./config.js";
|
|
13
|
+
import { createTestDomain, getDomainFromConfig, loadConfig, startCertbot, } from "./domain.js";
|
|
12
14
|
import { DEFAULT_REMOTE_GROUP, Remotes } from "./remotes.js";
|
|
13
|
-
import { peerIdFromString } from "@libp2p/peer-id";
|
|
14
15
|
import { LOCAL_API_PORT } from "./routes.js";
|
|
15
|
-
import
|
|
16
|
+
import { startServerWithNode } from "./server.js";
|
|
16
17
|
const colors = [
|
|
17
18
|
"#00FF00",
|
|
18
19
|
"#0000FF",
|
|
@@ -76,7 +77,7 @@ const colors = [
|
|
|
76
77
|
"#A5FFD2",
|
|
77
78
|
"#FFB167",
|
|
78
79
|
"#009BFF",
|
|
79
|
-
"#E85EBE"
|
|
80
|
+
"#E85EBE",
|
|
80
81
|
];
|
|
81
82
|
const padString = function (string, padding, padChar = " ", stringLength = string.valueOf().length) {
|
|
82
83
|
const val = string.valueOf();
|
|
@@ -107,35 +108,35 @@ export const cli = async (args) => {
|
|
|
107
108
|
defaultDescription: "~.peerbit",
|
|
108
109
|
type: "string",
|
|
109
110
|
alias: "d",
|
|
110
|
-
default: getHomeConfigDir()
|
|
111
|
+
default: getHomeConfigDir(),
|
|
111
112
|
})
|
|
112
113
|
.option("bootstrap", {
|
|
113
114
|
describe: "Whether to connect to bootstap nodes on startup",
|
|
114
115
|
type: "boolean",
|
|
115
|
-
default: false
|
|
116
|
+
default: false,
|
|
116
117
|
})
|
|
117
118
|
.option("grant-access", {
|
|
118
119
|
describe: "Grant access to public keys on start",
|
|
119
120
|
defaultDescription: "The publickey of this device located in 'directory'",
|
|
120
121
|
type: "string",
|
|
121
122
|
array: true,
|
|
122
|
-
alias: "ga"
|
|
123
|
+
alias: "ga",
|
|
123
124
|
})
|
|
124
125
|
.option("reset", {
|
|
125
126
|
describe: "If true, then programs opened during last session will not be opened",
|
|
126
127
|
type: "boolean",
|
|
127
128
|
default: false,
|
|
128
|
-
alias: "r"
|
|
129
|
+
alias: "r",
|
|
129
130
|
})
|
|
130
131
|
.option("port-api", {
|
|
131
132
|
describe: "Set API server port. Only modify this when testing locally, since NGINX config depends on the default value",
|
|
132
133
|
type: "number",
|
|
133
|
-
default: undefined
|
|
134
|
+
default: undefined,
|
|
134
135
|
})
|
|
135
136
|
.option("port-node", {
|
|
136
137
|
describe: "Set Libp2p listen port. Only modify this when testing locally, since NGINX config depends on the default value",
|
|
137
138
|
type: "number",
|
|
138
|
-
default: undefined
|
|
139
|
+
default: undefined,
|
|
139
140
|
});
|
|
140
141
|
return yargs;
|
|
141
142
|
},
|
|
@@ -146,9 +147,9 @@ export const cli = async (args) => {
|
|
|
146
147
|
ports: { api: args["port-api"], node: args["port-node"] },
|
|
147
148
|
bootstrap: args.bootstrap,
|
|
148
149
|
newSession: args.reset,
|
|
149
|
-
grantAccess: args["grant-access"]
|
|
150
|
+
grantAccess: args["grant-access"],
|
|
150
151
|
});
|
|
151
|
-
}
|
|
152
|
+
},
|
|
152
153
|
})
|
|
153
154
|
.command({
|
|
154
155
|
command: "id",
|
|
@@ -159,14 +160,14 @@ export const cli = async (args) => {
|
|
|
159
160
|
defaultDescription: "~.peerbit",
|
|
160
161
|
type: "string",
|
|
161
162
|
alias: "d",
|
|
162
|
-
default: getHomeConfigDir()
|
|
163
|
+
default: getHomeConfigDir(),
|
|
163
164
|
});
|
|
164
165
|
return yargs;
|
|
165
166
|
},
|
|
166
167
|
handler: async (args) => {
|
|
167
168
|
const kp = await getKeypair(args.directory);
|
|
168
169
|
console.log((await kp.toPeerId()).toString());
|
|
169
|
-
}
|
|
170
|
+
},
|
|
170
171
|
})
|
|
171
172
|
.command("domain", "Setup a domain and certificate for this node", (yargs) => {
|
|
172
173
|
yargs
|
|
@@ -177,25 +178,25 @@ export const cli = async (args) => {
|
|
|
177
178
|
email: {
|
|
178
179
|
describe: "Email for Lets encrypt autorenewal messages",
|
|
179
180
|
type: "string",
|
|
180
|
-
demandOption: true
|
|
181
|
+
demandOption: true,
|
|
181
182
|
},
|
|
182
183
|
outdir: {
|
|
183
184
|
describe: "Output path for Nginx config",
|
|
184
185
|
type: "string",
|
|
185
|
-
alias: "o"
|
|
186
|
+
alias: "o",
|
|
186
187
|
},
|
|
187
188
|
wait: {
|
|
188
189
|
alias: "w",
|
|
189
190
|
describe: "Wait for setup to succeed (or fail)",
|
|
190
191
|
type: "boolean",
|
|
191
|
-
default: false
|
|
192
|
-
}
|
|
192
|
+
default: false,
|
|
193
|
+
},
|
|
193
194
|
},
|
|
194
195
|
handler: async (args) => {
|
|
195
196
|
const domain = await createTestDomain();
|
|
196
197
|
await startCertbot(domain, args.email, args.outdir, args.wait);
|
|
197
198
|
exit();
|
|
198
|
-
}
|
|
199
|
+
},
|
|
199
200
|
})
|
|
200
201
|
.command({
|
|
201
202
|
command: "aws",
|
|
@@ -205,45 +206,45 @@ export const cli = async (args) => {
|
|
|
205
206
|
describe: "domain, e.g. abc.example.com, example.com",
|
|
206
207
|
alias: "d",
|
|
207
208
|
type: "string",
|
|
208
|
-
demandOption: true
|
|
209
|
+
demandOption: true,
|
|
209
210
|
},
|
|
210
211
|
hostedZoneId: {
|
|
211
212
|
describe: 'The id of the hosted zone "HostedZoneId"',
|
|
212
213
|
alias: "hz",
|
|
213
214
|
type: "string",
|
|
214
|
-
require: true
|
|
215
|
+
require: true,
|
|
215
216
|
},
|
|
216
217
|
accessKeyId: {
|
|
217
218
|
describe: "Access key id of the AWS user",
|
|
218
219
|
alias: "ak",
|
|
219
|
-
type: "string"
|
|
220
|
+
type: "string",
|
|
220
221
|
},
|
|
221
222
|
region: {
|
|
222
223
|
describe: "AWS region",
|
|
223
224
|
alias: "r",
|
|
224
|
-
type: "string"
|
|
225
|
+
type: "string",
|
|
225
226
|
},
|
|
226
227
|
secretAccessKey: {
|
|
227
228
|
describe: "Secret key id of the AWS user",
|
|
228
229
|
alias: "sk",
|
|
229
|
-
type: "string"
|
|
230
|
+
type: "string",
|
|
230
231
|
},
|
|
231
232
|
email: {
|
|
232
233
|
describe: "Email for Lets encrypt auto-renewal messages",
|
|
233
234
|
type: "string",
|
|
234
|
-
demandOption: true
|
|
235
|
+
demandOption: true,
|
|
235
236
|
},
|
|
236
237
|
outdir: {
|
|
237
238
|
describe: "Output path for Nginx config",
|
|
238
239
|
type: "string",
|
|
239
|
-
alias: "o"
|
|
240
|
+
alias: "o",
|
|
240
241
|
},
|
|
241
242
|
wait: {
|
|
242
243
|
alias: "w",
|
|
243
244
|
describe: "Wait for setup to succeed (or fail)",
|
|
244
245
|
type: "boolean",
|
|
245
|
-
default: false
|
|
246
|
-
}
|
|
246
|
+
default: false,
|
|
247
|
+
},
|
|
247
248
|
},
|
|
248
249
|
handler: async (args) => {
|
|
249
250
|
if (!!args.accessKeyId !== !!args.secretAccessKey ||
|
|
@@ -257,13 +258,13 @@ export const cli = async (args) => {
|
|
|
257
258
|
credentials: args.accessKeyId
|
|
258
259
|
? {
|
|
259
260
|
accessKeyId: args.accessKeyId,
|
|
260
|
-
secretAccessKey: args.secretAccessKey
|
|
261
|
+
secretAccessKey: args.secretAccessKey,
|
|
261
262
|
}
|
|
262
|
-
: undefined
|
|
263
|
+
: undefined,
|
|
263
264
|
});
|
|
264
265
|
await startCertbot(args.domain, args.email, args.outdir, args.wait);
|
|
265
266
|
exit();
|
|
266
|
-
}
|
|
267
|
+
},
|
|
267
268
|
})
|
|
268
269
|
.strict()
|
|
269
270
|
.demandCommand();
|
|
@@ -281,19 +282,19 @@ export const cli = async (args) => {
|
|
|
281
282
|
defaultDescription: "One node",
|
|
282
283
|
type: "number",
|
|
283
284
|
alias: "c",
|
|
284
|
-
default: 1
|
|
285
|
+
default: 1,
|
|
285
286
|
});
|
|
286
287
|
awsArgs.option("region", {
|
|
287
288
|
describe: "Region",
|
|
288
289
|
type: "string",
|
|
289
290
|
defaultDescription: "Region defined in ~.aws/config",
|
|
290
|
-
choices: Object.keys(AWS_LINUX_ARM_AMIs)
|
|
291
|
+
choices: Object.keys(AWS_LINUX_ARM_AMIs),
|
|
291
292
|
});
|
|
292
293
|
awsArgs.option("group", {
|
|
293
294
|
describe: "Remote group to launch nodes in",
|
|
294
295
|
type: "string",
|
|
295
296
|
alias: "g",
|
|
296
|
-
default: DEFAULT_REMOTE_GROUP
|
|
297
|
+
default: DEFAULT_REMOTE_GROUP,
|
|
297
298
|
});
|
|
298
299
|
awsArgs.option("size", {
|
|
299
300
|
describe: "Instance size",
|
|
@@ -305,29 +306,29 @@ export const cli = async (args) => {
|
|
|
305
306
|
"medium",
|
|
306
307
|
"large",
|
|
307
308
|
"xlarge",
|
|
308
|
-
"2xlarge"
|
|
309
|
+
"2xlarge",
|
|
309
310
|
],
|
|
310
|
-
default: "micro"
|
|
311
|
+
default: "micro",
|
|
311
312
|
});
|
|
312
313
|
awsArgs.option("name", {
|
|
313
314
|
describe: "Name prefix for spawned nodes",
|
|
314
315
|
type: "string",
|
|
315
316
|
alias: "n",
|
|
316
|
-
default: "peerbit-node"
|
|
317
|
+
default: "peerbit-node",
|
|
317
318
|
});
|
|
318
319
|
awsArgs.option("grant-access", {
|
|
319
320
|
describe: "Grant access to public keys on start",
|
|
320
321
|
defaultDescription: "The publickey of this device located in 'directory'",
|
|
321
322
|
type: "string",
|
|
322
323
|
array: true,
|
|
323
|
-
alias: "ga"
|
|
324
|
+
alias: "ga",
|
|
324
325
|
});
|
|
325
326
|
awsArgs.option("directory", {
|
|
326
327
|
describe: "Peerbit directory",
|
|
327
328
|
defaultDescription: "~.peerbit",
|
|
328
329
|
type: "string",
|
|
329
330
|
alias: "d",
|
|
330
|
-
default: getHomeConfigDir()
|
|
331
|
+
default: getHomeConfigDir(),
|
|
331
332
|
});
|
|
332
333
|
return awsArgs;
|
|
333
334
|
},
|
|
@@ -335,7 +336,7 @@ export const cli = async (args) => {
|
|
|
335
336
|
const accessGrant = args.access?.length > 0
|
|
336
337
|
? args.access.map((x) => peerIdFromString(x))
|
|
337
338
|
: [
|
|
338
|
-
await (await getKeypair(args.directory)).publicKey.toPeerId()
|
|
339
|
+
await (await getKeypair(args.directory)).publicKey.toPeerId(),
|
|
339
340
|
];
|
|
340
341
|
const nodes = await launchNodes({
|
|
341
342
|
email: "marcus@dao.xyz",
|
|
@@ -343,7 +344,7 @@ export const cli = async (args) => {
|
|
|
343
344
|
namePrefix: args.name,
|
|
344
345
|
region: args.region,
|
|
345
346
|
grantAccess: accessGrant,
|
|
346
|
-
size: args.size
|
|
347
|
+
size: args.size,
|
|
347
348
|
});
|
|
348
349
|
console.log(`Waiting for ${args.count} ${args.count > 1 ? "nodes" : "node"} to spawn. This might take a few minutes. You can watch the progress in your AWS console.`);
|
|
349
350
|
const twirlTimer = (function () {
|
|
@@ -365,8 +366,8 @@ export const cli = async (args) => {
|
|
|
365
366
|
origin: {
|
|
366
367
|
type: "aws",
|
|
367
368
|
instanceId: node.instanceId,
|
|
368
|
-
region: node.region
|
|
369
|
-
}
|
|
369
|
+
region: node.region,
|
|
370
|
+
},
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
373
|
catch (error) {
|
|
@@ -380,7 +381,7 @@ export const cli = async (args) => {
|
|
|
380
381
|
for (const node of nodes) {
|
|
381
382
|
console.log(chalk.green(node.name));
|
|
382
383
|
}
|
|
383
|
-
}
|
|
384
|
+
},
|
|
384
385
|
})
|
|
385
386
|
.strict()
|
|
386
387
|
.demandCommand();
|
|
@@ -392,21 +393,21 @@ export const cli = async (args) => {
|
|
|
392
393
|
killArgs.option("all", {
|
|
393
394
|
describe: "Kill all nodes",
|
|
394
395
|
type: "boolean",
|
|
395
|
-
default: false
|
|
396
|
+
default: false,
|
|
396
397
|
});
|
|
397
398
|
killArgs.positional("name", {
|
|
398
399
|
type: "string",
|
|
399
400
|
describe: "Remote name",
|
|
400
401
|
default: "localhost",
|
|
401
402
|
demandOption: false,
|
|
402
|
-
array: true
|
|
403
|
+
array: true,
|
|
403
404
|
});
|
|
404
405
|
killArgs.option("directory", {
|
|
405
406
|
describe: "Peerbit directory",
|
|
406
407
|
defaultDescription: "~.peerbit",
|
|
407
408
|
type: "string",
|
|
408
409
|
alias: "d",
|
|
409
|
-
default: getHomeConfigDir()
|
|
410
|
+
default: getHomeConfigDir(),
|
|
410
411
|
});
|
|
411
412
|
return killArgs;
|
|
412
413
|
},
|
|
@@ -418,12 +419,12 @@ export const cli = async (args) => {
|
|
|
418
419
|
if (remote.origin?.type === "aws") {
|
|
419
420
|
await terminateNode({
|
|
420
421
|
instanceId: remote.origin.instanceId,
|
|
421
|
-
region: remote.origin.region
|
|
422
|
+
region: remote.origin.region,
|
|
422
423
|
});
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
426
|
}
|
|
426
|
-
}
|
|
427
|
+
},
|
|
427
428
|
})
|
|
428
429
|
.command({
|
|
429
430
|
command: "list",
|
|
@@ -435,7 +436,7 @@ export const cli = async (args) => {
|
|
|
435
436
|
defaultDescription: "~.peerbit",
|
|
436
437
|
type: "string",
|
|
437
438
|
alias: "d",
|
|
438
|
-
default: getHomeConfigDir()
|
|
439
|
+
default: getHomeConfigDir(),
|
|
439
440
|
});
|
|
440
441
|
return yargs;
|
|
441
442
|
},
|
|
@@ -457,7 +458,7 @@ export const cli = async (args) => {
|
|
|
457
458
|
resolvedOrRejected[ix].status === "fulfilled"
|
|
458
459
|
? chalk.green("Y")
|
|
459
460
|
: chalk.red("N"),
|
|
460
|
-
remote.address
|
|
461
|
+
remote.address,
|
|
461
462
|
];
|
|
462
463
|
rows.push(row);
|
|
463
464
|
}
|
|
@@ -469,7 +470,7 @@ export const cli = async (args) => {
|
|
|
469
470
|
else {
|
|
470
471
|
console.log("No remotes found!");
|
|
471
472
|
}
|
|
472
|
-
}
|
|
473
|
+
},
|
|
473
474
|
})
|
|
474
475
|
.command({
|
|
475
476
|
command: "add <name> <address>",
|
|
@@ -479,25 +480,25 @@ export const cli = async (args) => {
|
|
|
479
480
|
.positional("name", {
|
|
480
481
|
type: "string",
|
|
481
482
|
describe: "Remote address",
|
|
482
|
-
demandOption: true
|
|
483
|
+
demandOption: true,
|
|
483
484
|
})
|
|
484
485
|
.positional("address", {
|
|
485
486
|
type: "string",
|
|
486
487
|
describe: "Remote name",
|
|
487
|
-
demandOption: true
|
|
488
|
+
demandOption: true,
|
|
488
489
|
})
|
|
489
490
|
.option("group", {
|
|
490
491
|
describe: "Group name",
|
|
491
492
|
type: "string",
|
|
492
493
|
alias: "g",
|
|
493
|
-
default: DEFAULT_REMOTE_GROUP
|
|
494
|
+
default: DEFAULT_REMOTE_GROUP,
|
|
494
495
|
})
|
|
495
496
|
.option("directory", {
|
|
496
497
|
describe: "Peerbit directory",
|
|
497
498
|
defaultDescription: "~.peerbit",
|
|
498
499
|
type: "string",
|
|
499
500
|
alias: "d",
|
|
500
|
-
default: getHomeConfigDir()
|
|
501
|
+
default: getHomeConfigDir(),
|
|
501
502
|
});
|
|
502
503
|
return yargs;
|
|
503
504
|
},
|
|
@@ -506,7 +507,7 @@ export const cli = async (args) => {
|
|
|
506
507
|
throw new Error("Remote can not be named 'localhost'");
|
|
507
508
|
}
|
|
508
509
|
const api = await createClient(await getKeypair(args.directory), {
|
|
509
|
-
address: args.address
|
|
510
|
+
address: args.address,
|
|
510
511
|
});
|
|
511
512
|
try {
|
|
512
513
|
await api.program.list();
|
|
@@ -521,9 +522,9 @@ export const cli = async (args) => {
|
|
|
521
522
|
remotes.add({
|
|
522
523
|
name: args.name,
|
|
523
524
|
address: args.address,
|
|
524
|
-
group: args.group
|
|
525
|
+
group: args.group,
|
|
525
526
|
});
|
|
526
|
-
}
|
|
527
|
+
},
|
|
527
528
|
})
|
|
528
529
|
.command({
|
|
529
530
|
command: "remove <name>",
|
|
@@ -533,14 +534,14 @@ export const cli = async (args) => {
|
|
|
533
534
|
.positional("name", {
|
|
534
535
|
type: "string",
|
|
535
536
|
describe: "Remote address",
|
|
536
|
-
demandOption: true
|
|
537
|
+
demandOption: true,
|
|
537
538
|
})
|
|
538
539
|
.option("directory", {
|
|
539
540
|
describe: "Peerbit directory",
|
|
540
541
|
defaultDescription: "~.peerbit",
|
|
541
542
|
type: "string",
|
|
542
543
|
alias: "d",
|
|
543
|
-
default: getHomeConfigDir()
|
|
544
|
+
default: getHomeConfigDir(),
|
|
544
545
|
});
|
|
545
546
|
return yargs;
|
|
546
547
|
},
|
|
@@ -553,7 +554,7 @@ export const cli = async (args) => {
|
|
|
553
554
|
else {
|
|
554
555
|
console.log(chalk.red("Did not find any remote with name: " + args.name));
|
|
555
556
|
}
|
|
556
|
-
}
|
|
557
|
+
},
|
|
557
558
|
})
|
|
558
559
|
.command({
|
|
559
560
|
command: "connect [name...]",
|
|
@@ -565,26 +566,26 @@ export const cli = async (args) => {
|
|
|
565
566
|
describe: "Remote name",
|
|
566
567
|
default: "localhost",
|
|
567
568
|
demandOption: false,
|
|
568
|
-
array: true
|
|
569
|
+
array: true,
|
|
569
570
|
})
|
|
570
571
|
.option("all", {
|
|
571
572
|
type: "boolean",
|
|
572
573
|
describe: "Connect to all nodes",
|
|
573
|
-
default: false
|
|
574
|
+
default: false,
|
|
574
575
|
})
|
|
575
576
|
.option("group", {
|
|
576
577
|
type: "string",
|
|
577
578
|
describe: "Remote group name",
|
|
578
579
|
alias: "g",
|
|
579
580
|
default: [],
|
|
580
|
-
array: true
|
|
581
|
+
array: true,
|
|
581
582
|
})
|
|
582
583
|
.option("directory", {
|
|
583
584
|
describe: "Peerbit directory",
|
|
584
585
|
defaultDescription: "~.peerbit",
|
|
585
586
|
type: "string",
|
|
586
587
|
alias: "d",
|
|
587
|
-
default: getHomeConfigDir()
|
|
588
|
+
default: getHomeConfigDir(),
|
|
588
589
|
});
|
|
589
590
|
return yargs;
|
|
590
591
|
},
|
|
@@ -601,12 +602,12 @@ export const cli = async (args) => {
|
|
|
601
602
|
const keypair = await config.getKeypair(connectArgs.directory);
|
|
602
603
|
const selectedRemotes = [];
|
|
603
604
|
if (names.length > 0) {
|
|
604
|
-
for (const [
|
|
605
|
+
for (const [_ix, name] of names.entries()) {
|
|
605
606
|
if (name === "localhost") {
|
|
606
607
|
selectedRemotes.push({
|
|
607
608
|
address: "http://localhost:" + LOCAL_API_PORT,
|
|
608
609
|
name: "localhost",
|
|
609
|
-
group: DEFAULT_REMOTE_GROUP
|
|
610
|
+
group: DEFAULT_REMOTE_GROUP,
|
|
610
611
|
});
|
|
611
612
|
}
|
|
612
613
|
else {
|
|
@@ -641,7 +642,7 @@ export const cli = async (args) => {
|
|
|
641
642
|
apis.push({
|
|
642
643
|
log: logFn,
|
|
643
644
|
name: remote.name,
|
|
644
|
-
api: await createClient(keypair, remote)
|
|
645
|
+
api: await createClient(keypair, remote),
|
|
645
646
|
});
|
|
646
647
|
}
|
|
647
648
|
// try if authenticated
|
|
@@ -657,7 +658,7 @@ export const cli = async (args) => {
|
|
|
657
658
|
input: process.stdin,
|
|
658
659
|
output: process.stdout,
|
|
659
660
|
terminal: true,
|
|
660
|
-
historySize: 100
|
|
661
|
+
historySize: 100,
|
|
661
662
|
});
|
|
662
663
|
console.log("Write 'help' to show commands.\n");
|
|
663
664
|
rl.prompt(false);
|
|
@@ -672,7 +673,7 @@ export const cli = async (args) => {
|
|
|
672
673
|
for (const api of apis) {
|
|
673
674
|
api.log((await api.api.peer.id.get()).toString());
|
|
674
675
|
}
|
|
675
|
-
}
|
|
676
|
+
},
|
|
676
677
|
})
|
|
677
678
|
.command({
|
|
678
679
|
command: "address",
|
|
@@ -681,7 +682,7 @@ export const cli = async (args) => {
|
|
|
681
682
|
for (const api of apis) {
|
|
682
683
|
(await api.api.peer.addresses.get()).forEach((x) => api.log(x.toString()));
|
|
683
684
|
}
|
|
684
|
-
}
|
|
685
|
+
},
|
|
685
686
|
})
|
|
686
687
|
.strict()
|
|
687
688
|
.demandCommand();
|
|
@@ -696,7 +697,7 @@ export const cli = async (args) => {
|
|
|
696
697
|
yargs.positional("peer-id", {
|
|
697
698
|
describe: "Peer id",
|
|
698
699
|
type: "string",
|
|
699
|
-
demandOption: true
|
|
700
|
+
demandOption: true,
|
|
700
701
|
});
|
|
701
702
|
return yargs;
|
|
702
703
|
},
|
|
@@ -705,7 +706,7 @@ export const cli = async (args) => {
|
|
|
705
706
|
for (const api of apis) {
|
|
706
707
|
await api.api.access.allow(peerId);
|
|
707
708
|
}
|
|
708
|
-
}
|
|
709
|
+
},
|
|
709
710
|
})
|
|
710
711
|
.command({
|
|
711
712
|
command: "deny <peer-id>",
|
|
@@ -713,7 +714,7 @@ export const cli = async (args) => {
|
|
|
713
714
|
builder: (yargs) => {
|
|
714
715
|
yargs.positional("peer-id", {
|
|
715
716
|
describe: "Peer id",
|
|
716
|
-
demandOption: true
|
|
717
|
+
demandOption: true,
|
|
717
718
|
});
|
|
718
719
|
return yargs;
|
|
719
720
|
},
|
|
@@ -722,7 +723,7 @@ export const cli = async (args) => {
|
|
|
722
723
|
for (const api of apis) {
|
|
723
724
|
await api.api.access.deny(peerId);
|
|
724
725
|
}
|
|
725
|
-
}
|
|
726
|
+
},
|
|
726
727
|
})
|
|
727
728
|
.strict()
|
|
728
729
|
.demandCommand();
|
|
@@ -736,7 +737,7 @@ export const cli = async (args) => {
|
|
|
736
737
|
for (const api of apis) {
|
|
737
738
|
await api.api.network.bootstrap();
|
|
738
739
|
}
|
|
739
|
-
}
|
|
740
|
+
},
|
|
740
741
|
})
|
|
741
742
|
.strict()
|
|
742
743
|
.demandCommand();
|
|
@@ -752,7 +753,7 @@ export const cli = async (args) => {
|
|
|
752
753
|
type: "boolean",
|
|
753
754
|
describe: "Replicate data on this topic",
|
|
754
755
|
aliases: "r",
|
|
755
|
-
default: false
|
|
756
|
+
default: false,
|
|
756
757
|
});
|
|
757
758
|
return yargs;
|
|
758
759
|
},
|
|
@@ -768,7 +769,7 @@ export const cli = async (args) => {
|
|
|
768
769
|
console.log("Not subscribed to any topics");
|
|
769
770
|
} */
|
|
770
771
|
console.error("Not implemented");
|
|
771
|
-
}
|
|
772
|
+
},
|
|
772
773
|
})
|
|
773
774
|
.strict()
|
|
774
775
|
.demandCommand();
|
|
@@ -783,7 +784,7 @@ export const cli = async (args) => {
|
|
|
783
784
|
yargs.positional("address", {
|
|
784
785
|
type: "string",
|
|
785
786
|
describe: "Program address",
|
|
786
|
-
demandOption: true
|
|
787
|
+
demandOption: true,
|
|
787
788
|
});
|
|
788
789
|
return yargs;
|
|
789
790
|
},
|
|
@@ -797,7 +798,7 @@ export const cli = async (args) => {
|
|
|
797
798
|
api.log(chalk.green("Open"));
|
|
798
799
|
}
|
|
799
800
|
}
|
|
800
|
-
}
|
|
801
|
+
},
|
|
801
802
|
})
|
|
802
803
|
.command({
|
|
803
804
|
command: "drop <address>",
|
|
@@ -806,7 +807,7 @@ export const cli = async (args) => {
|
|
|
806
807
|
yargs.positional("address", {
|
|
807
808
|
type: "string",
|
|
808
809
|
describe: "Program address",
|
|
809
|
-
demandOption: true
|
|
810
|
+
demandOption: true,
|
|
810
811
|
});
|
|
811
812
|
return yargs;
|
|
812
813
|
},
|
|
@@ -819,7 +820,7 @@ export const cli = async (args) => {
|
|
|
819
820
|
api.log(chalk.red(`Failed to drop ${args.address}: ${error.toString()}`));
|
|
820
821
|
}
|
|
821
822
|
}
|
|
822
|
-
}
|
|
823
|
+
},
|
|
823
824
|
})
|
|
824
825
|
.command({
|
|
825
826
|
command: "close <address>",
|
|
@@ -828,7 +829,7 @@ export const cli = async (args) => {
|
|
|
828
829
|
yargs.positional("address", {
|
|
829
830
|
type: "string",
|
|
830
831
|
describe: "Program address",
|
|
831
|
-
demandOption: true
|
|
832
|
+
demandOption: true,
|
|
832
833
|
});
|
|
833
834
|
return yargs;
|
|
834
835
|
},
|
|
@@ -836,7 +837,7 @@ export const cli = async (args) => {
|
|
|
836
837
|
for (const api of apis) {
|
|
837
838
|
await api.api.program.close(args.address);
|
|
838
839
|
}
|
|
839
|
-
}
|
|
840
|
+
},
|
|
840
841
|
})
|
|
841
842
|
.command({
|
|
842
843
|
command: "list",
|
|
@@ -850,7 +851,7 @@ export const cli = async (args) => {
|
|
|
850
851
|
api.log(chalk.green(p));
|
|
851
852
|
});
|
|
852
853
|
}
|
|
853
|
-
}
|
|
854
|
+
},
|
|
854
855
|
})
|
|
855
856
|
.command({
|
|
856
857
|
command: "variants",
|
|
@@ -864,7 +865,7 @@ export const cli = async (args) => {
|
|
|
864
865
|
api.log(chalk.green(p));
|
|
865
866
|
});
|
|
866
867
|
}
|
|
867
|
-
}
|
|
868
|
+
},
|
|
868
869
|
})
|
|
869
870
|
.command({
|
|
870
871
|
command: "open [program]",
|
|
@@ -873,17 +874,17 @@ export const cli = async (args) => {
|
|
|
873
874
|
yargs.positional("program", {
|
|
874
875
|
type: "string",
|
|
875
876
|
describe: "Identifier",
|
|
876
|
-
demandOption: true
|
|
877
|
+
demandOption: true,
|
|
877
878
|
});
|
|
878
879
|
yargs.option("base64", {
|
|
879
880
|
type: "string",
|
|
880
881
|
describe: "Base64 encoded serialized",
|
|
881
|
-
aliases: "b"
|
|
882
|
+
aliases: "b",
|
|
882
883
|
});
|
|
883
884
|
yargs.option("variant", {
|
|
884
885
|
type: "string",
|
|
885
886
|
describe: "Variant name",
|
|
886
|
-
aliases: "v"
|
|
887
|
+
aliases: "v",
|
|
887
888
|
});
|
|
888
889
|
return yargs;
|
|
889
890
|
},
|
|
@@ -894,12 +895,12 @@ export const cli = async (args) => {
|
|
|
894
895
|
let startArg;
|
|
895
896
|
if (args.base64) {
|
|
896
897
|
startArg = {
|
|
897
|
-
base64: args.base64
|
|
898
|
+
base64: args.base64,
|
|
898
899
|
};
|
|
899
900
|
}
|
|
900
901
|
else {
|
|
901
902
|
startArg = {
|
|
902
|
-
variant: args.variant
|
|
903
|
+
variant: args.variant,
|
|
903
904
|
};
|
|
904
905
|
}
|
|
905
906
|
for (const api of apis) {
|
|
@@ -907,7 +908,7 @@ export const cli = async (args) => {
|
|
|
907
908
|
api.log("Started program with address: ");
|
|
908
909
|
api.log(chalk.green(address.toString()));
|
|
909
910
|
}
|
|
910
|
-
}
|
|
911
|
+
},
|
|
911
912
|
})
|
|
912
913
|
.strict()
|
|
913
914
|
.demandCommand();
|
|
@@ -920,7 +921,7 @@ export const cli = async (args) => {
|
|
|
920
921
|
yargs.positional("package-spec", {
|
|
921
922
|
type: "string",
|
|
922
923
|
describe: "Installed dependency will be loaded with js import(...)",
|
|
923
|
-
demandOption: true
|
|
924
|
+
demandOption: true,
|
|
924
925
|
});
|
|
925
926
|
return yargs;
|
|
926
927
|
},
|
|
@@ -937,7 +938,7 @@ export const cli = async (args) => {
|
|
|
937
938
|
installCommand = {
|
|
938
939
|
type: "tgz",
|
|
939
940
|
name: await getPackageName(packageName),
|
|
940
|
-
base64
|
|
941
|
+
base64,
|
|
941
942
|
};
|
|
942
943
|
}
|
|
943
944
|
else {
|
|
@@ -950,7 +951,7 @@ export const cli = async (args) => {
|
|
|
950
951
|
api.log(chalk.green(p));
|
|
951
952
|
});
|
|
952
953
|
}
|
|
953
|
-
}
|
|
954
|
+
},
|
|
954
955
|
})
|
|
955
956
|
.command({
|
|
956
957
|
command: "restart",
|
|
@@ -959,7 +960,7 @@ export const cli = async (args) => {
|
|
|
959
960
|
for (const api of apis) {
|
|
960
961
|
await api.api.restart();
|
|
961
962
|
}
|
|
962
|
-
}
|
|
963
|
+
},
|
|
963
964
|
})
|
|
964
965
|
.command({
|
|
965
966
|
command: "stop",
|
|
@@ -968,7 +969,7 @@ export const cli = async (args) => {
|
|
|
968
969
|
for (const api of apis) {
|
|
969
970
|
await api.api.stop();
|
|
970
971
|
}
|
|
971
|
-
}
|
|
972
|
+
},
|
|
972
973
|
})
|
|
973
974
|
.help()
|
|
974
975
|
.strict()
|
|
@@ -987,7 +988,7 @@ export const cli = async (args) => {
|
|
|
987
988
|
rl.prompt(true);
|
|
988
989
|
});
|
|
989
990
|
}
|
|
990
|
-
}
|
|
991
|
+
},
|
|
991
992
|
})
|
|
992
993
|
.help()
|
|
993
994
|
.strict()
|