@hamedb89/localghost 0.1.6 → 0.1.9
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 +202 -22
- package/apps/macos-widget/LocalghostWidget.entitlements +12 -0
- package/apps/macos-widget/LocalghostWidget.swift +871 -0
- package/apps/macos-widget/Resources/localghost-logo-source.png +0 -0
- package/apps/macos-widget/Resources/localghost-widget-ui-reference.png +0 -0
- package/apps/macos-widget/Shared/LocalghostWidgetSnapshot.swift +50 -0
- package/apps/macos-widget/WidgetExtension/LocalghostDesktopWidget.swift +176 -0
- package/apps/macos-widget/WidgetExtension/LocalghostDesktopWidgetExtension.entitlements +12 -0
- package/apps/macos-widget/build.sh +60 -0
- package/apps/macos-widget/project.yml +40 -0
- package/assets/ghost-tunnel-app-icon.png +0 -0
- package/assets/ghost-tunnel-portal.png +0 -0
- package/assets/ghost-tunnel-wordmark.png +0 -0
- package/dist/cli.js +731 -91
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +138 -5
- package/dist/index.js +833 -37
- package/dist/index.js.map +1 -1
- package/dist/tunnel-DzfLXZ8O.d.ts +126 -0
- package/dist/vite.d.ts +5 -1
- package/dist/vite.js +717 -43
- package/dist/vite.js.map +1 -1
- package/docs/flows.md +19 -0
- package/docs/ghost-tunnel.md +249 -0
- package/docs/github.md +6 -6
- package/docs/localghost.1.md +28 -7
- package/docs/macos-widget.md +108 -0
- package/package.json +8 -2
- package/dist/config-Cde1Bich.d.ts +0 -31
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { D as DevHostEntry, R as ReadDevHostsOptions, C as ConfigPattern } from './
|
|
2
|
-
export { L as LOCALGHOST_CONFIG_FILE,
|
|
1
|
+
import { D as DevHostEntry, R as ReadDevHostsOptions, a as GhostTunnelConfig, C as ConfigPattern, G as GhostTunnelOptions } from './tunnel-DzfLXZ8O.js';
|
|
2
|
+
export { b as ConstructGhostTunnelUrlInput, c as GhostTunnelDisplayDefaults, d as GhostTunnelDomainOptions, e as GhostTunnelMode, f as GhostTunnelNamespaceConfig, g as GhostTunnelNamespaceOptions, h as GhostTunnelNamespaceTag, i as GhostTunnelNamespaceValues, j as GhostTunnelPreviewOptions, k as GhostTunnelRoute, L as LOCALGHOST_CONFIG_FILE, l as ResolvedDevHostsPath, m as assertSecureGhostTunnelRequest, n as constructGhostTunnelHost, o as constructGhostTunnelURL, p as constructGhostTunnelUrl, q as findLocalMdnsHosts, r as getConfigFileCandidates, s as getDevHostsPath, t as getGhostTunnelDefaultDisplayUrl, u as getGhostTunnelDisplayUrl, v as getGhostTunnelDisplayUrls, w as getGhostTunnelEntryHost, x as getGhostTunnelPreviewUrl, y as getGhostTunnelWildcardHost, z as getProjectName, A as parseDevHosts, B as parseGhostTunnelHost, E as readDevHosts, F as resolveDevHostsPath, H as resolveGhostTunnelConfig, I as sanitizeProjectName } from './tunnel-DzfLXZ8O.js';
|
|
3
3
|
import * as execa from 'execa';
|
|
4
4
|
|
|
5
5
|
declare const LOCALGHOST_ACTIVITY_VERSION = 1;
|
|
6
|
-
type LocalghostRunMode = "dev" | "run";
|
|
6
|
+
type LocalghostRunMode = "dev" | "run" | "vite";
|
|
7
7
|
type LocalghostRunRecord = {
|
|
8
8
|
id: string;
|
|
9
9
|
mode: LocalghostRunMode;
|
|
@@ -23,15 +23,29 @@ type LocalghostRunRecord = {
|
|
|
23
23
|
dynamicPort?: boolean;
|
|
24
24
|
entries: DevHostEntry[];
|
|
25
25
|
};
|
|
26
|
+
type LocalghostSetupRecord = {
|
|
27
|
+
id: string;
|
|
28
|
+
cwd: string;
|
|
29
|
+
projectName: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
configPath?: string;
|
|
32
|
+
caddyfilePath?: string;
|
|
33
|
+
https?: boolean;
|
|
34
|
+
entries: DevHostEntry[];
|
|
35
|
+
};
|
|
26
36
|
type LocalghostActivity = {
|
|
27
37
|
version: typeof LOCALGHOST_ACTIVITY_VERSION;
|
|
28
38
|
runs: LocalghostRunRecord[];
|
|
39
|
+
setups: LocalghostSetupRecord[];
|
|
29
40
|
};
|
|
30
41
|
type RegisterLocalghostRunInput = Omit<LocalghostRunRecord, "id" | "pid" | "startedAt" | "updatedAt"> & {
|
|
31
42
|
id?: string;
|
|
32
43
|
pid?: number;
|
|
33
44
|
startedAt?: string;
|
|
34
45
|
};
|
|
46
|
+
type RegisterLocalghostSetupInput = Omit<LocalghostSetupRecord, "id" | "updatedAt"> & {
|
|
47
|
+
id?: string;
|
|
48
|
+
};
|
|
35
49
|
declare function getLocalghostActivityPath(env?: NodeJS.ProcessEnv): string;
|
|
36
50
|
declare function isProcessRunning(pid: number): boolean;
|
|
37
51
|
declare function readLocalghostActivity(path?: string): LocalghostActivity;
|
|
@@ -40,10 +54,18 @@ declare function pruneLocalghostActivity(path?: string): {
|
|
|
40
54
|
path: string;
|
|
41
55
|
pruned: boolean;
|
|
42
56
|
runs: LocalghostRunRecord[];
|
|
57
|
+
setups: LocalghostSetupRecord[];
|
|
43
58
|
};
|
|
44
59
|
declare function listLocalghostRuns(path?: string): LocalghostRunRecord[];
|
|
60
|
+
declare function listLocalghostSetups(path?: string): LocalghostSetupRecord[];
|
|
45
61
|
declare function registerLocalghostRun(input: RegisterLocalghostRunInput, path?: string): LocalghostRunRecord;
|
|
62
|
+
declare function registerLocalghostSetup(input: RegisterLocalghostSetupInput, path?: string): LocalghostSetupRecord;
|
|
46
63
|
declare function unregisterLocalghostRun(id: string, path?: string): void;
|
|
64
|
+
declare function unregisterLocalghostSetup(options: {
|
|
65
|
+
cwd: string;
|
|
66
|
+
projectName?: string;
|
|
67
|
+
configPath?: string;
|
|
68
|
+
}, path?: string): void;
|
|
47
69
|
|
|
48
70
|
type CaddyModeOptions = {
|
|
49
71
|
https?: boolean;
|
|
@@ -57,10 +79,12 @@ declare function startCaddy(path: string): execa.ResultPromise<{
|
|
|
57
79
|
cwd: string;
|
|
58
80
|
stdio: "inherit";
|
|
59
81
|
}>;
|
|
82
|
+
declare function trustCaddy(path: string): Promise<void>;
|
|
60
83
|
|
|
61
84
|
type LocalghostContextOptions = {
|
|
62
85
|
cwd?: string;
|
|
63
86
|
project?: string;
|
|
87
|
+
localghostConfig?: string | false;
|
|
64
88
|
fileName?: string;
|
|
65
89
|
configFiles?: string[];
|
|
66
90
|
configPattern?: ConfigPattern;
|
|
@@ -69,6 +93,8 @@ type LocalghostContextOptions = {
|
|
|
69
93
|
bindHost?: string | boolean;
|
|
70
94
|
primaryHost?: string;
|
|
71
95
|
dynamicPort?: boolean;
|
|
96
|
+
wwwAlias?: boolean;
|
|
97
|
+
ghostTunnel?: GhostTunnelOptions;
|
|
72
98
|
};
|
|
73
99
|
type LocalghostContext = {
|
|
74
100
|
cwd: string;
|
|
@@ -85,7 +111,19 @@ type LocalghostContext = {
|
|
|
85
111
|
bindHost: string | boolean;
|
|
86
112
|
primaryHost: string;
|
|
87
113
|
https: boolean;
|
|
114
|
+
wwwAlias: boolean;
|
|
115
|
+
ghostTunnel: GhostTunnelConfig;
|
|
116
|
+
projectConfigPath?: string;
|
|
117
|
+
};
|
|
118
|
+
type LocalghostProjectConfig = Omit<LocalghostContextOptions, "cwd" | "localghostConfig">;
|
|
119
|
+
type LocalghostProjectConfigResult = {
|
|
120
|
+
config: LocalghostProjectConfig;
|
|
121
|
+
path?: string;
|
|
88
122
|
};
|
|
123
|
+
declare function readLocalghostProjectConfig(options?: {
|
|
124
|
+
cwd?: string;
|
|
125
|
+
configFile?: string | false;
|
|
126
|
+
}): Promise<LocalghostProjectConfigResult>;
|
|
89
127
|
declare function defineLocalghostConfig<T extends LocalghostContextOptions>(config: T): T;
|
|
90
128
|
declare function resolveLocalghostContext(options?: LocalghostContextOptions): Promise<LocalghostContext>;
|
|
91
129
|
|
|
@@ -153,6 +191,92 @@ type FindAvailablePortOptions = {
|
|
|
153
191
|
declare function isPortAvailable(port: number, host?: string): Promise<boolean>;
|
|
154
192
|
declare function findAvailablePort(startPort: number, options?: FindAvailablePortOptions): Promise<number>;
|
|
155
193
|
|
|
194
|
+
type RelayProtocol = "http" | "https";
|
|
195
|
+
type RelayAccessMode = "private" | "public";
|
|
196
|
+
type RelayLocalTarget = {
|
|
197
|
+
protocol?: RelayProtocol;
|
|
198
|
+
host: string;
|
|
199
|
+
port: number;
|
|
200
|
+
};
|
|
201
|
+
type RelayLimits = {
|
|
202
|
+
requestBodyBytes: number;
|
|
203
|
+
responseBytes: number;
|
|
204
|
+
timeoutMs: number;
|
|
205
|
+
maxConcurrentRequests: number;
|
|
206
|
+
perRouteRequestsPerMinute: number;
|
|
207
|
+
perIpRequestsPerMinute: number;
|
|
208
|
+
};
|
|
209
|
+
type RelayTargetPolicy = {
|
|
210
|
+
allowedHosts: string[];
|
|
211
|
+
blockedPorts: number[];
|
|
212
|
+
allowPrivateNetworkTargets: boolean;
|
|
213
|
+
};
|
|
214
|
+
type RelayRouteClaim = {
|
|
215
|
+
host: string;
|
|
216
|
+
scope: string;
|
|
217
|
+
expiresAt: string;
|
|
218
|
+
agentId: string;
|
|
219
|
+
};
|
|
220
|
+
type SignedRelayRouteClaim = {
|
|
221
|
+
payload: RelayRouteClaim;
|
|
222
|
+
token: string;
|
|
223
|
+
};
|
|
224
|
+
type RelayRouteRegistrationInput = {
|
|
225
|
+
authorizationHeader?: string | null;
|
|
226
|
+
agentToken: string;
|
|
227
|
+
claimToken: string;
|
|
228
|
+
signingSecret: string;
|
|
229
|
+
expectedScope: string;
|
|
230
|
+
target: RelayLocalTarget;
|
|
231
|
+
access?: RelayAccessMode;
|
|
232
|
+
publicMode?: boolean;
|
|
233
|
+
passwordProtected?: boolean;
|
|
234
|
+
authRequired?: boolean;
|
|
235
|
+
now?: Date;
|
|
236
|
+
targetPolicy?: Partial<RelayTargetPolicy>;
|
|
237
|
+
limits?: Partial<RelayLimits>;
|
|
238
|
+
};
|
|
239
|
+
type ActiveRelayRoute = {
|
|
240
|
+
host: string;
|
|
241
|
+
scope: string;
|
|
242
|
+
agentId: string;
|
|
243
|
+
expiresAt: string;
|
|
244
|
+
target: Required<RelayLocalTarget>;
|
|
245
|
+
access: RelayAccessMode;
|
|
246
|
+
passwordProtected: boolean;
|
|
247
|
+
authRequired: boolean;
|
|
248
|
+
limits: RelayLimits;
|
|
249
|
+
};
|
|
250
|
+
type RelayOfflineResponse = {
|
|
251
|
+
status: 503;
|
|
252
|
+
headers: Record<string, string>;
|
|
253
|
+
body: string;
|
|
254
|
+
};
|
|
255
|
+
declare const DEFAULT_RELAY_ALLOWED_TARGET_HOSTS: readonly ["localhost", "127.0.0.1", "::1"];
|
|
256
|
+
declare const DEFAULT_RELAY_BLOCKED_PORTS: readonly [22, 2375, 2376, 5432, 6379, 9200, 9229, 27017];
|
|
257
|
+
declare const DEFAULT_RELAY_LIMITS: RelayLimits;
|
|
258
|
+
declare const DEFAULT_RELAY_TARGET_POLICY: RelayTargetPolicy;
|
|
259
|
+
declare function assertExactRelayHost(host: string): string;
|
|
260
|
+
declare function assertRelayLocalTarget(target: RelayLocalTarget, policyInput?: Partial<RelayTargetPolicy>): Required<RelayLocalTarget>;
|
|
261
|
+
declare function authenticateRelayAgentToken(input: {
|
|
262
|
+
authorizationHeader?: string | null;
|
|
263
|
+
agentToken: string;
|
|
264
|
+
}): boolean;
|
|
265
|
+
declare function signRelayRouteClaim(claim: RelayRouteClaim, signingSecret: string): SignedRelayRouteClaim;
|
|
266
|
+
declare function verifyRelayRouteClaim(token: string, signingSecret: string, options: {
|
|
267
|
+
expectedScope: string;
|
|
268
|
+
now?: Date;
|
|
269
|
+
}): RelayRouteClaim;
|
|
270
|
+
declare function createRelayRouteRegistration(input: RelayRouteRegistrationInput): ActiveRelayRoute;
|
|
271
|
+
declare function isRelayRouteActive(route: ActiveRelayRoute, options: {
|
|
272
|
+
agentConnected: boolean;
|
|
273
|
+
now?: Date;
|
|
274
|
+
}): boolean;
|
|
275
|
+
declare function stripRelayForwardHeaders(headers: Record<string, string | string[] | undefined>): Record<string, string | string[]>;
|
|
276
|
+
declare function redactRelayHeaders(headers: Record<string, string | string[] | undefined>): Record<string, string | string[]>;
|
|
277
|
+
declare function redactRelayLogUrl(input: string): string;
|
|
278
|
+
declare function renderRelayOfflineResponse(): RelayOfflineResponse;
|
|
279
|
+
|
|
156
280
|
type DomainRoute = {
|
|
157
281
|
host: string;
|
|
158
282
|
port: number;
|
|
@@ -162,8 +286,14 @@ type DomainRoute = {
|
|
|
162
286
|
type DomainRouteOptions = {
|
|
163
287
|
https?: boolean;
|
|
164
288
|
};
|
|
289
|
+
type GhostTunnelFormatOptions = {
|
|
290
|
+
color?: boolean;
|
|
291
|
+
label?: "configured" | "expected" | "ready" | "running";
|
|
292
|
+
verbose?: boolean;
|
|
293
|
+
};
|
|
165
294
|
declare function getDomainRoutes(entries: DevHostEntry[], options?: DomainRouteOptions): DomainRoute[];
|
|
166
295
|
declare function formatDomainRoutes(entries: DevHostEntry[], options?: DomainRouteOptions): string;
|
|
296
|
+
declare function formatGhostTunnel(config: GhostTunnelConfig, options?: GhostTunnelFormatOptions): string | null;
|
|
167
297
|
|
|
168
298
|
declare const LOCALGHOST_STATE_FILE = "ops/local/localghost-state.json";
|
|
169
299
|
type LocalghostStateAction = "setup" | "teardown";
|
|
@@ -180,15 +310,18 @@ type LocalghostState = {
|
|
|
180
310
|
caddyfilePath?: string;
|
|
181
311
|
caddyfileRemoved?: boolean;
|
|
182
312
|
caddyHttps?: boolean;
|
|
313
|
+
caddyTrustedAt?: string;
|
|
314
|
+
caddyTrustPromptedAt?: string;
|
|
183
315
|
entries?: DevHostEntry[];
|
|
184
316
|
};
|
|
185
317
|
type WriteLocalghostStateInput = Omit<LocalghostState, "version" | "updatedAt">;
|
|
186
318
|
declare function getLocalghostStatePath(cwd?: string): string;
|
|
187
319
|
declare function readLocalghostState(cwd?: string): LocalghostState | null;
|
|
188
320
|
declare function writeLocalghostState(cwd: string, state: WriteLocalghostStateInput): string;
|
|
321
|
+
declare function patchLocalghostState(cwd: string, patch: Partial<WriteLocalghostStateInput>): string | null;
|
|
189
322
|
|
|
190
323
|
declare const LOCALGHOST_PACKAGE_NAME = "@hamedb89/localghost";
|
|
191
|
-
declare const LOCALGHOST_VERSION = "0.1.
|
|
324
|
+
declare const LOCALGHOST_VERSION = "0.1.9";
|
|
192
325
|
declare const UPDATE_CHECK_CACHE_TTL_MS: number;
|
|
193
326
|
declare const UPDATE_CHECK_NOTIFY_TTL_MS: number;
|
|
194
327
|
declare const UPDATE_CHECK_TIMEOUT_MS = 900;
|
|
@@ -225,4 +358,4 @@ declare function maybeNotifyAboutUpdate(options?: {
|
|
|
225
358
|
disabled?: boolean;
|
|
226
359
|
}): Promise<void>;
|
|
227
360
|
|
|
228
|
-
export { type CaddyModeOptions, ConfigPattern, DevHostEntry, type DoctorResult, type DomainRoute, type DomainRouteOptions, type FindAvailablePortOptions, type InitOptions, type InitResult, LOCALGHOST_ACTIVITY_VERSION, LOCALGHOST_PACKAGE_NAME, LOCALGHOST_STATE_FILE, LOCALGHOST_VERSION, type LocalghostActivity, type LocalghostContext, type LocalghostContextOptions, type LocalghostEnvironment, type LocalghostRunMode, type LocalghostRunRecord, type LocalghostState, type LocalghostStateAction, type PackageManager, ReadDevHostsOptions, type RegisterLocalghostRunInput, type RemoveSystemHostsResult, UPDATE_CHECK_CACHE_TTL_MS, UPDATE_CHECK_NOTIFY_TTL_MS, UPDATE_CHECK_TIMEOUT_MS, type UpdateCheckCache, type UpdateCheckResult, type UpdateSystemHostsResult, type WriteLocalghostStateInput, assertLocalDevelopment, checkCaddy, checkForUpdate, compareVersions, defineLocalghostConfig, detectPackageManager, findAvailablePort, formatDomainRoutes, formatUpdateMessage, getCaddyfilePath, getDomainRoutes, getLocalghostActivityPath, getLocalghostStatePath, getProductionEnvKeys, getProductionReason, getSystemHostsPath, getUpdateCheckCachePath, initLocalghost, isNewerVersion, isPortAvailable, isProcessRunning, isProductionLike, isUpdateCheckDisabled, listLocalghostRuns, markUpdateNotified, maybeNotifyAboutUpdate, packageAddCommand, packageRunCommand, pruneLocalghostActivity, readLocalghostActivity, readLocalghostState, registerLocalghostRun, removeManagedBlock, removeSystemHosts, renderCaddyfile, renderHostsBlock, resolveLocalghostContext, runCaddy, runDoctor, shouldNotifyAboutUpdate, startCaddy, unregisterLocalghostRun, updateSystemHosts, upsertManagedBlock, validateCaddyfile, writeCaddyfile, writeLocalghostActivity, writeLocalghostState };
|
|
361
|
+
export { type ActiveRelayRoute, type CaddyModeOptions, ConfigPattern, DEFAULT_RELAY_ALLOWED_TARGET_HOSTS, DEFAULT_RELAY_BLOCKED_PORTS, DEFAULT_RELAY_LIMITS, DEFAULT_RELAY_TARGET_POLICY, DevHostEntry, type DoctorResult, type DomainRoute, type DomainRouteOptions, type FindAvailablePortOptions, GhostTunnelConfig, GhostTunnelOptions, type InitOptions, type InitResult, LOCALGHOST_ACTIVITY_VERSION, LOCALGHOST_PACKAGE_NAME, LOCALGHOST_STATE_FILE, LOCALGHOST_VERSION, type LocalghostActivity, type LocalghostContext, type LocalghostContextOptions, type LocalghostEnvironment, type LocalghostProjectConfig, type LocalghostProjectConfigResult, type LocalghostRunMode, type LocalghostRunRecord, type LocalghostSetupRecord, type LocalghostState, type LocalghostStateAction, type PackageManager, ReadDevHostsOptions, type RegisterLocalghostRunInput, type RegisterLocalghostSetupInput, type RelayAccessMode, type RelayLimits, type RelayLocalTarget, type RelayOfflineResponse, type RelayProtocol, type RelayRouteClaim, type RelayRouteRegistrationInput, type RelayTargetPolicy, type RemoveSystemHostsResult, type SignedRelayRouteClaim, UPDATE_CHECK_CACHE_TTL_MS, UPDATE_CHECK_NOTIFY_TTL_MS, UPDATE_CHECK_TIMEOUT_MS, type UpdateCheckCache, type UpdateCheckResult, type UpdateSystemHostsResult, type WriteLocalghostStateInput, assertExactRelayHost, assertLocalDevelopment, assertRelayLocalTarget, authenticateRelayAgentToken, checkCaddy, checkForUpdate, compareVersions, createRelayRouteRegistration, defineLocalghostConfig, detectPackageManager, findAvailablePort, formatDomainRoutes, formatGhostTunnel, formatUpdateMessage, getCaddyfilePath, getDomainRoutes, getLocalghostActivityPath, getLocalghostStatePath, getProductionEnvKeys, getProductionReason, getSystemHostsPath, getUpdateCheckCachePath, initLocalghost, isNewerVersion, isPortAvailable, isProcessRunning, isProductionLike, isRelayRouteActive, isUpdateCheckDisabled, listLocalghostRuns, listLocalghostSetups, markUpdateNotified, maybeNotifyAboutUpdate, packageAddCommand, packageRunCommand, patchLocalghostState, pruneLocalghostActivity, readLocalghostActivity, readLocalghostProjectConfig, readLocalghostState, redactRelayHeaders, redactRelayLogUrl, registerLocalghostRun, registerLocalghostSetup, removeManagedBlock, removeSystemHosts, renderCaddyfile, renderHostsBlock, renderRelayOfflineResponse, resolveLocalghostContext, runCaddy, runDoctor, shouldNotifyAboutUpdate, signRelayRouteClaim, startCaddy, stripRelayForwardHeaders, trustCaddy, unregisterLocalghostRun, unregisterLocalghostSetup, updateSystemHosts, upsertManagedBlock, validateCaddyfile, verifyRelayRouteClaim, writeCaddyfile, writeLocalghostActivity, writeLocalghostState };
|