@peerbit/server 1.0.19 → 1.1.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/lib/esm/cli.js +107 -42
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/client.d.ts +25 -2
- package/lib/esm/client.js +105 -16
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/config.browser.d.ts +0 -0
- package/lib/esm/config.browser.js +3 -0
- package/lib/esm/config.browser.js.map +1 -0
- package/lib/esm/config.d.ts +3 -0
- package/lib/esm/config.js +71 -0
- package/lib/esm/config.js.map +1 -1
- package/lib/esm/domain.d.ts +3 -1
- package/lib/esm/domain.js +46 -30
- package/lib/esm/domain.js.map +1 -1
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +3 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/nginx-template.conf +0 -10
- package/lib/esm/peerbit.d.ts +5 -0
- package/lib/esm/peerbit.js +26 -0
- package/lib/esm/peerbit.js.map +1 -0
- package/lib/esm/routes.d.ts +9 -0
- package/lib/esm/routes.js +18 -0
- package/lib/esm/routes.js.map +1 -0
- package/lib/esm/server.browser.d.ts +0 -0
- package/lib/esm/server.browser.js +3 -0
- package/lib/esm/server.browser.js.map +1 -0
- package/lib/esm/server.d.ts +15 -0
- package/lib/esm/server.js +356 -0
- package/lib/esm/server.js.map +1 -0
- package/lib/esm/types.d.ts +7 -0
- package/lib/esm/types.js +2 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/ui/assets/config.browser-4ed993c7.js +1 -0
- package/lib/ui/assets/index-a8188422.js +53 -0
- package/lib/ui/index.html +1 -1
- package/package.json +16 -8
- package/src/cli.ts +124 -48
- package/src/client.ts +157 -16
- package/src/config.browser.ts +1 -0
- package/src/config.ts +80 -0
- package/src/domain.ts +55 -35
- package/src/index.ts +3 -1
- package/src/nginx-template.conf +0 -10
- package/src/peerbit.ts +26 -0
- package/src/routes.ts +20 -0
- package/src/server.browser.ts +1 -0
- package/src/server.ts +430 -0
- package/src/types.ts +7 -0
- package/lib/esm/api.d.ts +0 -33
- package/lib/esm/api.js +0 -370
- package/lib/esm/api.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/ui/assets/index-40169014.js +0 -80
- package/src/api.ts +0 -437
package/lib/esm/domain.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { waitFor, waitForAsync } from "@peerbit/time";
|
|
2
|
-
import { client } from "./api.js";
|
|
3
2
|
import { installDocker, startContainer } from "./docker.js";
|
|
4
3
|
const isNode = typeof window === undefined || typeof window === "undefined";
|
|
5
4
|
const validateEmail = (email) => {
|
|
@@ -7,36 +6,63 @@ const validateEmail = (email) => {
|
|
|
7
6
|
.toLowerCase()
|
|
8
7
|
.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
|
|
9
8
|
};
|
|
10
|
-
const
|
|
11
|
-
if (!isNode) {
|
|
12
|
-
throw new Error("Config can only be created with node");
|
|
13
|
-
}
|
|
14
|
-
const { AxiosError } = await import("axios");
|
|
9
|
+
const getConfigFileTemplate = async () => {
|
|
15
10
|
const url = await import("url");
|
|
16
11
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
17
12
|
const fs = await import("fs");
|
|
18
13
|
const path = await import("path");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
const file = fs.readFileSync(path.join(__filename, "../nginx-template.conf"), "utf-8");
|
|
15
|
+
return file;
|
|
16
|
+
};
|
|
17
|
+
const getNginxFolderPath = async () => {
|
|
18
|
+
const { exec } = await import("child_process");
|
|
19
|
+
const pwd = await new Promise((resolve, reject) => {
|
|
20
|
+
exec("pwd", (error, stdout, stderr) => {
|
|
21
|
+
if (error || stderr) {
|
|
22
|
+
reject("Failed to get current directory");
|
|
23
|
+
}
|
|
24
|
+
resolve(stdout.trimEnd());
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
const path = await import("path");
|
|
28
|
+
const nginxConfigPath = path.join(pwd, "nginx");
|
|
29
|
+
return nginxConfigPath;
|
|
30
|
+
};
|
|
31
|
+
const getNginxConfigPath = async (folder) => {
|
|
32
|
+
const path = await import("path");
|
|
33
|
+
return path.join(folder, "default.conf");
|
|
34
|
+
};
|
|
35
|
+
const createConfig = async (outputPath, domain) => {
|
|
36
|
+
if (!isNode) {
|
|
37
|
+
throw new Error("Config can only be created with node");
|
|
29
38
|
}
|
|
30
|
-
file =
|
|
39
|
+
let file = await getConfigFileTemplate();
|
|
31
40
|
file = file.replaceAll("%DOMAIN%", domain);
|
|
41
|
+
const fs = await import("fs");
|
|
42
|
+
const path = await import("path");
|
|
32
43
|
fs.mkdir(outputPath, { recursive: true }, (err) => {
|
|
33
44
|
if (err)
|
|
34
45
|
throw err;
|
|
35
46
|
});
|
|
36
47
|
await waitFor(() => fs.existsSync(outputPath));
|
|
37
|
-
fs.writeFileSync(
|
|
48
|
+
fs.writeFileSync(await getNginxConfigPath(outputPath), file);
|
|
38
49
|
return { domain };
|
|
39
50
|
};
|
|
51
|
+
export const loadConfig = async () => {
|
|
52
|
+
const configFilePath = await getNginxConfigPath(await getNginxFolderPath());
|
|
53
|
+
const fs = await import("fs");
|
|
54
|
+
if (!fs.existsSync(configFilePath)) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const file = fs.readFileSync(configFilePath, "utf-8");
|
|
58
|
+
return file;
|
|
59
|
+
};
|
|
60
|
+
export const getDomainFromConfig = async (config) => {
|
|
61
|
+
const pattern = "/etc/letsencrypt/live/(.*)/fullchain.pem";
|
|
62
|
+
const match = config.match(pattern);
|
|
63
|
+
const domain = match?.[1];
|
|
64
|
+
return domain === "%DOMAIN%" ? undefined : domain;
|
|
65
|
+
};
|
|
40
66
|
const getUIPath = async () => {
|
|
41
67
|
const url = await import("url");
|
|
42
68
|
const path = await import("path");
|
|
@@ -78,21 +104,11 @@ export const createTestDomain = async () => {
|
|
|
78
104
|
* @param dockerProcessName
|
|
79
105
|
* @returns domain
|
|
80
106
|
*/
|
|
81
|
-
export const startCertbot = async (domain, email,
|
|
107
|
+
export const startCertbot = async (domain, email, waitForUp = false, dockerProcessName = "nginx-certbot") => {
|
|
82
108
|
if (!validateEmail(email)) {
|
|
83
109
|
throw new Error("Email for SSL renenewal is invalid");
|
|
84
110
|
}
|
|
85
|
-
const
|
|
86
|
-
const pwd = await new Promise((resolve, reject) => {
|
|
87
|
-
exec("pwd", (error, stdout, stderr) => {
|
|
88
|
-
if (error || stderr) {
|
|
89
|
-
reject("Failed to get current directory");
|
|
90
|
-
}
|
|
91
|
-
resolve(stdout.trimEnd());
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
const path = await import("path");
|
|
95
|
-
nginxConfigPath = path.join(nginxConfigPath || pwd, "nginx");
|
|
111
|
+
const nginxConfigPath = await getNginxFolderPath();
|
|
96
112
|
await createConfig(nginxConfigPath, domain);
|
|
97
113
|
await installDocker();
|
|
98
114
|
// run
|
package/lib/esm/domain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../../src/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../../src/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,GAAG,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AAO,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC;aACrC;YAAC,OAAO,KAAK,EAAE;gBACf,OAAO,KAAK,CAAC;aACb;QACF,CAAC,EACD,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAChD,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;KAC/B;SAAM;QACN,OAAO,CAAC,GAAG,CACV,2FAA2F,CAC3F,CAAC;KACF;AACF,CAAC,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -87,16 +87,6 @@ server {
|
|
|
87
87
|
|
|
88
88
|
server {
|
|
89
89
|
server_name %DOMAIN%; # managed by Certbot
|
|
90
|
-
#location / {
|
|
91
|
-
# proxy_pass http://127.0.0.1:8080;
|
|
92
|
-
# proxy_set_header Host $host;
|
|
93
|
-
# proxy_cache_bypass $http_upgrade;
|
|
94
|
-
#}
|
|
95
|
-
|
|
96
|
-
#location / {
|
|
97
|
-
# add_header Content-Type text/html;
|
|
98
|
-
# return 200 '<html><body>This peer has the address <b>/dns4/%DOMAIN%/tcp/4002/wss/p2p/%IPFS_ID%</b></body></html>';
|
|
99
|
-
#}
|
|
100
90
|
|
|
101
91
|
root /usr/share/nginx/html;
|
|
102
92
|
index index.html index.htm;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DirectSub } from "@peerbit/pubsub";
|
|
2
|
+
import { Peerbit } from "peerbit";
|
|
3
|
+
export const create = (properties) => {
|
|
4
|
+
return Peerbit.create({
|
|
5
|
+
libp2p: {
|
|
6
|
+
addresses: {
|
|
7
|
+
announce: properties.domain
|
|
8
|
+
? [
|
|
9
|
+
`/dns4/${properties.domain}/tcp/8001`,
|
|
10
|
+
`/dns4/${properties.domain}/tcp/8002/ws`,
|
|
11
|
+
]
|
|
12
|
+
: undefined,
|
|
13
|
+
listen: ["/ip4/127.0.0.1/tcp/8001", "/ip4/127.0.0.1/tcp/8002/ws"],
|
|
14
|
+
},
|
|
15
|
+
connectionManager: {
|
|
16
|
+
maxConnections: Infinity,
|
|
17
|
+
minConnections: 0,
|
|
18
|
+
},
|
|
19
|
+
services: {
|
|
20
|
+
pubsub: (c) => new DirectSub(c, { canRelayMessage: true }),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
directory: properties.directory,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=peerbit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peerbit.js","sourceRoot":"","sources":["../../src/peerbit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAmD,EAAE,EAAE;IAC7E,OAAO,OAAO,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE;YACP,SAAS,EAAE;gBACV,QAAQ,EAAE,UAAU,CAAC,MAAM;oBAC1B,CAAC,CAAC;wBACA,SAAS,UAAU,CAAC,MAAM,WAAW;wBACrC,SAAS,UAAU,CAAC,MAAM,cAAc;qBACvC;oBACH,CAAC,CAAC,SAAS;gBACZ,MAAM,EAAE,CAAC,yBAAyB,EAAE,4BAA4B,CAAC;aACjE;YACD,iBAAiB,EAAE;gBAClB,cAAc,EAAE,QAAQ;gBACxB,cAAc,EAAE,CAAC;aACjB;YACD,QAAQ,EAAE;gBACT,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;aAC1D;SACD;QACD,SAAS,EAAE,UAAU,CAAC,SAAS;KAC/B,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getPort: (protocol: string) => 9002 | 8082;
|
|
2
|
+
export declare const SSL_PORT = 9002;
|
|
3
|
+
export declare const LOCAL_PORT = 8082;
|
|
4
|
+
export declare const PEER_ID_PATH = "/peer/id";
|
|
5
|
+
export declare const ADDRESS_PATH = "/peer/address";
|
|
6
|
+
export declare const PROGRAM_PATH = "/program";
|
|
7
|
+
export declare const PROGRAMS_PATH = "/programs";
|
|
8
|
+
export declare const INSTALL_PATH = "/install";
|
|
9
|
+
export declare const BOOTSTRAP_PATH = "/network/bootstrap";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const getPort = (protocol) => {
|
|
2
|
+
if (protocol === "https:") {
|
|
3
|
+
return SSL_PORT;
|
|
4
|
+
}
|
|
5
|
+
if (protocol === "http:") {
|
|
6
|
+
return LOCAL_PORT;
|
|
7
|
+
}
|
|
8
|
+
throw new Error("Unsupported protocol: " + protocol);
|
|
9
|
+
};
|
|
10
|
+
export const SSL_PORT = 9002;
|
|
11
|
+
export const LOCAL_PORT = 8082;
|
|
12
|
+
export const PEER_ID_PATH = "/peer/id";
|
|
13
|
+
export const ADDRESS_PATH = "/peer/address";
|
|
14
|
+
export const PROGRAM_PATH = "/program";
|
|
15
|
+
export const PROGRAMS_PATH = "/programs";
|
|
16
|
+
export const INSTALL_PATH = "/install";
|
|
17
|
+
export const BOOTSTRAP_PATH = "/network/bootstrap";
|
|
18
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC3C,IAAI,QAAQ,KAAK,QAAQ,EAAE;QAC1B,OAAO,QAAQ,CAAC;KAChB;IAED,IAAI,QAAQ,KAAK,OAAO,EAAE;QACzB,OAAO,UAAU,CAAC;KAClB;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.browser.js","sourceRoot":"","sources":["../../src/server.browser.ts"],"names":[],"mappings":";AAAA,gBAAgB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import http from "http";
|
|
3
|
+
import { ProgramClient } from "@peerbit/program";
|
|
4
|
+
import { Peerbit } from "peerbit";
|
|
5
|
+
export declare const createPassword: () => Promise<string>;
|
|
6
|
+
export declare const loadOrCreatePassword: () => Promise<string>;
|
|
7
|
+
export declare const startServerWithNode: (properties: {
|
|
8
|
+
directory?: string;
|
|
9
|
+
domain?: string;
|
|
10
|
+
bootstrap?: boolean;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
13
|
+
node: Peerbit;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const startServer: (client: ProgramClient, port?: number) => Promise<http.Server>;
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import http from "http";
|
|
2
|
+
import { fromBase64 } from "@peerbit/crypto";
|
|
3
|
+
import { deserialize } from "@dao-xyz/borsh";
|
|
4
|
+
import { Program, getProgramFromVariant, getProgramFromVariants, } from "@peerbit/program";
|
|
5
|
+
import { waitFor } from "@peerbit/time";
|
|
6
|
+
import { v4 as uuid } from "uuid";
|
|
7
|
+
import { checkExistPath, getConfigDir, getCredentialsPath, getPackageName, loadPassword, NotFoundError, } from "./config.js";
|
|
8
|
+
import { setMaxListeners } from "events";
|
|
9
|
+
import { create } from "./peerbit.js";
|
|
10
|
+
import { Peerbit } from "peerbit";
|
|
11
|
+
import { getSchema } from "@dao-xyz/borsh";
|
|
12
|
+
import { ADDRESS_PATH, BOOTSTRAP_PATH, INSTALL_PATH, LOCAL_PORT, PEER_ID_PATH, PROGRAMS_PATH, PROGRAM_PATH, } from "./routes.js";
|
|
13
|
+
import { client } from "./client.js";
|
|
14
|
+
export const createPassword = async () => {
|
|
15
|
+
const fs = await import("fs");
|
|
16
|
+
const configDir = await getConfigDir();
|
|
17
|
+
const credentialsPath = await getCredentialsPath(configDir);
|
|
18
|
+
if (await checkExistPath(credentialsPath)) {
|
|
19
|
+
throw new Error("Config path for credentials: " + credentialsPath + ", already exist");
|
|
20
|
+
}
|
|
21
|
+
console.log(`Creating config folder ${configDir}`);
|
|
22
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
23
|
+
await waitFor(() => fs.existsSync(configDir));
|
|
24
|
+
console.log(`Created config folder ${configDir}`);
|
|
25
|
+
const password = uuid();
|
|
26
|
+
fs.writeFileSync(credentialsPath, JSON.stringify({ username: "admin", password }));
|
|
27
|
+
console.log(`Created credentials at ${credentialsPath}`);
|
|
28
|
+
return password;
|
|
29
|
+
};
|
|
30
|
+
export const loadOrCreatePassword = async () => {
|
|
31
|
+
try {
|
|
32
|
+
return await loadPassword();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof NotFoundError) {
|
|
36
|
+
return createPassword();
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const startServerWithNode = async (properties) => {
|
|
42
|
+
const peer = await create({
|
|
43
|
+
directory: properties.directory,
|
|
44
|
+
domain: properties.domain,
|
|
45
|
+
});
|
|
46
|
+
if (properties.bootstrap) {
|
|
47
|
+
await peer.bootstrap();
|
|
48
|
+
}
|
|
49
|
+
const server = await startServer(peer);
|
|
50
|
+
const printNodeInfo = async () => {
|
|
51
|
+
console.log("Starting node with address(es): ");
|
|
52
|
+
const id = await (await client()).peer.id.get();
|
|
53
|
+
console.log("id: " + id);
|
|
54
|
+
console.log("Addresses: ");
|
|
55
|
+
for (const a of await (await client()).peer.addresses.get()) {
|
|
56
|
+
console.log(a.toString());
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
await printNodeInfo();
|
|
60
|
+
const shutDownHook = async (controller, server) => {
|
|
61
|
+
const { exit } = await import("process");
|
|
62
|
+
process.on("SIGINT", async () => {
|
|
63
|
+
console.log("Shutting down node");
|
|
64
|
+
await server.close();
|
|
65
|
+
await controller.stop();
|
|
66
|
+
exit();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
await shutDownHook(peer, server);
|
|
70
|
+
return { server, node: peer };
|
|
71
|
+
};
|
|
72
|
+
const getProgramFromPath = (client, req, pathIndex) => {
|
|
73
|
+
if (!req.url) {
|
|
74
|
+
throw new Error("Missing url");
|
|
75
|
+
}
|
|
76
|
+
const url = new URL(req.url, "http://localhost:" + 1234);
|
|
77
|
+
const path = url.pathname
|
|
78
|
+
.substring(Math.min(1, url.pathname.length), url.pathname.length)
|
|
79
|
+
.split("/");
|
|
80
|
+
if (path.length <= pathIndex) {
|
|
81
|
+
throw new Error("Invalid path");
|
|
82
|
+
}
|
|
83
|
+
const address = decodeURIComponent(path[pathIndex]);
|
|
84
|
+
return client.handler.items.get(address);
|
|
85
|
+
};
|
|
86
|
+
export const startServer = async (client, port = LOCAL_PORT) => {
|
|
87
|
+
const password = await loadOrCreatePassword();
|
|
88
|
+
const adminACL = (req) => {
|
|
89
|
+
const auth = req.headers["authorization"];
|
|
90
|
+
if (!auth?.startsWith("Basic ")) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const credentials = auth?.substring("Basic ".length);
|
|
94
|
+
const username = credentials.split(":")[0];
|
|
95
|
+
if (username !== "admin") {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (password !== credentials.substring(username.length + 1)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
};
|
|
103
|
+
const getBody = (req, callback) => {
|
|
104
|
+
let body = "";
|
|
105
|
+
req.on("data", function (d) {
|
|
106
|
+
body += d;
|
|
107
|
+
});
|
|
108
|
+
req.on("end", function () {
|
|
109
|
+
callback(body);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const e404 = "404";
|
|
113
|
+
const endpoints = (client) => {
|
|
114
|
+
return async (req, res) => {
|
|
115
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
116
|
+
res.setHeader("Access-Control-Request-Method", "*");
|
|
117
|
+
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
118
|
+
res.setHeader("Access-Control-Allow-Methods", "*");
|
|
119
|
+
const r404 = () => {
|
|
120
|
+
res.writeHead(404);
|
|
121
|
+
res.end(e404);
|
|
122
|
+
};
|
|
123
|
+
try {
|
|
124
|
+
if (req.url) {
|
|
125
|
+
if (!req.url.startsWith(PEER_ID_PATH) &&
|
|
126
|
+
!req.url.startsWith(ADDRESS_PATH) &&
|
|
127
|
+
!(await adminACL(req))) {
|
|
128
|
+
res.writeHead(401);
|
|
129
|
+
res.end("Not authorized");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
else if (req.url.startsWith(PROGRAMS_PATH)) {
|
|
133
|
+
if (client instanceof Peerbit === false) {
|
|
134
|
+
res.writeHead(400);
|
|
135
|
+
res.end("Server node is not running a native client");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
switch (req.method) {
|
|
139
|
+
case "GET":
|
|
140
|
+
try {
|
|
141
|
+
const keys = JSON.stringify([
|
|
142
|
+
...client.handler.items.keys(),
|
|
143
|
+
]);
|
|
144
|
+
res.setHeader("Content-Type", "application/json");
|
|
145
|
+
res.writeHead(200);
|
|
146
|
+
res.end(keys);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
res.writeHead(404);
|
|
150
|
+
res.end(error.message);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
r404();
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if (req.url.startsWith(PROGRAM_PATH)) {
|
|
159
|
+
if (client instanceof Peerbit === false) {
|
|
160
|
+
res.writeHead(400);
|
|
161
|
+
res.end("Server node is not running a native client");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
switch (req.method) {
|
|
165
|
+
case "HEAD":
|
|
166
|
+
try {
|
|
167
|
+
const program = getProgramFromPath(client, req, 1);
|
|
168
|
+
if (program) {
|
|
169
|
+
res.writeHead(200);
|
|
170
|
+
res.end();
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
res.writeHead(404);
|
|
174
|
+
res.end();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
res.writeHead(404);
|
|
179
|
+
res.end(error.message);
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case "DELETE":
|
|
183
|
+
try {
|
|
184
|
+
const url = new URL(req.url, "http://localhost:" + 1234);
|
|
185
|
+
const queryData = url.searchParams.get("delete");
|
|
186
|
+
const program = getProgramFromPath(client, req, 1);
|
|
187
|
+
if (program) {
|
|
188
|
+
if (queryData === "true") {
|
|
189
|
+
await program.drop();
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
await program.close();
|
|
193
|
+
}
|
|
194
|
+
res.writeHead(200);
|
|
195
|
+
res.end();
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
res.writeHead(404);
|
|
199
|
+
res.end();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
res.writeHead(404);
|
|
204
|
+
res.end(error.message);
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case "PUT":
|
|
208
|
+
getBody(req, (body) => {
|
|
209
|
+
try {
|
|
210
|
+
const startArguments = JSON.parse(body);
|
|
211
|
+
let program;
|
|
212
|
+
if (startArguments.variant) {
|
|
213
|
+
const P = getProgramFromVariant(startArguments.variant);
|
|
214
|
+
if (!P) {
|
|
215
|
+
res.writeHead(400);
|
|
216
|
+
res.end("Missing program with variant: " +
|
|
217
|
+
startArguments.variant);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
program = new P();
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
program = deserialize(fromBase64(startArguments.base64), Program);
|
|
224
|
+
}
|
|
225
|
+
client
|
|
226
|
+
.open(program) // TODO all users to pass args
|
|
227
|
+
.then((program) => {
|
|
228
|
+
res.writeHead(200);
|
|
229
|
+
res.end(program.address.toString());
|
|
230
|
+
})
|
|
231
|
+
.catch((error) => {
|
|
232
|
+
res.writeHead(400);
|
|
233
|
+
res.end("Failed to open program: " + error.toString());
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
res.writeHead(400);
|
|
238
|
+
res.end(error.toString());
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
r404();
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (req.url.startsWith(INSTALL_PATH)) {
|
|
248
|
+
switch (req.method) {
|
|
249
|
+
case "PUT":
|
|
250
|
+
getBody(req, async (body) => {
|
|
251
|
+
const name = body;
|
|
252
|
+
let packageName = name;
|
|
253
|
+
if (name.endsWith(".tgz")) {
|
|
254
|
+
packageName = await getPackageName(name);
|
|
255
|
+
}
|
|
256
|
+
if (!name || name.length === 0) {
|
|
257
|
+
res.writeHead(400);
|
|
258
|
+
res.end("Invalid package: " + name);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
const child_process = await import("child_process");
|
|
262
|
+
try {
|
|
263
|
+
child_process.execSync(`npm install ${name} --no-save --no-package-lock`); // TODO omit=dev ? but this makes breaks the tests after running once?
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
res.writeHead(400);
|
|
267
|
+
res.end("Failed ot install library: " +
|
|
268
|
+
name +
|
|
269
|
+
". " +
|
|
270
|
+
error.toString());
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
const programsPre = new Set(getProgramFromVariants().map((x) => getSchema(x).variant));
|
|
275
|
+
await import(
|
|
276
|
+
/* webpackIgnore: true */ /* @vite-ignore */ packageName);
|
|
277
|
+
const programsPost = getProgramFromVariants()?.map((x) => getSchema(x));
|
|
278
|
+
const newPrograms = [];
|
|
279
|
+
for (const p of programsPost) {
|
|
280
|
+
if (!programsPre.has(p.variant)) {
|
|
281
|
+
newPrograms.push(p);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
res.writeHead(200);
|
|
285
|
+
res.end(JSON.stringify(newPrograms.map((x) => x.variant)));
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
res.writeHead(400);
|
|
289
|
+
res.end(e.message.toString?.());
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
break;
|
|
294
|
+
default:
|
|
295
|
+
r404();
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else if (req.url.startsWith(BOOTSTRAP_PATH)) {
|
|
300
|
+
switch (req.method) {
|
|
301
|
+
case "POST":
|
|
302
|
+
if (client instanceof Peerbit === false) {
|
|
303
|
+
res.writeHead(400);
|
|
304
|
+
res.end("Server node is not running a native client");
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
await client.bootstrap();
|
|
308
|
+
res.writeHead(200);
|
|
309
|
+
res.end();
|
|
310
|
+
break;
|
|
311
|
+
default:
|
|
312
|
+
r404();
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else if (req.url.startsWith(PEER_ID_PATH)) {
|
|
317
|
+
res.writeHead(200);
|
|
318
|
+
res.end(client.peerId.toString());
|
|
319
|
+
}
|
|
320
|
+
else if (req.url.startsWith(ADDRESS_PATH)) {
|
|
321
|
+
res.setHeader("Content-Type", "application/json");
|
|
322
|
+
res.writeHead(200);
|
|
323
|
+
const addresses = client.getMultiaddrs().map((x) => x.toString());
|
|
324
|
+
res.end(JSON.stringify(addresses));
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
r404();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
r404();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
res.writeHead(500);
|
|
336
|
+
console.error(error?.message);
|
|
337
|
+
res.end("Unexpected error");
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
setMaxListeners(Infinity); // TODO make this better (lower and large enough)
|
|
342
|
+
process.setMaxListeners(Infinity); // TODO make this better (lower and large enough)
|
|
343
|
+
const server = http.createServer(endpoints(client));
|
|
344
|
+
server.listen(port);
|
|
345
|
+
server.on("error", (e) => {
|
|
346
|
+
console.error("Server error: " + e?.message);
|
|
347
|
+
import("fs").then((fs) => {
|
|
348
|
+
fs.writeFile("error.log", JSON.stringify(e.message), function () {
|
|
349
|
+
/* void */ 0;
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
console.log("API available at port", port);
|
|
354
|
+
return server;
|
|
355
|
+
};
|
|
356
|
+
//# sourceMappingURL=server.js.map
|