@hamedb89/localghost 0.1.8 → 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 +158 -27
- package/apps/macos-widget/LocalghostWidget.entitlements +12 -0
- package/apps/macos-widget/LocalghostWidget.swift +701 -48
- 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 +8 -1
- 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 +524 -63
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +130 -5
- package/dist/index.js +761 -31
- package/dist/index.js.map +1 -1
- package/dist/tunnel-DzfLXZ8O.d.ts +126 -0
- package/dist/vite.d.ts +3 -1
- package/dist/vite.js +655 -36
- 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 +10 -4
- package/docs/macos-widget.md +68 -6
- package/package.json +6 -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;
|
|
@@ -72,6 +94,7 @@ type LocalghostContextOptions = {
|
|
|
72
94
|
primaryHost?: string;
|
|
73
95
|
dynamicPort?: boolean;
|
|
74
96
|
wwwAlias?: boolean;
|
|
97
|
+
ghostTunnel?: GhostTunnelOptions;
|
|
75
98
|
};
|
|
76
99
|
type LocalghostContext = {
|
|
77
100
|
cwd: string;
|
|
@@ -89,8 +112,18 @@ type LocalghostContext = {
|
|
|
89
112
|
primaryHost: string;
|
|
90
113
|
https: boolean;
|
|
91
114
|
wwwAlias: boolean;
|
|
115
|
+
ghostTunnel: GhostTunnelConfig;
|
|
92
116
|
projectConfigPath?: string;
|
|
93
117
|
};
|
|
118
|
+
type LocalghostProjectConfig = Omit<LocalghostContextOptions, "cwd" | "localghostConfig">;
|
|
119
|
+
type LocalghostProjectConfigResult = {
|
|
120
|
+
config: LocalghostProjectConfig;
|
|
121
|
+
path?: string;
|
|
122
|
+
};
|
|
123
|
+
declare function readLocalghostProjectConfig(options?: {
|
|
124
|
+
cwd?: string;
|
|
125
|
+
configFile?: string | false;
|
|
126
|
+
}): Promise<LocalghostProjectConfigResult>;
|
|
94
127
|
declare function defineLocalghostConfig<T extends LocalghostContextOptions>(config: T): T;
|
|
95
128
|
declare function resolveLocalghostContext(options?: LocalghostContextOptions): Promise<LocalghostContext>;
|
|
96
129
|
|
|
@@ -158,6 +191,92 @@ type FindAvailablePortOptions = {
|
|
|
158
191
|
declare function isPortAvailable(port: number, host?: string): Promise<boolean>;
|
|
159
192
|
declare function findAvailablePort(startPort: number, options?: FindAvailablePortOptions): Promise<number>;
|
|
160
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
|
+
|
|
161
280
|
type DomainRoute = {
|
|
162
281
|
host: string;
|
|
163
282
|
port: number;
|
|
@@ -167,8 +286,14 @@ type DomainRoute = {
|
|
|
167
286
|
type DomainRouteOptions = {
|
|
168
287
|
https?: boolean;
|
|
169
288
|
};
|
|
289
|
+
type GhostTunnelFormatOptions = {
|
|
290
|
+
color?: boolean;
|
|
291
|
+
label?: "configured" | "expected" | "ready" | "running";
|
|
292
|
+
verbose?: boolean;
|
|
293
|
+
};
|
|
170
294
|
declare function getDomainRoutes(entries: DevHostEntry[], options?: DomainRouteOptions): DomainRoute[];
|
|
171
295
|
declare function formatDomainRoutes(entries: DevHostEntry[], options?: DomainRouteOptions): string;
|
|
296
|
+
declare function formatGhostTunnel(config: GhostTunnelConfig, options?: GhostTunnelFormatOptions): string | null;
|
|
172
297
|
|
|
173
298
|
declare const LOCALGHOST_STATE_FILE = "ops/local/localghost-state.json";
|
|
174
299
|
type LocalghostStateAction = "setup" | "teardown";
|
|
@@ -196,7 +321,7 @@ declare function writeLocalghostState(cwd: string, state: WriteLocalghostStateIn
|
|
|
196
321
|
declare function patchLocalghostState(cwd: string, patch: Partial<WriteLocalghostStateInput>): string | null;
|
|
197
322
|
|
|
198
323
|
declare const LOCALGHOST_PACKAGE_NAME = "@hamedb89/localghost";
|
|
199
|
-
declare const LOCALGHOST_VERSION = "0.1.
|
|
324
|
+
declare const LOCALGHOST_VERSION = "0.1.9";
|
|
200
325
|
declare const UPDATE_CHECK_CACHE_TTL_MS: number;
|
|
201
326
|
declare const UPDATE_CHECK_NOTIFY_TTL_MS: number;
|
|
202
327
|
declare const UPDATE_CHECK_TIMEOUT_MS = 900;
|
|
@@ -233,4 +358,4 @@ declare function maybeNotifyAboutUpdate(options?: {
|
|
|
233
358
|
disabled?: boolean;
|
|
234
359
|
}): Promise<void>;
|
|
235
360
|
|
|
236
|
-
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, patchLocalghostState, pruneLocalghostActivity, readLocalghostActivity, readLocalghostState, registerLocalghostRun, removeManagedBlock, removeSystemHosts, renderCaddyfile, renderHostsBlock, resolveLocalghostContext, runCaddy, runDoctor, shouldNotifyAboutUpdate, startCaddy, trustCaddy, 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 };
|