@peerbit/server 4.0.2 → 4.0.4
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/lib/esm/aws.js +27 -27
- package/lib/esm/aws.js.map +1 -1
- package/lib/esm/cli.js +97 -97
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/client.js +24 -24
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/docker.js +1 -1
- package/lib/esm/peerbit.js +8 -8
- package/lib/esm/remotes.js +1 -1
- package/lib/esm/server.js +10 -12
- package/lib/esm/server.js.map +1 -1
- package/lib/esm/session.js +2 -2
- package/lib/esm/signes-request.js +1 -1
- package/lib/esm/signes-request.js.map +1 -1
- package/package.json +4 -4
- package/src/aws.ts +27 -27
- package/src/cli.ts +101 -103
- package/src/client.ts +24 -24
- package/src/docker.ts +1 -1
- package/src/peerbit.ts +8 -8
- package/src/remotes.ts +1 -1
- package/src/server.ts +11 -13
- package/src/session.ts +2 -2
- package/src/signes-request.ts +1 -1
package/src/aws.ts
CHANGED
|
@@ -26,9 +26,9 @@ export const createRecord = async (options: {
|
|
|
26
26
|
credentials: options.credentials
|
|
27
27
|
? {
|
|
28
28
|
accessKeyId: options.credentials.accessKeyId,
|
|
29
|
-
secretAccessKey: options.credentials.secretAccessKey
|
|
29
|
+
secretAccessKey: options.credentials.secretAccessKey
|
|
30
30
|
}
|
|
31
|
-
: undefined
|
|
31
|
+
: undefined
|
|
32
32
|
});
|
|
33
33
|
const cmd = new ChangeResourceRecordSetsCommand({
|
|
34
34
|
ChangeBatch: {
|
|
@@ -39,12 +39,12 @@ export const createRecord = async (options: {
|
|
|
39
39
|
Name: options.domain,
|
|
40
40
|
Type: v4 ? "A" : "AAAA",
|
|
41
41
|
TTL: 60,
|
|
42
|
-
ResourceRecords: [{ Value: myIp }]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
]
|
|
42
|
+
ResourceRecords: [{ Value: myIp }]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
46
|
},
|
|
47
|
-
HostedZoneId: options.hostedZoneId
|
|
47
|
+
HostedZoneId: options.hostedZoneId
|
|
48
48
|
});
|
|
49
49
|
await client.send(cmd);
|
|
50
50
|
};
|
|
@@ -95,7 +95,7 @@ export const AWS_LINUX_ARM_AMIs: Record<string, string> = {
|
|
|
95
95
|
/* "us-gov-east-1",
|
|
96
96
|
"us-gov-west-1", */
|
|
97
97
|
"us-west-1": "ami-0dca369228f3b2ce7",
|
|
98
|
-
"us-west-2": "ami-0c79a55dda52434da"
|
|
98
|
+
"us-west-2": "ami-0c79a55dda52434da"
|
|
99
99
|
};
|
|
100
100
|
export const launchNodes = async (properties: {
|
|
101
101
|
region?: string;
|
|
@@ -123,7 +123,7 @@ export const launchNodes = async (properties: {
|
|
|
123
123
|
DescribeSecurityGroupsCommand,
|
|
124
124
|
CreateSecurityGroupCommand,
|
|
125
125
|
AuthorizeSecurityGroupIngressCommand,
|
|
126
|
-
DescribeInstancesCommand
|
|
126
|
+
DescribeInstancesCommand
|
|
127
127
|
} = await import("@aws-sdk/client-ec2");
|
|
128
128
|
const client = new EC2Client({ region: properties.region });
|
|
129
129
|
const regionString = await client.config.region();
|
|
@@ -132,8 +132,8 @@ export const launchNodes = async (properties: {
|
|
|
132
132
|
await client.send(
|
|
133
133
|
new DescribeSecurityGroupsCommand({
|
|
134
134
|
Filters: [
|
|
135
|
-
{ Name: "tag:" + PURPOSE_TAG_NAME, Values: [PURPOSE_TAG_VALUE] }
|
|
136
|
-
]
|
|
135
|
+
{ Name: "tag:" + PURPOSE_TAG_NAME, Values: [PURPOSE_TAG_VALUE] }
|
|
136
|
+
]
|
|
137
137
|
})
|
|
138
138
|
)
|
|
139
139
|
)?.SecurityGroups?.[0];
|
|
@@ -141,13 +141,13 @@ export const launchNodes = async (properties: {
|
|
|
141
141
|
securityGroupOut = await client.send(
|
|
142
142
|
new CreateSecurityGroupCommand({
|
|
143
143
|
GroupName: "peerbit-node",
|
|
144
|
-
Description: "Security group for running Peerbit nodes"
|
|
144
|
+
Description: "Security group for running Peerbit nodes"
|
|
145
145
|
})
|
|
146
146
|
);
|
|
147
147
|
await client.send(
|
|
148
148
|
new CreateTagsCommand({
|
|
149
149
|
Resources: [securityGroupOut.GroupId!],
|
|
150
|
-
Tags: [{ Key: PURPOSE_TAG_NAME, Value: PURPOSE_TAG_VALUE }]
|
|
150
|
+
Tags: [{ Key: PURPOSE_TAG_NAME, Value: PURPOSE_TAG_VALUE }]
|
|
151
151
|
})
|
|
152
152
|
);
|
|
153
153
|
await client.send(
|
|
@@ -158,39 +158,39 @@ export const launchNodes = async (properties: {
|
|
|
158
158
|
IpRanges: [{ CidrIp: "0.0.0.0/0" }],
|
|
159
159
|
IpProtocol: "tcp",
|
|
160
160
|
FromPort: 80,
|
|
161
|
-
ToPort: 80
|
|
161
|
+
ToPort: 80
|
|
162
162
|
}, // Frontend
|
|
163
163
|
{
|
|
164
164
|
IpRanges: [{ CidrIp: "0.0.0.0/0" }],
|
|
165
165
|
IpProtocol: "tcp",
|
|
166
166
|
FromPort: 443,
|
|
167
|
-
ToPort: 443
|
|
167
|
+
ToPort: 443
|
|
168
168
|
}, // Frontend SSL
|
|
169
169
|
{
|
|
170
170
|
IpRanges: [{ CidrIp: "0.0.0.0/0" }],
|
|
171
171
|
IpProtocol: "tcp",
|
|
172
172
|
FromPort: 9002,
|
|
173
|
-
ToPort: 9002
|
|
173
|
+
ToPort: 9002
|
|
174
174
|
}, // HTTPS api
|
|
175
175
|
{
|
|
176
176
|
IpRanges: [{ CidrIp: "0.0.0.0/0" }],
|
|
177
177
|
IpProtocol: "tcp",
|
|
178
178
|
FromPort: 8082,
|
|
179
|
-
ToPort: 8082
|
|
179
|
+
ToPort: 8082
|
|
180
180
|
}, // HTTP api
|
|
181
181
|
{
|
|
182
182
|
IpRanges: [{ CidrIp: "0.0.0.0/0" }],
|
|
183
183
|
IpProtocol: "tcp",
|
|
184
184
|
FromPort: 4002,
|
|
185
|
-
ToPort: 4005
|
|
185
|
+
ToPort: 4005
|
|
186
186
|
}, // libp2p
|
|
187
187
|
{
|
|
188
188
|
IpRanges: [{ CidrIp: "0.0.0.0/0" }],
|
|
189
189
|
IpProtocol: "tcp",
|
|
190
190
|
FromPort: 22,
|
|
191
|
-
ToPort: 22
|
|
192
|
-
}
|
|
193
|
-
]
|
|
191
|
+
ToPort: 22
|
|
192
|
+
} // SSH
|
|
193
|
+
]
|
|
194
194
|
})
|
|
195
195
|
);
|
|
196
196
|
}
|
|
@@ -200,7 +200,7 @@ export const launchNodes = async (properties: {
|
|
|
200
200
|
(
|
|
201
201
|
await client.send(
|
|
202
202
|
new DescribeInstancesCommand({
|
|
203
|
-
Filters: [{ Name: "tag:Purpose", Values: [instanceTag] }]
|
|
203
|
+
Filters: [{ Name: "tag:Purpose", Values: [instanceTag] }]
|
|
204
204
|
})
|
|
205
205
|
)
|
|
206
206
|
).Reservations?.length || 0;
|
|
@@ -215,7 +215,7 @@ export const launchNodes = async (properties: {
|
|
|
215
215
|
setupUserData(properties.email, properties.grantAccess)
|
|
216
216
|
).toString("base64"),
|
|
217
217
|
MinCount: count,
|
|
218
|
-
MaxCount: count
|
|
218
|
+
MaxCount: count
|
|
219
219
|
// InstanceInitiatedShutdownBehavior: 'terminate' // to enable termination when node shutting itself down
|
|
220
220
|
})
|
|
221
221
|
);
|
|
@@ -237,8 +237,8 @@ export const launchNodes = async (properties: {
|
|
|
237
237
|
Resources: [instance.InstanceId!],
|
|
238
238
|
Tags: [
|
|
239
239
|
{ Key: "Name", Value: name },
|
|
240
|
-
{ Key: "Purpose", Value: instanceTag }
|
|
241
|
-
]
|
|
240
|
+
{ Key: "Purpose", Value: instanceTag }
|
|
241
|
+
]
|
|
242
242
|
})
|
|
243
243
|
);
|
|
244
244
|
}
|
|
@@ -248,7 +248,7 @@ export const launchNodes = async (properties: {
|
|
|
248
248
|
for (let i = 0; i < 10; i++) {
|
|
249
249
|
const info = await client.send(
|
|
250
250
|
new DescribeInstancesCommand({
|
|
251
|
-
InstanceIds: instanceOut.Instances.map((x) => x.InstanceId!)
|
|
251
|
+
InstanceIds: instanceOut.Instances.map((x) => x.InstanceId!)
|
|
252
252
|
})
|
|
253
253
|
);
|
|
254
254
|
const foundInstances = info
|
|
@@ -278,7 +278,7 @@ export const launchNodes = async (properties: {
|
|
|
278
278
|
instanceId: instanceOut.Instances![ix].InstanceId!,
|
|
279
279
|
publicIp: v,
|
|
280
280
|
name: names[ix],
|
|
281
|
-
region: regionString
|
|
281
|
+
region: regionString
|
|
282
282
|
};
|
|
283
283
|
}); // TODO types
|
|
284
284
|
};
|