@openchambery/web 1.17.1-beta.7 → 1.17.1-beta.8
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 +3 -39
- package/bin/cli-output.js +0 -16
- package/bin/cli.js +3 -66
- package/bin/cli.test.js +4 -81
- package/bin/lib/DOCUMENTATION.md +5 -19
- package/bin/lib/cli-args.js +3 -327
- package/bin/lib/cli-http.js +0 -16
- package/bin/lib/cli-lifecycle.js +2 -111
- package/bin/lib/cli-paths.js +0 -57
- package/dist/assets/{AgentAvatar-htFrIvQx.js → AgentAvatar-C6Hxu5_o.js} +1 -1
- package/dist/assets/{AssistantView-BZiJsNuI.js → AssistantView-ZlXc0xFT.js} +1 -1
- package/dist/assets/{ChatContainer-CdmcMnL3.js → ChatContainer-BXFy3Uu2.js} +5 -5
- package/dist/assets/{DiagramView-B7sq74V-.js → DiagramView-CgotrQyK.js} +1 -1
- package/dist/assets/{FadeInOnReveal-8fY7XL23.js → FadeInOnReveal-CvNA_aGD.js} +1 -1
- package/dist/assets/{Icon-B7eLbnyj.js → Icon-BPJ_quEe.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DICju9ve.js → MarkdownRendererImpl-Cj4y0P0S.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CuxWU1yf.js → MobileDetailNavigation-5tAL5d_M.js} +1 -1
- package/dist/assets/{MobileShareBridge-CPg9Eyro.js → MobileShareBridge-BL7Ehxhd.js} +1 -1
- package/dist/assets/{MobileSurface-D7sDH_tx.js → MobileSurface-ByMnQ5rD.js} +1 -1
- package/dist/assets/{MultiRunWindow-MSO0Equt.js → MultiRunWindow-Che7L3TX.js} +1 -1
- package/dist/assets/{OnboardingScreen-C87u_MLg.js → OnboardingScreen-CdvaEBtt.js} +1 -1
- package/dist/assets/{OverlayScrollbar-Kmmybw-z.js → OverlayScrollbar-C2pEDFq-.js} +1 -1
- package/dist/assets/SettingsView-D0p-e8Px.js +25 -0
- package/dist/assets/{SettingsWindow-Bl25cfXX.js → SettingsWindow-KYhsFUrb.js} +1 -1
- package/dist/assets/{TerminalView-jR5jP1b0.js → TerminalView-Da5aLqHR.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DCEZb2DZ.js → ToolOutputDialog-DZI4uxx3.js} +1 -1
- package/dist/assets/{appThemeRegistry-aiRF-s3c.js → appThemeRegistry-DAgBeFsZ.js} +2 -2
- package/dist/assets/{button-bYWkDtDI.js → button-BmNJBT13.js} +1 -1
- package/dist/assets/{clipboard-CzpzN4Um.js → clipboard-CXWbHCAk.js} +1 -1
- package/dist/assets/{collapsible-A1PFvMRp.js → collapsible-68IqWBM1.js} +1 -1
- package/dist/assets/{context-menu-CkpHn-Bm.js → context-menu-BXH0AcOc.js} +1 -1
- package/dist/assets/desktopHosts-BpjUSDz4.js +1 -0
- package/dist/assets/{desktopRelayRestore-C5vYnSTd.js → desktopRelayRestore-BzUEk1i7.js} +1 -1
- package/dist/assets/{diagram-BkwKWaTO.js → diagram-YN0GZ1Q0.js} +1 -1
- package/dist/assets/{dialog-DW7-_iqo.js → dialog-BV1ENlLf.js} +1 -1
- package/dist/assets/es-EXZUX1sB.js +15 -0
- package/dist/assets/{fileQueries-P9SX4YwC.js → fileQueries-i4oziMnC.js} +1 -1
- package/dist/assets/fr-jWNPO91J.js +13 -0
- package/dist/assets/{gitApi-CMsZ2v08.js → gitApi-BW5AFgD1.js} +1 -1
- package/dist/assets/{gitApiHttp-DvIIcDAO.js → gitApiHttp-C1DaEMKR.js} +1 -1
- package/dist/assets/{input-B9aNttqV.js → input-BLVhPvhN.js} +1 -1
- package/dist/assets/{insertionBoundaries-Di3rCXgN.js → insertionBoundaries-D4KbXFFj.js} +1 -1
- package/dist/assets/ja-Dcb0VtDE.js +15 -0
- package/dist/assets/ko-CX71xNDX.js +15 -0
- package/dist/assets/{main-DY27kMV5.js → main-CcyyPAib.js} +2 -2
- package/dist/assets/{main-Chtf300b.js → main-DzxdsF_k.js} +5 -5
- package/dist/assets/{markdown-worker-BoB1_DPo.js → markdown-worker-Cq3Twp1A.js} +1 -1
- package/dist/assets/{markdownTheme-om5XcPqq.js → markdownTheme-CCnvI6L0.js} +1 -1
- package/dist/assets/{miniChat-BWbpl5SN.js → miniChat-BsNf9y48.js} +2 -2
- package/dist/assets/mobile-CsJg2IAq.js +2 -0
- package/dist/assets/{multirun-BfPcVktg.js → multirun-qs5hZkwM.js} +1 -1
- package/dist/assets/persistence-C_KCiMcY.js +3 -0
- package/dist/assets/{pl-BSjLn4dm.js → pl-mR_3Sqr8.js} +2 -2
- package/dist/assets/{projectMeta-CiAR7MRG.js → projectMeta-1SSTNg8w.js} +1 -1
- package/dist/assets/pt-BR-D1RpVOvC.js +15 -0
- package/dist/assets/radio-DBJG9Dd1.js +1 -0
- package/dist/assets/{renderElectronMiniChatApp-CiEXAVSt.js → renderElectronMiniChatApp-DOWE0jSA.js} +2 -2
- package/dist/assets/{renderMobileApp-BHvgSVPk.js → renderMobileApp-bklJJSZi.js} +3 -3
- package/dist/assets/{runtimeConfig-49YbZaqI.js → runtimeConfig-JSaYFA5x.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CdhtjuPe.js → runtimeEndpointReset-ix1NxqYw.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-XeYica3j.js → sortable-tabs-strip-DncWjNx4.js} +1 -1
- package/dist/assets/src-B8mzksNL.css +2 -0
- package/dist/assets/store-oojlrF4d.js +15 -0
- package/dist/assets/{terminalApi-DAu7xKli.js → terminalApi-BYTA045F.js} +1 -1
- package/dist/assets/{tooltip-BSlxaNrR.js → tooltip-BYGBBTc2.js} +1 -1
- package/dist/assets/uk-UvnVqWv-.js +15 -0
- package/dist/assets/{url-DjkTDrad.js → url-CGHw6D-E.js} +1 -1
- package/dist/assets/useAppFontEffects-B1EhZNex.js +7 -0
- package/dist/assets/{useDesktopWindowControlsLayout-BwYnhrEy.js → useDesktopWindowControlsLayout-Dc69l-pm.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CEmsrrEs.js → useEffectiveDirectory-dCGvvYRh.js} +1 -1
- package/dist/assets/{useFontPreferences-BxMT_kty.js → useFontPreferences-Bu4ME5hk.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DryW-QdG.js → useMobileNavigationStore-DhkIZBJw.js} +4 -4
- package/dist/assets/useSessionAutoCleanup-D-r9oDye.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-CFW2AoPL.js → useWorkerHighlightedLines-05dLFgTI.js} +1 -1
- package/dist/assets/{utils-RUACCsOs.js → utils-DyUyiLje.js} +1 -1
- package/dist/assets/zh-CN-9v-RC966.js +15 -0
- package/dist/assets/zh-TW-BZ_wZdC-.js +15 -0
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +1 -1
- package/server/index.d.ts +0 -6
- package/server/index.js +5 -153
- package/server/lib/opencode/DOCUMENTATION.md +6 -10
- package/server/lib/opencode/cli-entry-runtime.js +0 -10
- package/server/lib/opencode/cli-options.js +0 -65
- package/server/lib/opencode/core-routes.js +2 -4
- package/server/lib/opencode/routes.test.js +0 -1
- package/server/lib/opencode/server-startup-runtime.js +0 -55
- package/server/lib/opencode/settings-helpers.js +0 -55
- package/server/lib/opencode/settings-helpers.test.js +0 -20
- package/server/lib/opencode/settings-normalization-runtime.js +0 -87
- package/server/lib/opencode/settings-normalization-runtime.test.js +0 -3
- package/server/lib/opencode/settings-runtime.js +9 -102
- package/server/lib/opencode/settings-runtime.test.js +0 -10
- package/server/lib/opencode/shutdown-runtime.js +1 -9
- package/server/lib/opencode/shutdown-runtime.test.js +0 -2
- package/server/lib/opencode/startup-pipeline-runtime.js +0 -20
- package/server/lib/opencode/startup-pipeline-runtime.test.js +2 -3
- package/server/lib/opencode/tunnel-wiring-runtime.js +2 -80
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/bin/lib/cli-tunnel-capabilities.js +0 -9
- package/bin/lib/cli-tunnel-profiles.js +0 -366
- package/bin/lib/cli-tunnel-utils.js +0 -300
- package/bin/lib/commands-tunnel.js +0 -1761
- package/dist/assets/SettingsView-5YNu54KI.js +0 -25
- package/dist/assets/desktopHosts-D5m_ggY1.js +0 -1
- package/dist/assets/es-Cei_75Jt.js +0 -15
- package/dist/assets/fr-Dn7WSHh2.js +0 -13
- package/dist/assets/ja-DFARVqVj.js +0 -15
- package/dist/assets/ko-pyLnIyDY.js +0 -15
- package/dist/assets/mobile-DEQeGskq.js +0 -2
- package/dist/assets/persistence-CHA81Od7.js +0 -3
- package/dist/assets/pt-BR-DaWvr_0A.js +0 -15
- package/dist/assets/radio-BnF4XhCC.js +0 -1
- package/dist/assets/src-BtkWqMFu.css +0 -2
- package/dist/assets/store-DIpqFVjs.js +0 -15
- package/dist/assets/uk-CHCRqRKf.js +0 -15
- package/dist/assets/useAppFontEffects-BRNICZS2.js +0 -7
- package/dist/assets/useSessionAutoCleanup-DMJ1LiW_.js +0 -1
- package/dist/assets/zh-CN-BWEQZKXk.js +0 -15
- package/dist/assets/zh-TW-BbO-gJq3.js +0 -15
- package/server/lib/cloudflare-tunnel.js +0 -618
- package/server/lib/ngrok-tunnel.js +0 -343
- package/server/lib/ngrok-tunnel.test.js +0 -50
- package/server/lib/tunnels/DOCUMENTATION.md +0 -21
- package/server/lib/tunnels/executable-search.js +0 -140
- package/server/lib/tunnels/executable-search.test.js +0 -96
- package/server/lib/tunnels/index.js +0 -179
- package/server/lib/tunnels/index.test.js +0 -93
- package/server/lib/tunnels/install-help.js +0 -56
- package/server/lib/tunnels/install-help.test.js +0 -31
- package/server/lib/tunnels/managed-config.js +0 -201
- package/server/lib/tunnels/providers/cloudflare.js +0 -266
- package/server/lib/tunnels/providers/ngrok.js +0 -123
- package/server/lib/tunnels/registry.js +0 -51
- package/server/lib/tunnels/routes.js +0 -610
- package/server/lib/tunnels/types.js +0 -245
- package/server/lib/tunnels/types.test.js +0 -34
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
export const TUNNEL_PROVIDER_CLOUDFLARE = 'cloudflare';
|
|
5
|
-
export const TUNNEL_PROVIDER_NGROK = 'ngrok';
|
|
6
|
-
|
|
7
|
-
export const TUNNEL_MODE_QUICK = 'quick';
|
|
8
|
-
export const TUNNEL_MODE_MANAGED_REMOTE = 'managed-remote';
|
|
9
|
-
export const TUNNEL_MODE_MANAGED_LOCAL = 'managed-local';
|
|
10
|
-
|
|
11
|
-
export const TUNNEL_INTENT_EPHEMERAL_PUBLIC = 'ephemeral-public';
|
|
12
|
-
export const TUNNEL_INTENT_PERSISTENT_PUBLIC = 'persistent-public';
|
|
13
|
-
const TUNNEL_INTENT_PRIVATE_NETWORK = 'private-network';
|
|
14
|
-
|
|
15
|
-
const SUPPORTED_TUNNEL_INTENTS = new Set([
|
|
16
|
-
TUNNEL_INTENT_EPHEMERAL_PUBLIC,
|
|
17
|
-
TUNNEL_INTENT_PERSISTENT_PUBLIC,
|
|
18
|
-
TUNNEL_INTENT_PRIVATE_NETWORK,
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
const SUPPORTED_TUNNEL_MODES = new Set([
|
|
22
|
-
TUNNEL_MODE_QUICK,
|
|
23
|
-
TUNNEL_MODE_MANAGED_REMOTE,
|
|
24
|
-
TUNNEL_MODE_MANAGED_LOCAL,
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
export class TunnelServiceError extends Error {
|
|
28
|
-
constructor(code, message, details = null) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.name = 'TunnelServiceError';
|
|
31
|
-
this.code = code;
|
|
32
|
-
this.details = details;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const SUPPORTED_TUNNEL_PROVIDERS = new Set([
|
|
37
|
-
TUNNEL_PROVIDER_CLOUDFLARE,
|
|
38
|
-
TUNNEL_PROVIDER_NGROK,
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
const getPathApiForPlatform = (platform) => (platform === 'win32' ? path.win32 : path);
|
|
42
|
-
|
|
43
|
-
export function isPathWithinDirectory(candidatePath, directoryPath, platform = process.platform) {
|
|
44
|
-
if (typeof candidatePath !== 'string' || typeof directoryPath !== 'string') {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const pathApi = getPathApiForPlatform(platform);
|
|
49
|
-
const resolvedCandidate = pathApi.resolve(candidatePath);
|
|
50
|
-
const resolvedDirectory = pathApi.resolve(directoryPath);
|
|
51
|
-
const comparableCandidate = platform === 'win32' ? resolvedCandidate.toLowerCase() : resolvedCandidate;
|
|
52
|
-
const comparableDirectory = platform === 'win32' ? resolvedDirectory.toLowerCase() : resolvedDirectory;
|
|
53
|
-
const directoryPrefix = comparableDirectory.endsWith(pathApi.sep)
|
|
54
|
-
? comparableDirectory
|
|
55
|
-
: `${comparableDirectory}${pathApi.sep}`;
|
|
56
|
-
|
|
57
|
-
return comparableCandidate === comparableDirectory || comparableCandidate.startsWith(directoryPrefix);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function resolveTunnelConfigPath(value, home = os.homedir(), platform = process.platform) {
|
|
61
|
-
const pathApi = getPathApiForPlatform(platform);
|
|
62
|
-
let resolved;
|
|
63
|
-
if (value === '~') {
|
|
64
|
-
resolved = home;
|
|
65
|
-
} else if (value.startsWith('~/') || value.startsWith('~\\')) {
|
|
66
|
-
resolved = pathApi.join(home, value.slice(2));
|
|
67
|
-
} else {
|
|
68
|
-
resolved = pathApi.resolve(value);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!isPathWithinDirectory(resolved, home, platform)) {
|
|
72
|
-
throw new TunnelServiceError(
|
|
73
|
-
'validation_error',
|
|
74
|
-
`Config path must be within the home directory (${home}). Got: ${resolved}`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
return resolved;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function normalizeTunnelProvider(value) {
|
|
81
|
-
if (typeof value !== 'string') {
|
|
82
|
-
return TUNNEL_PROVIDER_CLOUDFLARE;
|
|
83
|
-
}
|
|
84
|
-
const provider = value.trim().toLowerCase();
|
|
85
|
-
if (!provider || !SUPPORTED_TUNNEL_PROVIDERS.has(provider)) {
|
|
86
|
-
return TUNNEL_PROVIDER_CLOUDFLARE;
|
|
87
|
-
}
|
|
88
|
-
return provider;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function normalizeTunnelMode(value) {
|
|
92
|
-
if (typeof value !== 'string') {
|
|
93
|
-
return TUNNEL_MODE_QUICK;
|
|
94
|
-
}
|
|
95
|
-
const mode = value.trim().toLowerCase();
|
|
96
|
-
if (!mode) {
|
|
97
|
-
return TUNNEL_MODE_QUICK;
|
|
98
|
-
}
|
|
99
|
-
if (mode === TUNNEL_MODE_QUICK) {
|
|
100
|
-
return TUNNEL_MODE_QUICK;
|
|
101
|
-
}
|
|
102
|
-
if (mode === TUNNEL_MODE_MANAGED_REMOTE) {
|
|
103
|
-
return TUNNEL_MODE_MANAGED_REMOTE;
|
|
104
|
-
}
|
|
105
|
-
if (mode === TUNNEL_MODE_MANAGED_LOCAL) {
|
|
106
|
-
return TUNNEL_MODE_MANAGED_LOCAL;
|
|
107
|
-
}
|
|
108
|
-
return TUNNEL_MODE_QUICK;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function normalizeTunnelIntent(value) {
|
|
112
|
-
if (typeof value !== 'string') {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
const intent = value.trim().toLowerCase();
|
|
116
|
-
if (!intent || !SUPPORTED_TUNNEL_INTENTS.has(intent)) {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
return intent;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function modeIntentFallback(mode) {
|
|
123
|
-
if (mode === TUNNEL_MODE_QUICK) {
|
|
124
|
-
return TUNNEL_INTENT_EPHEMERAL_PUBLIC;
|
|
125
|
-
}
|
|
126
|
-
if (mode === TUNNEL_MODE_MANAGED_REMOTE || mode === TUNNEL_MODE_MANAGED_LOCAL) {
|
|
127
|
-
return TUNNEL_INTENT_PERSISTENT_PUBLIC;
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function normalizeTunnelModeForRequest(value) {
|
|
133
|
-
if (typeof value === 'string') {
|
|
134
|
-
const mode = value.trim().toLowerCase();
|
|
135
|
-
if (mode === TUNNEL_MODE_QUICK || mode === TUNNEL_MODE_MANAGED_REMOTE || mode === TUNNEL_MODE_MANAGED_LOCAL) {
|
|
136
|
-
return mode;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return TUNNEL_MODE_QUICK;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function normalizeOptionalPath(value) {
|
|
143
|
-
if (value === null) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
if (typeof value !== 'string') {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
const trimmed = value.trim();
|
|
150
|
-
if (!trimmed) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
return resolveTunnelConfigPath(trimmed);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function isSupportedTunnelMode(mode) {
|
|
157
|
-
return SUPPORTED_TUNNEL_MODES.has(mode);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function normalizeTunnelStartRequest(input = {}, defaults = {}) {
|
|
161
|
-
const provider = normalizeTunnelProvider(input.provider ?? defaults.provider);
|
|
162
|
-
const mode = normalizeTunnelModeForRequest(input.mode ?? defaults.mode);
|
|
163
|
-
const explicitIntent = normalizeTunnelIntent(input.intent ?? defaults.intent);
|
|
164
|
-
const intent = explicitIntent ?? modeIntentFallback(mode);
|
|
165
|
-
const configPathValue = Object.prototype.hasOwnProperty.call(input, 'configPath')
|
|
166
|
-
? input.configPath
|
|
167
|
-
: defaults.configPath;
|
|
168
|
-
const configPath = normalizeOptionalPath(configPathValue);
|
|
169
|
-
|
|
170
|
-
const token = typeof (input.token ?? defaults.token) === 'string'
|
|
171
|
-
? (input.token ?? defaults.token).trim()
|
|
172
|
-
: '';
|
|
173
|
-
|
|
174
|
-
const hostname = typeof (input.hostname ?? defaults.hostname) === 'string'
|
|
175
|
-
? (input.hostname ?? defaults.hostname).trim().toLowerCase()
|
|
176
|
-
: '';
|
|
177
|
-
|
|
178
|
-
return {
|
|
179
|
-
provider,
|
|
180
|
-
mode,
|
|
181
|
-
intent,
|
|
182
|
-
configPath,
|
|
183
|
-
token,
|
|
184
|
-
hostname,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function validateTunnelStartRequest(request, capabilities) {
|
|
189
|
-
if (!request || typeof request !== 'object') {
|
|
190
|
-
throw new TunnelServiceError('validation_error', 'Tunnel start request must be an object');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (!request.provider) {
|
|
194
|
-
throw new TunnelServiceError('validation_error', 'Tunnel provider is required');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!isSupportedTunnelMode(request.mode)) {
|
|
198
|
-
throw new TunnelServiceError('mode_unsupported', `Unsupported tunnel mode: ${request.mode}`);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (!capabilities || capabilities.provider !== request.provider) {
|
|
202
|
-
throw new TunnelServiceError('provider_unsupported', `Unsupported tunnel provider: ${request.provider}`);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!Array.isArray(capabilities.modes)) {
|
|
206
|
-
throw new TunnelServiceError('mode_unsupported', `Provider '${request.provider}' does not declare tunnel modes`);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const modeDescriptor = capabilities.modes.find((entry) => entry?.key === request.mode);
|
|
210
|
-
if (!modeDescriptor) {
|
|
211
|
-
throw new TunnelServiceError('mode_unsupported', `Provider '${request.provider}' does not support mode '${request.mode}'`);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (typeof request.intent === 'string' && request.intent.length > 0) {
|
|
215
|
-
if (!SUPPORTED_TUNNEL_INTENTS.has(request.intent)) {
|
|
216
|
-
throw new TunnelServiceError('validation_error', `Unsupported tunnel intent: ${request.intent}`);
|
|
217
|
-
}
|
|
218
|
-
if (modeDescriptor.intent !== request.intent) {
|
|
219
|
-
throw new TunnelServiceError(
|
|
220
|
-
'validation_error',
|
|
221
|
-
`Tunnel intent '${request.intent}' does not match mode '${request.mode}' (expected '${modeDescriptor.intent}')`
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const requiredFields = Array.isArray(modeDescriptor.requires) ? modeDescriptor.requires : [];
|
|
227
|
-
|
|
228
|
-
if (requiredFields.includes('token')) {
|
|
229
|
-
if (!request.token) {
|
|
230
|
-
throw new TunnelServiceError('validation_error', 'Managed remote tunnel token is required');
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (requiredFields.includes('hostname')) {
|
|
235
|
-
if (!request.hostname) {
|
|
236
|
-
throw new TunnelServiceError('validation_error', 'Managed remote tunnel hostname is required');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (requiredFields.includes('configPath')) {
|
|
241
|
-
if (request.configPath === undefined || request.configPath === null || request.configPath === '') {
|
|
242
|
-
throw new TunnelServiceError('validation_error', `Mode '${request.mode}' requires a configPath`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
isPathWithinDirectory,
|
|
5
|
-
resolveTunnelConfigPath,
|
|
6
|
-
} from './types.js';
|
|
7
|
-
|
|
8
|
-
describe('tunnel config path normalization', () => {
|
|
9
|
-
it('allows Windows home paths with different drive casing', () => {
|
|
10
|
-
expect(isPathWithinDirectory(
|
|
11
|
-
'c:\\Users\\Bohdan\\.cloudflared\\config.yml',
|
|
12
|
-
'C:\\Users\\Bohdan',
|
|
13
|
-
'win32'
|
|
14
|
-
)).toBe(true);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('does not allow Windows sibling home directories', () => {
|
|
18
|
-
expect(isPathWithinDirectory(
|
|
19
|
-
'C:\\Users\\Bohdan2\\.cloudflared\\config.yml',
|
|
20
|
-
'C:\\Users\\Bohdan',
|
|
21
|
-
'win32'
|
|
22
|
-
)).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('resolves Windows tilde paths inside the provided home directory', () => {
|
|
26
|
-
expect(resolveTunnelConfigPath('~\\.cloudflared\\config.yml', 'C:\\Users\\Bohdan', 'win32'))
|
|
27
|
-
.toBe('C:\\Users\\Bohdan\\.cloudflared\\config.yml');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('rejects Windows paths outside the provided home directory', () => {
|
|
31
|
-
expect(() => resolveTunnelConfigPath('C:\\Temp\\config.yml', 'C:\\Users\\Bohdan', 'win32'))
|
|
32
|
-
.toThrow(/Config path must be within the home directory/);
|
|
33
|
-
});
|
|
34
|
-
});
|