@opendatalabs/personal-server-ts-server 0.0.1-canary.2eea97d → 0.0.1-canary.321fa2f
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/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +1 -0
- package/dist/app.js.map +1 -1
- package/dist/bootstrap.d.ts +5 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +68 -11
- package/dist/bootstrap.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/routes/health.d.ts +2 -0
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +2 -0
- package/dist/routes/health.js.map +1 -1
- package/dist/tunnel/auth.d.ts +44 -0
- package/dist/tunnel/auth.d.ts.map +1 -0
- package/dist/tunnel/auth.js +44 -0
- package/dist/tunnel/auth.js.map +1 -0
- package/dist/tunnel/binary.d.ts +57 -0
- package/dist/tunnel/binary.d.ts.map +1 -0
- package/dist/tunnel/binary.js +180 -0
- package/dist/tunnel/binary.js.map +1 -0
- package/dist/tunnel/config.d.ts +27 -0
- package/dist/tunnel/config.d.ts.map +1 -0
- package/dist/tunnel/config.js +38 -0
- package/dist/tunnel/config.js.map +1 -0
- package/dist/tunnel/index.d.ts +11 -0
- package/dist/tunnel/index.d.ts.map +1 -0
- package/dist/tunnel/index.js +8 -0
- package/dist/tunnel/index.js.map +1 -0
- package/dist/tunnel/manager.d.ts +59 -0
- package/dist/tunnel/manager.d.ts.map +1 -0
- package/dist/tunnel/manager.js +191 -0
- package/dist/tunnel/manager.js.map +1 -0
- package/package.json +2 -2
package/dist/app.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { HierarchyManagerOptions } from "@opendatalabs/personal-server-ts-c
|
|
|
4
4
|
import type { GatewayClient } from "@opendatalabs/personal-server-ts-core/gateway";
|
|
5
5
|
import type { AccessLogWriter } from "@opendatalabs/personal-server-ts-core/logging/access-log";
|
|
6
6
|
import type { AccessLogReader } from "@opendatalabs/personal-server-ts-core/logging/access-reader";
|
|
7
|
+
import { type HealthDeps } from "./routes/health.js";
|
|
7
8
|
import type { SyncManager } from "@opendatalabs/personal-server-ts-core/sync";
|
|
8
9
|
import type { Logger } from "pino";
|
|
9
10
|
export interface IdentityInfo {
|
|
@@ -26,6 +27,7 @@ export interface AppDeps {
|
|
|
26
27
|
devToken?: string;
|
|
27
28
|
configPath?: string;
|
|
28
29
|
syncManager?: SyncManager | null;
|
|
30
|
+
getTunnelStatus?: HealthDeps["getTunnelStatus"];
|
|
29
31
|
}
|
|
30
32
|
export declare function createApp(deps: AppDeps): Hono;
|
|
31
33
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,KAAK,EAAE,eAA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,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE;QACjB,OAAO,CAAC,CAAC,IAAI,CACX;YACE,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG;gBACT,SAAS,EAAE,WAAW;gBACtB,OAAO,EAAE,WAAW;aACrB;SACF,EACD,GAAG,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { ServerAccount } from "@opendatalabs/personal-server-ts-core/keys";
|
|
|
7
7
|
import type { ServerSigner } from "@opendatalabs/personal-server-ts-core/signing";
|
|
8
8
|
import { type SyncManager } from "@opendatalabs/personal-server-ts-core/sync";
|
|
9
9
|
import type { Hono } from "hono";
|
|
10
|
+
import { TunnelManager } from "./tunnel/index.js";
|
|
10
11
|
export interface ServerContext {
|
|
11
12
|
app: Hono;
|
|
12
13
|
logger: Logger;
|
|
@@ -18,10 +19,14 @@ export interface ServerContext {
|
|
|
18
19
|
serverAccount?: ServerAccount;
|
|
19
20
|
serverSigner?: ServerSigner;
|
|
20
21
|
syncManager: SyncManager | null;
|
|
22
|
+
tunnelManager?: TunnelManager;
|
|
23
|
+
tunnelUrl?: string;
|
|
21
24
|
devToken?: string;
|
|
22
25
|
cleanup: () => Promise<void>;
|
|
23
26
|
}
|
|
24
27
|
export interface CreateServerOptions {
|
|
28
|
+
rootPath?: string;
|
|
29
|
+
/** @deprecated Use rootPath instead. */
|
|
25
30
|
serverDir?: string;
|
|
26
31
|
dataDir?: string;
|
|
27
32
|
}
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,Y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sB,YAAY,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,CAAC,CAsPxB"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
1
3
|
import { join } from "node:path";
|
|
2
|
-
import {
|
|
4
|
+
import { DEFAULT_ROOT_PATH, resolveRootPath, } from "@opendatalabs/personal-server-ts-core/config";
|
|
3
5
|
import { createLogger, } from "@opendatalabs/personal-server-ts-core/logger";
|
|
4
6
|
import { initializeDatabase, createIndexManager, } from "@opendatalabs/personal-server-ts-core/storage/index";
|
|
5
7
|
import { createGatewayClient } from "@opendatalabs/personal-server-ts-core/gateway";
|
|
@@ -11,18 +13,21 @@ import { createSyncCursor, createSyncManager, } from "@opendatalabs/personal-ser
|
|
|
11
13
|
import { createVanaStorageAdapter } from "@opendatalabs/personal-server-ts-core/storage/adapters";
|
|
12
14
|
import { createApp } from "./app.js";
|
|
13
15
|
import { generateDevToken } from "./dev-token.js";
|
|
16
|
+
import { TunnelManager, ensureFrpcBinary } from "./tunnel/index.js";
|
|
14
17
|
export async function createServer(config, options) {
|
|
15
18
|
const logger = createLogger(config.logging);
|
|
16
19
|
const startedAt = new Date();
|
|
17
|
-
const
|
|
18
|
-
const dataDir = options?.dataDir ??
|
|
19
|
-
const indexPath = join(
|
|
20
|
-
const configPath = join(
|
|
20
|
+
const storageRoot = resolveRootPath(options?.rootPath ?? options?.serverDir ?? DEFAULT_ROOT_PATH);
|
|
21
|
+
const dataDir = options?.dataDir ?? join(storageRoot, "data");
|
|
22
|
+
const indexPath = join(storageRoot, "index.db");
|
|
23
|
+
const configPath = join(storageRoot, "config.json");
|
|
24
|
+
await mkdir(storageRoot, { recursive: true });
|
|
25
|
+
await mkdir(dataDir, { recursive: true });
|
|
21
26
|
const db = initializeDatabase(indexPath);
|
|
22
27
|
const indexManager = createIndexManager(db);
|
|
23
28
|
const hierarchyOptions = { dataDir };
|
|
24
29
|
const gatewayClient = createGatewayClient(config.gateway.url);
|
|
25
|
-
const
|
|
30
|
+
const _serverOrigin = config.server.origin;
|
|
26
31
|
// Derive server owner from VANA_MASTER_KEY_SIGNATURE env var
|
|
27
32
|
const masterKeySignature = process.env.VANA_MASTER_KEY_SIGNATURE;
|
|
28
33
|
let serverOwner;
|
|
@@ -34,7 +39,7 @@ export async function createServer(config, options) {
|
|
|
34
39
|
deriveMasterKey(masterKeySignature); // validate signature format
|
|
35
40
|
logger.info({ owner: serverOwner }, "Server owner derived from master key");
|
|
36
41
|
// Load or create server keypair from disk
|
|
37
|
-
const keyPath = join(
|
|
42
|
+
const keyPath = join(storageRoot, "key.json");
|
|
38
43
|
serverAccount = loadOrCreateServerAccount(keyPath);
|
|
39
44
|
logger.info({ owner: serverOwner, serverAddress: serverAccount.address }, "Server signing account loaded");
|
|
40
45
|
serverSigner = createServerSigner(serverAccount, {
|
|
@@ -68,6 +73,50 @@ export async function createServer(config, options) {
|
|
|
68
73
|
else {
|
|
69
74
|
logger.warn("VANA_MASTER_KEY_SIGNATURE not set — owner-restricted endpoints will return 500");
|
|
70
75
|
}
|
|
76
|
+
// --- Tunnel setup ---
|
|
77
|
+
// Tunnel starts FIRST to get public URL for Gateway registration
|
|
78
|
+
let tunnelManager;
|
|
79
|
+
let tunnelUrl;
|
|
80
|
+
let effectiveOrigin = config.server.origin; // Start with config.server.origin
|
|
81
|
+
if (config.tunnel.enabled && serverOwner && serverAccount) {
|
|
82
|
+
// Ensure frpc binary is available (downloads on first run or version bump)
|
|
83
|
+
let frpcBinaryPath;
|
|
84
|
+
try {
|
|
85
|
+
frpcBinaryPath = await ensureFrpcBinary(storageRoot, {
|
|
86
|
+
log: (msg) => logger.info(msg),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
logger.warn({ err }, "Failed to download frpc binary - tunnel disabled");
|
|
91
|
+
frpcBinaryPath = "";
|
|
92
|
+
}
|
|
93
|
+
if (frpcBinaryPath) {
|
|
94
|
+
tunnelManager = new TunnelManager(storageRoot);
|
|
95
|
+
// Generate unique run ID for this process/session (used for claim binding)
|
|
96
|
+
const runId = randomUUID();
|
|
97
|
+
try {
|
|
98
|
+
tunnelUrl = await tunnelManager.start({
|
|
99
|
+
walletAddress: serverAccount.address, // Use server's own keypair address
|
|
100
|
+
ownerAddress: serverOwner,
|
|
101
|
+
serverKeypair: serverAccount,
|
|
102
|
+
runId,
|
|
103
|
+
serverAddr: config.tunnel.serverAddr,
|
|
104
|
+
serverPort: config.tunnel.serverPort,
|
|
105
|
+
localPort: config.server.port,
|
|
106
|
+
}, frpcBinaryPath);
|
|
107
|
+
logger.info({ tunnelUrl }, "Tunnel established");
|
|
108
|
+
// Use tunnel URL as effective origin for requests and Gateway registration
|
|
109
|
+
effectiveOrigin = tunnelUrl;
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
logger.warn({ err }, "Tunnel failed to connect - server running in local-only mode");
|
|
113
|
+
tunnelManager = undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (config.tunnel.enabled) {
|
|
118
|
+
logger.warn("Tunnel enabled in config but VANA_MASTER_KEY_SIGNATURE not set — tunnel disabled");
|
|
119
|
+
}
|
|
71
120
|
// --- Sync engine setup ---
|
|
72
121
|
let syncManager = null;
|
|
73
122
|
if (config.sync.enabled &&
|
|
@@ -85,8 +134,7 @@ export async function createServer(config, options) {
|
|
|
85
134
|
ownerAddress: serverOwner,
|
|
86
135
|
signer: requestSigner,
|
|
87
136
|
});
|
|
88
|
-
const
|
|
89
|
-
const cursor = createSyncCursor(configPath_);
|
|
137
|
+
const cursor = createSyncCursor(configPath);
|
|
90
138
|
const uploadDeps = {
|
|
91
139
|
indexManager,
|
|
92
140
|
hierarchyOptions,
|
|
@@ -114,7 +162,8 @@ export async function createServer(config, options) {
|
|
|
114
162
|
else if (config.sync.enabled) {
|
|
115
163
|
logger.warn("Sync enabled in config but VANA_MASTER_KEY_SIGNATURE not set — sync disabled");
|
|
116
164
|
}
|
|
117
|
-
const logsDir = join(
|
|
165
|
+
const logsDir = join(storageRoot, "logs");
|
|
166
|
+
await mkdir(logsDir, { recursive: true });
|
|
118
167
|
const accessLogWriter = createAccessLogWriter(logsDir);
|
|
119
168
|
const accessLogReader = createAccessLogReader(logsDir);
|
|
120
169
|
// Generate ephemeral dev token when devUi is enabled
|
|
@@ -125,7 +174,7 @@ export async function createServer(config, options) {
|
|
|
125
174
|
startedAt,
|
|
126
175
|
indexManager,
|
|
127
176
|
hierarchyOptions,
|
|
128
|
-
serverOrigin,
|
|
177
|
+
serverOrigin: effectiveOrigin,
|
|
129
178
|
serverOwner,
|
|
130
179
|
identity,
|
|
131
180
|
gateway: gatewayClient,
|
|
@@ -134,8 +183,14 @@ export async function createServer(config, options) {
|
|
|
134
183
|
devToken,
|
|
135
184
|
configPath,
|
|
136
185
|
syncManager,
|
|
186
|
+
getTunnelStatus: tunnelManager
|
|
187
|
+
? () => tunnelManager.getStatus()
|
|
188
|
+
: undefined,
|
|
137
189
|
});
|
|
138
190
|
const cleanup = async () => {
|
|
191
|
+
if (tunnelManager) {
|
|
192
|
+
await tunnelManager.stop();
|
|
193
|
+
}
|
|
139
194
|
if (syncManager) {
|
|
140
195
|
await syncManager.stop();
|
|
141
196
|
}
|
|
@@ -152,6 +207,8 @@ export async function createServer(config, options) {
|
|
|
152
207
|
serverAccount,
|
|
153
208
|
serverSigner,
|
|
154
209
|
syncManager,
|
|
210
|
+
tunnelManager,
|
|
211
|
+
tunnelUrl,
|
|
155
212
|
devToken,
|
|
156
213
|
cleanup,
|
|
157
214
|
};
|
package/dist/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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Y;QACZ,WAAW;QACX,aAAa;QACb,SAAS;QACT,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import { loadConfig } from "@opendatalabs/personal-server-ts-core/config";
|
|
|
3
3
|
import { createServer } from "./bootstrap.js";
|
|
4
4
|
const DRAIN_TIMEOUT_MS = 5_000;
|
|
5
5
|
async function main() {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const rootPath = process.env.PERSONAL_SERVER_ROOT_PATH;
|
|
7
|
+
const config = await loadConfig({ rootPath });
|
|
8
|
+
const { app, logger, devToken } = await createServer(config, { rootPath });
|
|
8
9
|
const server = serve({ fetch: app.fetch, port: config.server.port }, (info) => {
|
|
9
10
|
logger.info({ port: info.port, version: "0.0.1" }, "Server started");
|
|
10
11
|
if (devToken) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,KAAK,UAAU,IAAI;IACjB,MAAM,QAAQ,GAAG,OAAO,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C;IAC/B,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Hono } from "hono";
|
|
|
2
2
|
import type { GatewayClient } from "@opendatalabs/personal-server-ts-core/gateway";
|
|
3
3
|
import type { Logger } from "pino";
|
|
4
4
|
import type { IdentityInfo } from "../app.js";
|
|
5
|
+
import type { TunnelStatusInfo } from "../tunnel/index.js";
|
|
5
6
|
export interface HealthDeps {
|
|
6
7
|
version: string;
|
|
7
8
|
startedAt: Date;
|
|
@@ -9,6 +10,7 @@ export interface HealthDeps {
|
|
|
9
10
|
identity?: IdentityInfo;
|
|
10
11
|
gateway?: GatewayClient;
|
|
11
12
|
logger?: Logger;
|
|
13
|
+
getTunnelStatus?: () => TunnelStatusInfo | null;
|
|
12
14
|
}
|
|
13
15
|
export declare function healthRoute(deps: HealthDeps): Hono;
|
|
14
16
|
//# sourceMappingURL=health.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAAC;CACjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CA0ClD"}
|
package/dist/routes/health.js
CHANGED
|
@@ -22,12 +22,14 @@ export function healthRoute(deps) {
|
|
|
22
22
|
serverId,
|
|
23
23
|
}
|
|
24
24
|
: null;
|
|
25
|
+
const tunnel = deps.getTunnelStatus?.() ?? null;
|
|
25
26
|
return c.json({
|
|
26
27
|
status: "healthy",
|
|
27
28
|
version: deps.version,
|
|
28
29
|
uptime: Math.floor(uptimeMs / 1000),
|
|
29
30
|
owner: deps.serverOwner ?? null,
|
|
30
31
|
identity,
|
|
32
|
+
tunnel,
|
|
31
33
|
});
|
|
32
34
|
});
|
|
33
35
|
return app;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"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AC;QAET,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,EAAE,IAAI,IAAI,CAAC;QAEhD,OAAO,CAAC,CAAC,IAAI,CAAC;YACZ,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;YACnC,KAAK,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;YAC/B,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tunnel authentication via EIP-191 signed claims.
|
|
3
|
+
*
|
|
4
|
+
* Generates signed claims for FRP server plugin-first Login/NewProxy validation.
|
|
5
|
+
* The claim is a base64url-encoded JSON payload signed with EIP-191.
|
|
6
|
+
*/
|
|
7
|
+
import type { ServerAccount } from "@opendatalabs/personal-server-ts-core/keys";
|
|
8
|
+
export interface SignedClaim {
|
|
9
|
+
claim: string;
|
|
10
|
+
sig: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ClaimPayload {
|
|
13
|
+
aud: string;
|
|
14
|
+
iat: number;
|
|
15
|
+
exp: number;
|
|
16
|
+
owner: string;
|
|
17
|
+
wallet: string;
|
|
18
|
+
subdomain: string;
|
|
19
|
+
runId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ClaimConfig {
|
|
22
|
+
ownerAddress: string;
|
|
23
|
+
walletAddress: string;
|
|
24
|
+
runId: string;
|
|
25
|
+
serverKeypair: ServerAccount;
|
|
26
|
+
}
|
|
27
|
+
/** Encode a UTF-8 string to base64url (no padding). */
|
|
28
|
+
export declare function base64urlEncode(input: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a signed claim for tunnel authentication.
|
|
31
|
+
*
|
|
32
|
+
* The claim payload contains:
|
|
33
|
+
* - aud: "https://tunnel.vana.org" (audience)
|
|
34
|
+
* - iat: issued-at timestamp (seconds)
|
|
35
|
+
* - exp: expiration timestamp (5 min TTL)
|
|
36
|
+
* - owner: owner wallet address
|
|
37
|
+
* - wallet: server wallet address
|
|
38
|
+
* - subdomain: lowercased wallet address
|
|
39
|
+
* - runId: unique per-process session ID
|
|
40
|
+
*
|
|
41
|
+
* The signature is EIP-191 over the base64url-encoded claim string.
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateSignedClaim(config: ClaimConfig): Promise<SignedClaim>;
|
|
44
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/tunnel/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC,CAiBtB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tunnel authentication via EIP-191 signed claims.
|
|
3
|
+
*
|
|
4
|
+
* Generates signed claims for FRP server plugin-first Login/NewProxy validation.
|
|
5
|
+
* The claim is a base64url-encoded JSON payload signed with EIP-191.
|
|
6
|
+
*/
|
|
7
|
+
/** Encode a UTF-8 string to base64url (no padding). */
|
|
8
|
+
export function base64urlEncode(input) {
|
|
9
|
+
return Buffer.from(input, "utf-8")
|
|
10
|
+
.toString("base64")
|
|
11
|
+
.replace(/\+/g, "-")
|
|
12
|
+
.replace(/\//g, "_")
|
|
13
|
+
.replace(/=+$/, "");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generate a signed claim for tunnel authentication.
|
|
17
|
+
*
|
|
18
|
+
* The claim payload contains:
|
|
19
|
+
* - aud: "https://tunnel.vana.org" (audience)
|
|
20
|
+
* - iat: issued-at timestamp (seconds)
|
|
21
|
+
* - exp: expiration timestamp (5 min TTL)
|
|
22
|
+
* - owner: owner wallet address
|
|
23
|
+
* - wallet: server wallet address
|
|
24
|
+
* - subdomain: lowercased wallet address
|
|
25
|
+
* - runId: unique per-process session ID
|
|
26
|
+
*
|
|
27
|
+
* The signature is EIP-191 over the base64url-encoded claim string.
|
|
28
|
+
*/
|
|
29
|
+
export async function generateSignedClaim(config) {
|
|
30
|
+
const now = Math.floor(Date.now() / 1000);
|
|
31
|
+
const payload = {
|
|
32
|
+
aud: "https://tunnel.vana.org",
|
|
33
|
+
iat: now,
|
|
34
|
+
exp: now + 300, // 5 min TTL
|
|
35
|
+
owner: config.ownerAddress,
|
|
36
|
+
wallet: config.walletAddress,
|
|
37
|
+
subdomain: config.walletAddress.toLowerCase(),
|
|
38
|
+
runId: config.runId,
|
|
39
|
+
};
|
|
40
|
+
const claim = base64urlEncode(JSON.stringify(payload));
|
|
41
|
+
const sig = await config.serverKeypair.signMessage(claim);
|
|
42
|
+
return { claim, sig };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tunnel/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH,uDAAuD;AACvD,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;SAC/B,QAAQ,CAAC,QAAQ,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAmB;IAEnB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAiB;QAC5B,GAAG,EAAE,yBAAyB;QAC9B,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,YAAY;QAC5B,KAAK,EAAE,MAAM,CAAC,YAAY;QAC1B,MAAM,EAAE,MAAM,CAAC,aAAa;QAC5B,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE;QAC7C,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;IAEF,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE1D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-demand frpc binary download and version management.
|
|
3
|
+
*
|
|
4
|
+
* Downloads the correct frpc binary for the current platform from GitHub
|
|
5
|
+
* releases, stores it in the user's data directory, and re-downloads only
|
|
6
|
+
* when the pinned version changes.
|
|
7
|
+
*/
|
|
8
|
+
/** Pinned frpc version — bump this to trigger re-download on next startup. */
|
|
9
|
+
export declare const FRPC_VERSION = "0.67.0";
|
|
10
|
+
export interface PlatformInfo {
|
|
11
|
+
/** e.g. "darwin_arm64" */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Archive extension: "tar.gz" or "zip" */
|
|
14
|
+
ext: "tar.gz" | "zip";
|
|
15
|
+
/** Binary file name inside the archive */
|
|
16
|
+
binaryName: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Map current process.platform / process.arch to frp release naming.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPlatformInfo(): PlatformInfo;
|
|
22
|
+
/**
|
|
23
|
+
* Return the expected path to the frpc binary under storageRoot.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getBinaryPath(storageRoot: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Read the installed version from the metadata file.
|
|
28
|
+
* Returns null if the file is missing or corrupt.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getInstalledVersion(storageRoot: string): Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Write version metadata after successful installation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function writeVersionFile(storageRoot: string, version: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Build the GitHub release download URL for a given version and platform.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getDownloadUrl(version: string, platformInfo: PlatformInfo): string;
|
|
39
|
+
/**
|
|
40
|
+
* Download a file from `url` to `destPath` using fetch + stream pipeline.
|
|
41
|
+
*/
|
|
42
|
+
export declare function downloadArchive(url: string, destPath: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Extract the frpc binary from a downloaded archive into destDir.
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractBinary(archivePath: string, destDir: string, version: string, platformInfo: PlatformInfo): Promise<string>;
|
|
47
|
+
export interface EnsureFrpcOptions {
|
|
48
|
+
log?: (msg: string) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Main entry point: ensure the correct frpc binary is available.
|
|
52
|
+
*
|
|
53
|
+
* 1. Check version file — if version matches and binary exists, return path (fast path).
|
|
54
|
+
* 2. Otherwise download, extract, chmod, write version file, return path.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ensureFrpcBinary(storageRoot: string, options?: EnsureFrpcOptions): Promise<string>;
|
|
57
|
+
//# sourceMappingURL=binary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../src/tunnel/binary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,8EAA8E;AAC9E,eAAO,MAAM,YAAY,WAAW,CAAC;AAIrC,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,GAAG,EAAE,QAAQ,GAAG,KAAK,CAAC;IACtB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,CA+B9C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGzD;AAMD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY,GACzB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CA8CjB"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-demand frpc binary download and version management.
|
|
3
|
+
*
|
|
4
|
+
* Downloads the correct frpc binary for the current platform from GitHub
|
|
5
|
+
* releases, stores it in the user's data directory, and re-downloads only
|
|
6
|
+
* when the pinned version changes.
|
|
7
|
+
*/
|
|
8
|
+
import { createWriteStream } from "node:fs";
|
|
9
|
+
import { access, chmod, mkdir, readFile, rename, rm, writeFile, constants, } from "node:fs/promises";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { pipeline } from "node:stream/promises";
|
|
12
|
+
import { Readable } from "node:stream";
|
|
13
|
+
import { exec } from "node:child_process";
|
|
14
|
+
import { promisify } from "node:util";
|
|
15
|
+
const execAsync = promisify(exec);
|
|
16
|
+
/** Pinned frpc version — bump this to trigger re-download on next startup. */
|
|
17
|
+
export const FRPC_VERSION = "0.67.0";
|
|
18
|
+
const GITHUB_RELEASE_BASE = "https://github.com/fatedier/frp/releases/download";
|
|
19
|
+
/**
|
|
20
|
+
* Map current process.platform / process.arch to frp release naming.
|
|
21
|
+
*/
|
|
22
|
+
export function getPlatformInfo() {
|
|
23
|
+
const platform = process.platform;
|
|
24
|
+
const arch = process.arch;
|
|
25
|
+
if (platform === "darwin") {
|
|
26
|
+
const archName = arch === "arm64" ? "arm64" : "amd64";
|
|
27
|
+
return {
|
|
28
|
+
name: `darwin_${archName}`,
|
|
29
|
+
ext: "tar.gz",
|
|
30
|
+
binaryName: "frpc",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (platform === "linux") {
|
|
34
|
+
const archName = arch === "arm64" ? "arm64" : "amd64";
|
|
35
|
+
return {
|
|
36
|
+
name: `linux_${archName}`,
|
|
37
|
+
ext: "tar.gz",
|
|
38
|
+
binaryName: "frpc",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (platform === "win32") {
|
|
42
|
+
return {
|
|
43
|
+
name: "windows_amd64",
|
|
44
|
+
ext: "zip",
|
|
45
|
+
binaryName: "frpc.exe",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Unsupported platform: ${platform} ${arch}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Return the expected path to the frpc binary under storageRoot.
|
|
52
|
+
*/
|
|
53
|
+
export function getBinaryPath(storageRoot) {
|
|
54
|
+
const isWindows = process.platform === "win32";
|
|
55
|
+
return join(storageRoot, "bin", isWindows ? "frpc.exe" : "frpc");
|
|
56
|
+
}
|
|
57
|
+
function versionFilePath(storageRoot) {
|
|
58
|
+
return join(storageRoot, "bin", "frpc-version.json");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Read the installed version from the metadata file.
|
|
62
|
+
* Returns null if the file is missing or corrupt.
|
|
63
|
+
*/
|
|
64
|
+
export async function getInstalledVersion(storageRoot) {
|
|
65
|
+
try {
|
|
66
|
+
const raw = await readFile(versionFilePath(storageRoot), "utf-8");
|
|
67
|
+
const meta = JSON.parse(raw);
|
|
68
|
+
return meta.version ?? null;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Write version metadata after successful installation.
|
|
76
|
+
*/
|
|
77
|
+
export async function writeVersionFile(storageRoot, version) {
|
|
78
|
+
const meta = {
|
|
79
|
+
version,
|
|
80
|
+
platform: `${process.platform}_${process.arch}`,
|
|
81
|
+
installedAt: new Date().toISOString(),
|
|
82
|
+
};
|
|
83
|
+
await writeFile(versionFilePath(storageRoot), JSON.stringify(meta, null, 2));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build the GitHub release download URL for a given version and platform.
|
|
87
|
+
*/
|
|
88
|
+
export function getDownloadUrl(version, platformInfo) {
|
|
89
|
+
const archiveName = `frp_${version}_${platformInfo.name}.${platformInfo.ext}`;
|
|
90
|
+
return `${GITHUB_RELEASE_BASE}/v${version}/${archiveName}`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Download a file from `url` to `destPath` using fetch + stream pipeline.
|
|
94
|
+
*/
|
|
95
|
+
export async function downloadArchive(url, destPath) {
|
|
96
|
+
const response = await fetch(url);
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
throw new Error(`Failed to download frpc: HTTP ${response.status} from ${url}`);
|
|
99
|
+
}
|
|
100
|
+
if (!response.body) {
|
|
101
|
+
throw new Error("No response body received");
|
|
102
|
+
}
|
|
103
|
+
const fileStream = createWriteStream(destPath);
|
|
104
|
+
await pipeline(Readable.fromWeb(response.body), fileStream);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Extract the frpc binary from a downloaded archive into destDir.
|
|
108
|
+
*/
|
|
109
|
+
export async function extractBinary(archivePath, destDir, version, platformInfo) {
|
|
110
|
+
const extractDir = join(destDir, "_extract");
|
|
111
|
+
await mkdir(extractDir, { recursive: true });
|
|
112
|
+
try {
|
|
113
|
+
if (platformInfo.ext === "tar.gz") {
|
|
114
|
+
await execAsync(`tar -xzf "${archivePath}" -C "${extractDir}"`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Windows: use PowerShell
|
|
118
|
+
await execAsync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force"`);
|
|
119
|
+
}
|
|
120
|
+
// The archive extracts to frp_<version>_<platform>/frpc
|
|
121
|
+
const innerDir = join(extractDir, `frp_${version}_${platformInfo.name}`);
|
|
122
|
+
const srcBinary = join(innerDir, platformInfo.binaryName);
|
|
123
|
+
// Verify extracted binary exists
|
|
124
|
+
await access(srcBinary, constants.F_OK);
|
|
125
|
+
// Move binary to final destination
|
|
126
|
+
const finalPath = join(destDir, platformInfo.binaryName);
|
|
127
|
+
await rename(srcBinary, finalPath);
|
|
128
|
+
return finalPath;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
await rm(extractDir, { recursive: true, force: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Main entry point: ensure the correct frpc binary is available.
|
|
136
|
+
*
|
|
137
|
+
* 1. Check version file — if version matches and binary exists, return path (fast path).
|
|
138
|
+
* 2. Otherwise download, extract, chmod, write version file, return path.
|
|
139
|
+
*/
|
|
140
|
+
export async function ensureFrpcBinary(storageRoot, options) {
|
|
141
|
+
const log = options?.log ?? (() => { });
|
|
142
|
+
const binDir = join(storageRoot, "bin");
|
|
143
|
+
const binaryPath = getBinaryPath(storageRoot);
|
|
144
|
+
// Fast path: version matches and binary exists
|
|
145
|
+
const installedVersion = await getInstalledVersion(storageRoot);
|
|
146
|
+
if (installedVersion === FRPC_VERSION) {
|
|
147
|
+
try {
|
|
148
|
+
await access(binaryPath, constants.F_OK);
|
|
149
|
+
log(`frpc v${FRPC_VERSION} already installed`);
|
|
150
|
+
return binaryPath;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Binary missing despite version file — re-download
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Need to download
|
|
157
|
+
log(`Downloading frpc v${FRPC_VERSION}...`);
|
|
158
|
+
await mkdir(binDir, { recursive: true });
|
|
159
|
+
const platformInfo = getPlatformInfo();
|
|
160
|
+
const url = getDownloadUrl(FRPC_VERSION, platformInfo);
|
|
161
|
+
// Download to a temp file in the bin directory
|
|
162
|
+
const tempArchive = join(binDir, `_frpc_download.${platformInfo.ext}`);
|
|
163
|
+
try {
|
|
164
|
+
await downloadArchive(url, tempArchive);
|
|
165
|
+
log("Download complete, extracting...");
|
|
166
|
+
await extractBinary(tempArchive, binDir, FRPC_VERSION, platformInfo);
|
|
167
|
+
// Make executable on unix
|
|
168
|
+
if (process.platform !== "win32") {
|
|
169
|
+
await chmod(binaryPath, 0o755);
|
|
170
|
+
}
|
|
171
|
+
await writeVersionFile(storageRoot, FRPC_VERSION);
|
|
172
|
+
log(`frpc v${FRPC_VERSION} installed successfully`);
|
|
173
|
+
return binaryPath;
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
// Clean up temp archive
|
|
177
|
+
await rm(tempArchive, { force: true });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../src/tunnel/binary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,EAAE,EACF,SAAS,EACT,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CA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IAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,kBAAkB,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;IAEvE,IAAI,CAAC;QACH,MAAM,eAAe,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACxC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAExC,MAAM,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QAErE,0BAA0B;QAC1B,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,MAAM,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;QAED,MAAM,gBAAgB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAClD,GAAG,CAAC,SAAS,YAAY,yBAAyB,CAAC,CAAC;QAEpD,OAAO,UAAU,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,wBAAwB;QACxB,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FRP client configuration generation.
|
|
3
|
+
*
|
|
4
|
+
* Generates frpc.toml configuration for connecting to the FRP server.
|
|
5
|
+
*/
|
|
6
|
+
export interface FrpcConfigOptions {
|
|
7
|
+
serverAddr: string;
|
|
8
|
+
serverPort: number;
|
|
9
|
+
localPort: number;
|
|
10
|
+
subdomain: string;
|
|
11
|
+
walletAddress: string;
|
|
12
|
+
ownerAddress: string;
|
|
13
|
+
runId: string;
|
|
14
|
+
authClaim: string;
|
|
15
|
+
authSig: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate frpc.toml configuration content.
|
|
19
|
+
*
|
|
20
|
+
* Uses TOML format with:
|
|
21
|
+
* - serverAddr/serverPort for FRP control plane connection
|
|
22
|
+
* - loginFailExit = false for resilience (keeps trying on auth failure)
|
|
23
|
+
* - HTTP proxy with subdomain routing
|
|
24
|
+
* - Root-level metadatas for Auth Plugin validation (required by frps server)
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateFrpcConfig(options: FrpcConfigOptions): string;
|
|
27
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/tunnel/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAsBrE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FRP client configuration generation.
|
|
3
|
+
*
|
|
4
|
+
* Generates frpc.toml configuration for connecting to the FRP server.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Generate frpc.toml configuration content.
|
|
8
|
+
*
|
|
9
|
+
* Uses TOML format with:
|
|
10
|
+
* - serverAddr/serverPort for FRP control plane connection
|
|
11
|
+
* - loginFailExit = false for resilience (keeps trying on auth failure)
|
|
12
|
+
* - HTTP proxy with subdomain routing
|
|
13
|
+
* - Root-level metadatas for Auth Plugin validation (required by frps server)
|
|
14
|
+
*/
|
|
15
|
+
export function generateFrpcConfig(options) {
|
|
16
|
+
return `# Auto-generated frpc configuration
|
|
17
|
+
# Do not edit - regenerated on each server start
|
|
18
|
+
|
|
19
|
+
serverAddr = "${options.serverAddr}"
|
|
20
|
+
serverPort = ${options.serverPort}
|
|
21
|
+
loginFailExit = false
|
|
22
|
+
|
|
23
|
+
# Metadata for Auth Plugin validation (at root level for Login operation)
|
|
24
|
+
metadatas.wallet = "${options.walletAddress}"
|
|
25
|
+
metadatas.owner = "${options.ownerAddress}"
|
|
26
|
+
metadatas.run_id = "${options.runId}"
|
|
27
|
+
metadatas.auth_claim = "${options.authClaim}"
|
|
28
|
+
metadatas.auth_sig = "${options.authSig}"
|
|
29
|
+
|
|
30
|
+
[[proxies]]
|
|
31
|
+
name = "personal-server"
|
|
32
|
+
type = "http"
|
|
33
|
+
localIP = "127.0.0.1"
|
|
34
|
+
localPort = ${options.localPort}
|
|
35
|
+
subdomain = "${options.subdomain}"
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/tunnel/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IAC3D,OAAO;;;gBAGO,OAAO,CAAC,UAAU;eACnB,OAAO,CAAC,UAAU;;;;sBAIX,OAAO,CAAC,aAAa;qBACtB,OAAO,CAAC,YAAY;sBACnB,OAAO,CAAC,KAAK;0BACT,OAAO,CAAC,SAAS;wBACnB,OAAO,CAAC,OAAO;;;;;;cAMzB,OAAO,CAAC,SAAS;eAChB,OAAO,CAAC,SAAS;CAC/B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FRP tunnel module for establishing reverse proxy connections.
|
|
3
|
+
*/
|
|
4
|
+
export { generateSignedClaim, base64urlEncode } from "./auth.js";
|
|
5
|
+
export type { SignedClaim, ClaimPayload, ClaimConfig } from "./auth.js";
|
|
6
|
+
export { generateFrpcConfig } from "./config.js";
|
|
7
|
+
export type { FrpcConfigOptions } from "./config.js";
|
|
8
|
+
export { TunnelManager } from "./manager.js";
|
|
9
|
+
export type { TunnelConfig, TunnelStatus, TunnelStatusInfo, } from "./manager.js";
|
|
10
|
+
export { ensureFrpcBinary, getBinaryPath } from "./binary.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tunnel/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FRP tunnel module for establishing reverse proxy connections.
|
|
3
|
+
*/
|
|
4
|
+
export { generateSignedClaim, base64urlEncode } from "./auth.js";
|
|
5
|
+
export { generateFrpcConfig } from "./config.js";
|
|
6
|
+
export { TunnelManager } from "./manager.js";
|
|
7
|
+
export { ensureFrpcBinary, getBinaryPath } from "./binary.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tunnel/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAO7C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TunnelManager handles the frpc process lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Generate signed claim and frpc.toml config
|
|
6
|
+
* - Spawn frpc process with a caller-provided binary path
|
|
7
|
+
* - Monitor process lifecycle
|
|
8
|
+
* - Provide status for health endpoint
|
|
9
|
+
*/
|
|
10
|
+
import type { ServerAccount } from "@opendatalabs/personal-server-ts-core/keys";
|
|
11
|
+
export type TunnelStatus = "stopped" | "starting" | "connected" | "disconnected" | "error";
|
|
12
|
+
export interface TunnelStatusInfo {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
status: TunnelStatus;
|
|
15
|
+
publicUrl: string | null;
|
|
16
|
+
connectedSince: string | null;
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TunnelConfig {
|
|
20
|
+
walletAddress: string;
|
|
21
|
+
ownerAddress: string;
|
|
22
|
+
serverKeypair: ServerAccount;
|
|
23
|
+
runId: string;
|
|
24
|
+
serverAddr: string;
|
|
25
|
+
serverPort: number;
|
|
26
|
+
localPort: number;
|
|
27
|
+
}
|
|
28
|
+
export declare class TunnelManager {
|
|
29
|
+
private storageRoot;
|
|
30
|
+
private process;
|
|
31
|
+
private status;
|
|
32
|
+
private publicUrl;
|
|
33
|
+
private connectedSince;
|
|
34
|
+
private lastError;
|
|
35
|
+
private config;
|
|
36
|
+
constructor(storageRoot: string);
|
|
37
|
+
/**
|
|
38
|
+
* Start the frpc process with the given configuration.
|
|
39
|
+
* Returns the public URL once the tunnel is established.
|
|
40
|
+
*/
|
|
41
|
+
start(config: TunnelConfig, binaryPath: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Stop the frpc process gracefully.
|
|
44
|
+
*/
|
|
45
|
+
stop(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Check if the tunnel is currently running.
|
|
48
|
+
*/
|
|
49
|
+
isRunning(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current tunnel status.
|
|
52
|
+
*/
|
|
53
|
+
getStatus(): TunnelStatusInfo;
|
|
54
|
+
/**
|
|
55
|
+
* Get the public URL if connected.
|
|
56
|
+
*/
|
|
57
|
+
getPublicUrl(): string | null;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/tunnel/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAIhF,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,UAAU,GACV,WAAW,GACX,cAAc,GACd,OAAO,CAAC;AAEZ,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,MAAM,CAA6B;gBAE/B,WAAW,EAAE,MAAM;IAI/B;;;OAGG;IACG,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiItE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B3B;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,SAAS,IAAI,gBAAgB;IAU7B;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI;CAG9B"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TunnelManager handles the frpc process lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Generate signed claim and frpc.toml config
|
|
6
|
+
* - Spawn frpc process with a caller-provided binary path
|
|
7
|
+
* - Monitor process lifecycle
|
|
8
|
+
* - Provide status for health endpoint
|
|
9
|
+
*/
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import { writeFile, mkdir, chmod, access, constants } from "node:fs/promises";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { generateSignedClaim } from "./auth.js";
|
|
14
|
+
import { generateFrpcConfig } from "./config.js";
|
|
15
|
+
export class TunnelManager {
|
|
16
|
+
storageRoot;
|
|
17
|
+
process = null;
|
|
18
|
+
status = "stopped";
|
|
19
|
+
publicUrl = null;
|
|
20
|
+
connectedSince = null;
|
|
21
|
+
lastError = null;
|
|
22
|
+
config = null;
|
|
23
|
+
constructor(storageRoot) {
|
|
24
|
+
this.storageRoot = storageRoot;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Start the frpc process with the given configuration.
|
|
28
|
+
* Returns the public URL once the tunnel is established.
|
|
29
|
+
*/
|
|
30
|
+
async start(config, binaryPath) {
|
|
31
|
+
if (this.process) {
|
|
32
|
+
throw new Error("Tunnel already running");
|
|
33
|
+
}
|
|
34
|
+
this.config = config;
|
|
35
|
+
this.status = "starting";
|
|
36
|
+
this.lastError = null;
|
|
37
|
+
// Generate signed claim
|
|
38
|
+
const { claim, sig } = await generateSignedClaim({
|
|
39
|
+
ownerAddress: config.ownerAddress,
|
|
40
|
+
walletAddress: config.walletAddress,
|
|
41
|
+
runId: config.runId,
|
|
42
|
+
serverKeypair: config.serverKeypair,
|
|
43
|
+
});
|
|
44
|
+
// Generate frpc.toml config
|
|
45
|
+
const subdomain = config.walletAddress.toLowerCase();
|
|
46
|
+
const frpcConfig = generateFrpcConfig({
|
|
47
|
+
serverAddr: config.serverAddr,
|
|
48
|
+
serverPort: config.serverPort,
|
|
49
|
+
localPort: config.localPort,
|
|
50
|
+
subdomain,
|
|
51
|
+
walletAddress: config.walletAddress,
|
|
52
|
+
ownerAddress: config.ownerAddress,
|
|
53
|
+
runId: config.runId,
|
|
54
|
+
authClaim: claim,
|
|
55
|
+
authSig: sig,
|
|
56
|
+
});
|
|
57
|
+
// Write config to disk
|
|
58
|
+
const tunnelDir = join(this.storageRoot, "tunnel");
|
|
59
|
+
await mkdir(tunnelDir, { recursive: true });
|
|
60
|
+
const configPath = join(tunnelDir, "frpc.toml");
|
|
61
|
+
await writeFile(configPath, frpcConfig, "utf-8");
|
|
62
|
+
// Verify binary exists and is executable
|
|
63
|
+
try {
|
|
64
|
+
await access(binaryPath, constants.X_OK);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Try to make it executable
|
|
68
|
+
try {
|
|
69
|
+
await chmod(binaryPath, 0o755);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
throw new Error(`frpc binary not found or not executable: ${binaryPath}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Spawn frpc process
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
const proc = spawn(binaryPath, ["-c", configPath], {
|
|
78
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
79
|
+
});
|
|
80
|
+
this.process = proc;
|
|
81
|
+
let startupOutput = "";
|
|
82
|
+
let resolved = false;
|
|
83
|
+
const onData = (data) => {
|
|
84
|
+
const text = data.toString();
|
|
85
|
+
startupOutput += text;
|
|
86
|
+
// Check for successful connection
|
|
87
|
+
if (text.includes("start proxy success") ||
|
|
88
|
+
text.includes("login to server success")) {
|
|
89
|
+
if (!resolved) {
|
|
90
|
+
resolved = true;
|
|
91
|
+
this.status = "connected";
|
|
92
|
+
this.connectedSince = new Date();
|
|
93
|
+
this.publicUrl = `https://${subdomain}.server.vana.org`;
|
|
94
|
+
resolve(this.publicUrl);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Check for errors
|
|
98
|
+
if (text.includes("login to the server failed") ||
|
|
99
|
+
text.includes("error")) {
|
|
100
|
+
// Don't reject immediately due to loginFailExit=false
|
|
101
|
+
// Just log and continue trying
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
proc.stdout?.on("data", onData);
|
|
105
|
+
proc.stderr?.on("data", onData);
|
|
106
|
+
proc.on("error", (err) => {
|
|
107
|
+
this.status = "error";
|
|
108
|
+
this.lastError = err.message;
|
|
109
|
+
if (!resolved) {
|
|
110
|
+
resolved = true;
|
|
111
|
+
reject(new Error(`Failed to start frpc: ${err.message}`));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
proc.on("exit", (code) => {
|
|
115
|
+
this.process = null;
|
|
116
|
+
if (code !== 0 && !resolved) {
|
|
117
|
+
this.status = "error";
|
|
118
|
+
this.lastError = `frpc exited with code ${code}: ${startupOutput}`;
|
|
119
|
+
resolved = true;
|
|
120
|
+
reject(new Error(this.lastError));
|
|
121
|
+
}
|
|
122
|
+
else if (this.status === "connected") {
|
|
123
|
+
this.status = "disconnected";
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// Timeout for startup
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
if (!resolved) {
|
|
129
|
+
resolved = true;
|
|
130
|
+
// Even if we don't see the success message, the tunnel might still be working
|
|
131
|
+
// Set as connected optimistically
|
|
132
|
+
this.status = "connected";
|
|
133
|
+
this.connectedSince = new Date();
|
|
134
|
+
this.publicUrl = `https://${subdomain}.server.vana.org`;
|
|
135
|
+
resolve(this.publicUrl);
|
|
136
|
+
}
|
|
137
|
+
}, 10000); // 10 second timeout
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Stop the frpc process gracefully.
|
|
142
|
+
*/
|
|
143
|
+
async stop() {
|
|
144
|
+
if (!this.process) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
const proc = this.process;
|
|
149
|
+
const timeout = setTimeout(() => {
|
|
150
|
+
// Force kill if graceful shutdown takes too long
|
|
151
|
+
proc.kill("SIGKILL");
|
|
152
|
+
resolve();
|
|
153
|
+
}, 5000);
|
|
154
|
+
proc.on("exit", () => {
|
|
155
|
+
clearTimeout(timeout);
|
|
156
|
+
this.process = null;
|
|
157
|
+
this.status = "stopped";
|
|
158
|
+
this.publicUrl = null;
|
|
159
|
+
this.connectedSince = null;
|
|
160
|
+
resolve();
|
|
161
|
+
});
|
|
162
|
+
// Send SIGTERM for graceful shutdown
|
|
163
|
+
proc.kill("SIGTERM");
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Check if the tunnel is currently running.
|
|
168
|
+
*/
|
|
169
|
+
isRunning() {
|
|
170
|
+
return this.process !== null && this.status === "connected";
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get the current tunnel status.
|
|
174
|
+
*/
|
|
175
|
+
getStatus() {
|
|
176
|
+
return {
|
|
177
|
+
enabled: true,
|
|
178
|
+
status: this.status,
|
|
179
|
+
publicUrl: this.publicUrl,
|
|
180
|
+
connectedSince: this.connectedSince?.toISOString() ?? null,
|
|
181
|
+
error: this.lastError ?? undefined,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get the public URL if connected.
|
|
186
|
+
*/
|
|
187
|
+
getPublicUrl() {
|
|
188
|
+
return this.publicUrl;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/tunnel/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA2BjD,MAAM,OAAO,aAAa;IAChB,WAAW,CAAS;IACpB,OAAO,GAAwB,IAAI,CAAC;IACpC,MAAM,GAAiB,SAAS,CAAC;IACjC,SAAS,GAAkB,IAAI,CAAC;IAChC,cAAc,GAAgB,IAAI,CAAC;IACnC,SAAS,GAAkB,IAAI,CAAC;IAChC,MAAM,GAAwB,IAAI,CAAC;IAE3C,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,MAAoB,EAAE,UAAkB;QAClD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;QACzB,IAAI,CAAC,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AI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,IAAI,IAAI;YAC1D,KAAK,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS;SACnC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendatalabs/personal-server-ts-server",
|
|
3
|
-
"version": "0.0.1-canary.
|
|
3
|
+
"version": "0.0.1-canary.321fa2f",
|
|
4
4
|
"description": "Hono HTTP server for the Vana Personal Server — routes, middleware, composition root",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dev": "node --watch dist/index.js"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@opendatalabs/personal-server-ts-core": "0.0.1-canary.
|
|
41
|
+
"@opendatalabs/personal-server-ts-core": "0.0.1-canary.321fa2f",
|
|
42
42
|
"hono": "^4.7.0",
|
|
43
43
|
"@hono/node-server": "^1.14.0"
|
|
44
44
|
}
|