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