alink-cli 0.11.9 → 0.11.11
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/README.md +2 -0
- package/bin/agentlink-account.js +4 -0
- package/bin/agentlink.js +24 -2
- package/dist/bin.mjs +120 -10
- package/dist/bin.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,4 +24,6 @@ alink
|
|
|
24
24
|
|
|
25
25
|
`alink login` 会打开浏览器,支持使用 GitHub 或已有 AgentLink 账号登录并添加当前电脑。原命令 `alink-cli` 继续可用。
|
|
26
26
|
|
|
27
|
+
脚本或排障时可用 `alink status --json` 和 `alink machines --json` 获取结构化的本机连接状态与账号机器数据。daemon 在网络中断、电脑唤醒或 Hub 更新后会自动退避重连,无需手动重启。
|
|
28
|
+
|
|
27
29
|
[GitHub](https://github.com/baichen99/agentlink) · [提交问题](https://github.com/baichen99/agentlink/issues)
|
package/bin/agentlink-account.js
CHANGED
|
@@ -185,9 +185,13 @@ export async function listAgentLinkAccountMachinesFromHub({ hub, jwt, fetchFn =
|
|
|
185
185
|
online: row.online === true,
|
|
186
186
|
name: typeof row.name === "string" ? row.name : undefined,
|
|
187
187
|
hostname: typeof row.hostname === "string" ? row.hostname : undefined,
|
|
188
|
+
daemonVersion: typeof row.daemonVersion === "string" ? row.daemonVersion : undefined,
|
|
188
189
|
connectedAt: timestamp(row.connectedAt),
|
|
189
190
|
createdAt: timestamp(row.createdAt),
|
|
190
191
|
updatedAt: timestamp(row.updatedAt),
|
|
192
|
+
dirs: Array.isArray(row.dirs) ? row.dirs.filter((dir) => typeof dir === "string") : undefined,
|
|
193
|
+
agents: Array.isArray(row.agents) ? row.agents.filter((agent) => typeof agent === "string") : undefined,
|
|
194
|
+
e2e: typeof row.e2e === "boolean" ? row.e2e : undefined,
|
|
191
195
|
})).filter((m) => m.machineId);
|
|
192
196
|
}
|
|
193
197
|
|
package/bin/agentlink.js
CHANGED
|
@@ -283,7 +283,7 @@ async function pair(hub) {
|
|
|
283
283
|
|
|
284
284
|
async function showHelp() {
|
|
285
285
|
console.log(
|
|
286
|
-
`用法:\n alink-cli 打开 AgentLink\n alink-cli login 登录账号\n alink-cli status
|
|
286
|
+
`用法:\n alink-cli 打开 AgentLink\n alink-cli login 登录账号\n alink-cli status [--json] 查看连接状态\n alink-cli machines [--json] 查看账号下的机器\n alink-cli logout 退出账号\n alink-cli help 查看帮助`,
|
|
287
287
|
);
|
|
288
288
|
}
|
|
289
289
|
|
|
@@ -317,6 +317,20 @@ async function showStatus() {
|
|
|
317
317
|
typeof status.hub !== "string" || normalizeHub(status.hub) === normalizeHub(hub);
|
|
318
318
|
const hubStatus =
|
|
319
319
|
!running || !statusMatchesHub ? "未连接" : status.hubConnected ? "已连接" : "连接中";
|
|
320
|
+
if (args.includes("--json")) {
|
|
321
|
+
console.log(JSON.stringify({
|
|
322
|
+
loggedIn: Boolean(savedCredential(hub)),
|
|
323
|
+
running,
|
|
324
|
+
hubConnected: hubStatus === "已连接",
|
|
325
|
+
hubStatus,
|
|
326
|
+
hub: normalizeHub(hub),
|
|
327
|
+
...(typeof status.machineId === "string" ? { machineId: status.machineId } : {}),
|
|
328
|
+
...(typeof status.daemonVersion === "string" ? { daemonVersion: status.daemonVersion } : {}),
|
|
329
|
+
...(typeof status.startedAt === "number" ? { startedAt: status.startedAt } : {}),
|
|
330
|
+
...(typeof status.ts === "number" ? { updatedAt: status.ts } : {}),
|
|
331
|
+
}, null, 2));
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
320
334
|
console.log(`[agentlink] 登录状态:${savedCredential(hub) ? "已登录" : "未登录"}`);
|
|
321
335
|
console.log(`[agentlink] 本机服务:${running ? "运行中" : "已停止"}`);
|
|
322
336
|
console.log(`[agentlink] Hub 连接:${hubStatus}`);
|
|
@@ -381,13 +395,21 @@ async function doMachines() {
|
|
|
381
395
|
saveSessionJwt(jwt, hub);
|
|
382
396
|
}
|
|
383
397
|
const machines = await listAgentLinkAccountMachinesFromHub({ hub, jwt });
|
|
398
|
+
if (args.includes("--json")) {
|
|
399
|
+
console.log(JSON.stringify(machines, null, 2));
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
384
402
|
if (machines.length === 0) console.log("[agentlink] 账号下还没有机器。");
|
|
385
403
|
else {
|
|
386
404
|
console.log(`[agentlink] 账号下共 ${machines.length} 台机器:`);
|
|
387
405
|
for (const machine of machines) {
|
|
388
406
|
const onlineMarker = machine.online ? "●" : "○";
|
|
389
407
|
const label = machine.name || machine.hostname || machine.machineId;
|
|
390
|
-
|
|
408
|
+
const details = [
|
|
409
|
+
machine.daemonVersion ? `v${machine.daemonVersion}` : undefined,
|
|
410
|
+
machine.connectedAt ? `连接于 ${new Date(machine.connectedAt).toLocaleString()}` : undefined,
|
|
411
|
+
].filter(Boolean).join(" · ");
|
|
412
|
+
console.log(` ${onlineMarker} ${label} (${machine.machineId})${details ? ` · ${details}` : ""}`);
|
|
391
413
|
}
|
|
392
414
|
}
|
|
393
415
|
}
|
package/dist/bin.mjs
CHANGED
|
@@ -11747,6 +11747,7 @@ const AuthAccessReadScope = "access:read";
|
|
|
11747
11747
|
const AuthAccessWriteScope = "access:write";
|
|
11748
11748
|
const AuthRelayReadScope = "relay:read";
|
|
11749
11749
|
const AuthRelayWriteScope = "relay:write";
|
|
11750
|
+
const AuthPortProxyOperateScope = "port-proxy:operate";
|
|
11750
11751
|
const AuthEnvironmentScope = Literals([
|
|
11751
11752
|
AuthOrchestrationReadScope,
|
|
11752
11753
|
AuthOrchestrationOperateScope,
|
|
@@ -11755,7 +11756,8 @@ const AuthEnvironmentScope = Literals([
|
|
|
11755
11756
|
AuthAccessReadScope,
|
|
11756
11757
|
AuthAccessWriteScope,
|
|
11757
11758
|
AuthRelayReadScope,
|
|
11758
|
-
AuthRelayWriteScope
|
|
11759
|
+
AuthRelayWriteScope,
|
|
11760
|
+
AuthPortProxyOperateScope
|
|
11759
11761
|
]);
|
|
11760
11762
|
const AuthEnvironmentScopes = ArraySchema(AuthEnvironmentScope);
|
|
11761
11763
|
const AuthStandardClientScopes = [
|
|
@@ -11763,7 +11765,8 @@ const AuthStandardClientScopes = [
|
|
|
11763
11765
|
AuthOrchestrationOperateScope,
|
|
11764
11766
|
AuthTerminalOperateScope,
|
|
11765
11767
|
AuthReviewWriteScope,
|
|
11766
|
-
AuthRelayReadScope
|
|
11768
|
+
AuthRelayReadScope,
|
|
11769
|
+
AuthPortProxyOperateScope
|
|
11767
11770
|
];
|
|
11768
11771
|
const AuthAdministrativeScopes = [
|
|
11769
11772
|
...AuthStandardClientScopes,
|
|
@@ -22506,6 +22509,11 @@ const ReviewDiffPreviewResult = Struct({
|
|
|
22506
22509
|
sources: ArraySchema(ReviewDiffPreviewSource)
|
|
22507
22510
|
});
|
|
22508
22511
|
const ReviewDiffPreviewError = Union([VcsError, GitCommandError]);
|
|
22512
|
+
//#endregion
|
|
22513
|
+
//#region ../t3-contracts/src/portProxy.ts
|
|
22514
|
+
const PortProxyPort = PortSchema.pipe(brand("PortProxyPort"));
|
|
22515
|
+
const PortProxyListResult = Struct({ ports: ArraySchema(PortProxyPort) });
|
|
22516
|
+
const PortProxyPortInput = Struct({ port: PortProxyPort });
|
|
22509
22517
|
const ResourceTelemetryIoSemantics = Literals([
|
|
22510
22518
|
"storage",
|
|
22511
22519
|
"logical",
|
|
@@ -23272,6 +23280,9 @@ const WS_METHODS = {
|
|
|
23272
23280
|
serverReportClientActivity: "server.reportClientActivity",
|
|
23273
23281
|
serverReportHostPowerState: "server.reportHostPowerState",
|
|
23274
23282
|
serverGetBackgroundPolicy: "server.getBackgroundPolicy",
|
|
23283
|
+
portProxyList: "portProxy.list",
|
|
23284
|
+
portProxyAuthorize: "portProxy.authorize",
|
|
23285
|
+
portProxyRevoke: "portProxy.revoke",
|
|
23275
23286
|
cloudGetRelayClientStatus: "cloud.getRelayClientStatus",
|
|
23276
23287
|
cloudInstallRelayClient: "cloud.installRelayClient",
|
|
23277
23288
|
sourceControlLookupRepository: "sourceControl.lookupRepository",
|
|
@@ -23345,6 +23356,21 @@ const WsServerGetSettingsRpc = make$52(WS_METHODS.serverGetSettings, {
|
|
|
23345
23356
|
success: ServerSettings,
|
|
23346
23357
|
error: Union([ServerSettingsError, EnvironmentAuthorizationError])
|
|
23347
23358
|
});
|
|
23359
|
+
const WsPortProxyListRpc = make$52(WS_METHODS.portProxyList, {
|
|
23360
|
+
payload: Struct({}),
|
|
23361
|
+
success: PortProxyListResult,
|
|
23362
|
+
error: EnvironmentAuthorizationError
|
|
23363
|
+
});
|
|
23364
|
+
const WsPortProxyAuthorizeRpc = make$52(WS_METHODS.portProxyAuthorize, {
|
|
23365
|
+
payload: PortProxyPortInput,
|
|
23366
|
+
success: PortProxyListResult,
|
|
23367
|
+
error: EnvironmentAuthorizationError
|
|
23368
|
+
});
|
|
23369
|
+
const WsPortProxyRevokeRpc = make$52(WS_METHODS.portProxyRevoke, {
|
|
23370
|
+
payload: PortProxyPortInput,
|
|
23371
|
+
success: PortProxyListResult,
|
|
23372
|
+
error: EnvironmentAuthorizationError
|
|
23373
|
+
});
|
|
23348
23374
|
const WsServerUpdateSettingsRpc = make$52(WS_METHODS.serverUpdateSettings, {
|
|
23349
23375
|
payload: Struct({ patch: ServerSettingsPatch }),
|
|
23350
23376
|
success: ServerSettings,
|
|
@@ -23670,7 +23696,7 @@ const WsOrchestrationSubscribeThreadRpc = make$52(ORCHESTRATION_WS_METHODS.subsc
|
|
|
23670
23696
|
error: Union([OrchestrationGetSnapshotError, EnvironmentAuthorizationError]),
|
|
23671
23697
|
stream: true
|
|
23672
23698
|
});
|
|
23673
|
-
const WsRpcGroup = make$51(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpdateServerWithProgressRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsServerSignalProcessRpc, WsServerReportClientActivityRpc, WsServerReportHostPowerStateRpc, WsServerGetBackgroundPolicyRpc, WsCloudGetRelayClientStatusRpc, WsCloudInstallRelayClientRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsReviewGetDiffFileContentsRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, make$52(WS_METHODS.subscribeTerminalEvents, {
|
|
23699
|
+
const WsRpcGroup = make$51(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpdateServerWithProgressRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsServerSignalProcessRpc, WsServerReportClientActivityRpc, WsServerReportHostPowerStateRpc, WsServerGetBackgroundPolicyRpc, WsPortProxyListRpc, WsPortProxyAuthorizeRpc, WsPortProxyRevokeRpc, WsCloudGetRelayClientStatusRpc, WsCloudInstallRelayClientRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsReviewGetDiffFileContentsRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, make$52(WS_METHODS.subscribeTerminalEvents, {
|
|
23674
23700
|
payload: Struct({}),
|
|
23675
23701
|
success: TerminalEvent,
|
|
23676
23702
|
error: EnvironmentAuthorizationError,
|
|
@@ -51040,6 +51066,60 @@ const observeRpcStreamEffect = (method, effect, traceAttributes) => {
|
|
|
51040
51066
|
return withRpcStreamTracing(method, instrumented, traceAttributes);
|
|
51041
51067
|
};
|
|
51042
51068
|
//#endregion
|
|
51069
|
+
//#region src/portProxy.ts
|
|
51070
|
+
const ports = /* @__PURE__ */ new Set();
|
|
51071
|
+
const methods = /* @__PURE__ */ new Set([
|
|
51072
|
+
"GET",
|
|
51073
|
+
"HEAD",
|
|
51074
|
+
"POST",
|
|
51075
|
+
"PUT",
|
|
51076
|
+
"PATCH",
|
|
51077
|
+
"DELETE",
|
|
51078
|
+
"OPTIONS"
|
|
51079
|
+
]);
|
|
51080
|
+
const requestHeaders = /* @__PURE__ */ new Set([
|
|
51081
|
+
"authorization",
|
|
51082
|
+
"cookie",
|
|
51083
|
+
"host",
|
|
51084
|
+
"connection",
|
|
51085
|
+
"upgrade",
|
|
51086
|
+
"proxy-authorization",
|
|
51087
|
+
"proxy-connection"
|
|
51088
|
+
]);
|
|
51089
|
+
const responseHeaders = /* @__PURE__ */ new Set([
|
|
51090
|
+
"set-cookie",
|
|
51091
|
+
"connection",
|
|
51092
|
+
"upgrade",
|
|
51093
|
+
"proxy-authenticate",
|
|
51094
|
+
"transfer-encoding"
|
|
51095
|
+
]);
|
|
51096
|
+
function listAuthorizedPorts() {
|
|
51097
|
+
return [...ports].sort((a, b) => a - b);
|
|
51098
|
+
}
|
|
51099
|
+
function authorizePort(port) {
|
|
51100
|
+
ports.add(port);
|
|
51101
|
+
return listAuthorizedPorts();
|
|
51102
|
+
}
|
|
51103
|
+
function revokePort(port) {
|
|
51104
|
+
ports.delete(port);
|
|
51105
|
+
return listAuthorizedPorts();
|
|
51106
|
+
}
|
|
51107
|
+
function isPortAuthorized(port) {
|
|
51108
|
+
return ports.has(port);
|
|
51109
|
+
}
|
|
51110
|
+
function authorizedPortBaseUrl(port) {
|
|
51111
|
+
return isPortAuthorized(port) ? `http://127.0.0.1:${port}` : null;
|
|
51112
|
+
}
|
|
51113
|
+
function isPortProxyMethodAllowed(method) {
|
|
51114
|
+
return methods.has(method.toUpperCase());
|
|
51115
|
+
}
|
|
51116
|
+
function isPortProxyRequestHeaderAllowed(header) {
|
|
51117
|
+
return !requestHeaders.has(header.toLowerCase());
|
|
51118
|
+
}
|
|
51119
|
+
function isPortProxyResponseHeaderAllowed(header) {
|
|
51120
|
+
return !responseHeaders.has(header.toLowerCase());
|
|
51121
|
+
}
|
|
51122
|
+
//#endregion
|
|
51043
51123
|
//#region ../t3-shared/src/searchRanking.ts
|
|
51044
51124
|
function normalizeSearchQuery(input, options) {
|
|
51045
51125
|
const trimmed = input.trim();
|
|
@@ -52379,6 +52459,9 @@ const RPC_REQUIRED_SCOPES = {
|
|
|
52379
52459
|
[WS_METHODS.serverReportClientActivity]: AuthOrchestrationReadScope,
|
|
52380
52460
|
[WS_METHODS.serverReportHostPowerState]: AuthOrchestrationOperateScope,
|
|
52381
52461
|
[WS_METHODS.serverGetBackgroundPolicy]: AuthOrchestrationReadScope,
|
|
52462
|
+
[WS_METHODS.portProxyList]: AuthOrchestrationOperateScope,
|
|
52463
|
+
[WS_METHODS.portProxyAuthorize]: AuthOrchestrationOperateScope,
|
|
52464
|
+
[WS_METHODS.portProxyRevoke]: AuthOrchestrationOperateScope,
|
|
52382
52465
|
[WS_METHODS.cloudGetRelayClientStatus]: AuthRelayReadScope,
|
|
52383
52466
|
[WS_METHODS.cloudInstallRelayClient]: AuthRelayWriteScope,
|
|
52384
52467
|
[WS_METHODS.sourceControlLookupRepository]: AuthOrchestrationReadScope,
|
|
@@ -52885,6 +52968,9 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
|
|
|
52885
52968
|
}), { "rpc.aggregate": "orchestration" }),
|
|
52886
52969
|
[WS_METHODS.serverProbe]: (_input) => observeRpcEffect$1(WS_METHODS.serverProbe, succeed$1({}), { "rpc.aggregate": "server" }),
|
|
52887
52970
|
[WS_METHODS.serverGetConfig]: (_input) => observeRpcEffect$1(WS_METHODS.serverGetConfig, loadServerConfig, { "rpc.aggregate": "server" }),
|
|
52971
|
+
[WS_METHODS.portProxyList]: (_input) => observeRpcEffect$1(WS_METHODS.portProxyList, sync(() => ({ ports: listAuthorizedPorts() })), { "rpc.aggregate": "port-proxy" }),
|
|
52972
|
+
[WS_METHODS.portProxyAuthorize]: ({ port }) => observeRpcEffect$1(WS_METHODS.portProxyAuthorize, sync(() => ({ ports: authorizePort(port) })), { "rpc.aggregate": "port-proxy" }),
|
|
52973
|
+
[WS_METHODS.portProxyRevoke]: ({ port }) => observeRpcEffect$1(WS_METHODS.portProxyRevoke, sync(() => ({ ports: revokePort(port) })), { "rpc.aggregate": "port-proxy" }),
|
|
52888
52974
|
[WS_METHODS.serverRefreshProviders]: (input) => observeRpcEffect$1(WS_METHODS.serverRefreshProviders, (input.instanceId !== void 0 ? providerRegistry.refreshInstance(input.instanceId) : providerRegistry.refresh()).pipe(map$4((providers) => ({ providers }))), { "rpc.aggregate": "server" }),
|
|
52889
52975
|
[WS_METHODS.serverUpdateProvider]: (input) => observeRpcEffect$1(WS_METHODS.serverUpdateProvider, providerMaintenanceRunner.updateProvider(input), { "rpc.aggregate": "server" }),
|
|
52890
52976
|
[WS_METHODS.serverUpdateSettings]: ({ patch }) => observeRpcEffect$1(WS_METHODS.serverUpdateSettings, serverSettings.updateSettings(patch).pipe(map$4(redactServerSettingsForClient)), { "rpc.aggregate": "server" }),
|
|
@@ -53185,7 +53271,8 @@ function makeAgentLinkFrameAssembler() {
|
|
|
53185
53271
|
const TUNNEL_SCOPES = [
|
|
53186
53272
|
AuthOrchestrationReadScope,
|
|
53187
53273
|
AuthOrchestrationOperateScope,
|
|
53188
|
-
AuthTerminalOperateScope
|
|
53274
|
+
AuthTerminalOperateScope,
|
|
53275
|
+
AuthPortProxyOperateScope
|
|
53189
53276
|
];
|
|
53190
53277
|
function machineIdFromToken(token) {
|
|
53191
53278
|
const parts = token.split(".");
|
|
@@ -53322,7 +53409,7 @@ const splitHubFrame = (text) => {
|
|
|
53322
53409
|
};
|
|
53323
53410
|
};
|
|
53324
53411
|
function isHttpTunnelRequestFrame(value) {
|
|
53325
|
-
return typeof value === "object" && value !== null && value._tag === "HttpRequest" && typeof value.id === "string" && typeof value.method === "string" && typeof value.path === "string" && Array.isArray(value.headers) && (value.body === null || typeof value.body === "string");
|
|
53412
|
+
return typeof value === "object" && value !== null && value._tag === "HttpRequest" && typeof value.id === "string" && typeof value.method === "string" && typeof value.path === "string" && Array.isArray(value.headers) && (value.body === null || typeof value.body === "string") && (value.targetPort === void 0 || Number.isInteger(value.targetPort) && Number(value.targetPort) >= 1 && Number(value.targetPort) <= 65535);
|
|
53326
53413
|
}
|
|
53327
53414
|
function encodeHttpTunnelResponseFrame(frame) {
|
|
53328
53415
|
return JSON.stringify(frame);
|
|
@@ -53455,7 +53542,7 @@ const runHubTunnel = (config) => gen(function* () {
|
|
|
53455
53542
|
});
|
|
53456
53543
|
yield* addFinalizer(() => sessionsStore.markDisconnected(issued.sessionId).pipe(andThen(serverAuth.revokeSession(issued.sessionId)), ignore$1));
|
|
53457
53544
|
yield* sessionsStore.markConnected(issued.sessionId);
|
|
53458
|
-
const
|
|
53545
|
+
const daemonBaseUrl = `http://127.0.0.1:${serverConfig.port}`;
|
|
53459
53546
|
const sendEncrypted = (frame) => {
|
|
53460
53547
|
try {
|
|
53461
53548
|
for (const part of chunkAgentLinkFrame(encodeHttpTunnelResponseFrame(frame))) {
|
|
@@ -53496,12 +53583,35 @@ const runHubTunnel = (config) => gen(function* () {
|
|
|
53496
53583
|
});
|
|
53497
53584
|
return;
|
|
53498
53585
|
}
|
|
53586
|
+
const portProxyBaseUrl = requestFrame.targetPort === void 0 ? void 0 : authorizedPortBaseUrl(requestFrame.targetPort);
|
|
53587
|
+
if (portProxyBaseUrl === null) {
|
|
53588
|
+
sendEncrypted({
|
|
53589
|
+
_tag: "HttpResponse",
|
|
53590
|
+
id: requestFrame.id,
|
|
53591
|
+
status: 403,
|
|
53592
|
+
statusText: "Forbidden",
|
|
53593
|
+
headers: [["content-type", "text/plain; charset=utf-8"]],
|
|
53594
|
+
body: Buffer.from("This port has not been authorized in AgentLink settings.").toString("base64")
|
|
53595
|
+
});
|
|
53596
|
+
return;
|
|
53597
|
+
}
|
|
53598
|
+
if (portProxyBaseUrl !== void 0 && !isPortProxyMethodAllowed(requestFrame.method)) {
|
|
53599
|
+
sendEncrypted({
|
|
53600
|
+
_tag: "HttpResponse",
|
|
53601
|
+
id: requestFrame.id,
|
|
53602
|
+
status: 405,
|
|
53603
|
+
statusText: "Method Not Allowed",
|
|
53604
|
+
headers: [["content-type", "text/plain; charset=utf-8"]],
|
|
53605
|
+
body: Buffer.from("Unsupported port proxy method.").toString("base64")
|
|
53606
|
+
});
|
|
53607
|
+
return;
|
|
53608
|
+
}
|
|
53499
53609
|
runFork(gen(function* () {
|
|
53500
|
-
const targetUrl = `${
|
|
53501
|
-
const headers = { authorization: `Bearer ${issued.token}` };
|
|
53610
|
+
const targetUrl = `${portProxyBaseUrl ?? daemonBaseUrl}${requestFrame.path}`;
|
|
53611
|
+
const headers = requestFrame.targetPort === void 0 ? { authorization: `Bearer ${issued.token}` } : {};
|
|
53502
53612
|
for (const [key, value] of requestFrame.headers) {
|
|
53503
53613
|
const lower = key.toLowerCase();
|
|
53504
|
-
if (lower === "authorization" || lower === "cookie") continue;
|
|
53614
|
+
if (requestFrame.targetPort === void 0 ? lower === "authorization" || lower === "cookie" : !isPortProxyRequestHeaderAllowed(lower)) continue;
|
|
53505
53615
|
headers[lower] = value;
|
|
53506
53616
|
}
|
|
53507
53617
|
let request = make$65(requestFrame.method)(targetUrl).pipe(setHeaders(headers));
|
|
@@ -53509,7 +53619,7 @@ const runHubTunnel = (config) => gen(function* () {
|
|
|
53509
53619
|
const response = yield* httpClient.execute(request);
|
|
53510
53620
|
const responseBody = yield* response.arrayBuffer;
|
|
53511
53621
|
const responseHeaders = [];
|
|
53512
|
-
for (const [key, value] of Object.entries(response.headers)) if (typeof value === "string") responseHeaders.push([key, value]);
|
|
53622
|
+
for (const [key, value] of Object.entries(response.headers)) if (typeof value === "string" && (requestFrame.targetPort === void 0 || isPortProxyResponseHeaderAllowed(key))) responseHeaders.push([key, value]);
|
|
53513
53623
|
return {
|
|
53514
53624
|
_tag: "HttpResponse",
|
|
53515
53625
|
id: requestFrame.id,
|