devframe 0.0.0 → 0.1.16

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.
Files changed (73) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +62 -0
  3. package/dist/_shared-CU6dE-VX.mjs +20 -0
  4. package/dist/adapters/build.d.mts +37 -0
  5. package/dist/adapters/build.mjs +61 -0
  6. package/dist/adapters/cli.d.mts +35 -0
  7. package/dist/adapters/cli.mjs +357 -0
  8. package/dist/adapters/embedded.d.mts +19 -0
  9. package/dist/adapters/embedded.mjs +15 -0
  10. package/dist/adapters/kit.d.mts +23 -0
  11. package/dist/adapters/kit.mjs +16 -0
  12. package/dist/adapters/mcp.d.mts +39 -0
  13. package/dist/adapters/mcp.mjs +278 -0
  14. package/dist/adapters/vite.d.mts +32 -0
  15. package/dist/adapters/vite.mjs +31 -0
  16. package/dist/client/index.d.mts +227 -0
  17. package/dist/client/index.mjs +2 -0
  18. package/dist/client-4WrEozlH.mjs +1561 -0
  19. package/dist/constants.d.mts +20 -0
  20. package/dist/constants.mjs +34 -0
  21. package/dist/context-BrePWeyd.mjs +6776 -0
  22. package/dist/define-Bb4zh-Dc.mjs +11 -0
  23. package/dist/devtool-OJ3QW0ns.d.mts +1125 -0
  24. package/dist/helpers/nuxt/index.d.mts +46 -0
  25. package/dist/helpers/nuxt/index.mjs +58 -0
  26. package/dist/helpers/nuxt/runtime/plugin.client.d.mts +8 -0
  27. package/dist/helpers/nuxt/runtime/plugin.client.mjs +12 -0
  28. package/dist/human-id-CHS0s28X.mjs +844 -0
  29. package/dist/immer-HjMAm3b6.mjs +894 -0
  30. package/dist/index-DvKDO5H8.d.mts +333 -0
  31. package/dist/index.d.mts +10 -0
  32. package/dist/index.mjs +2 -0
  33. package/dist/main-DpINGndA.mjs +601 -0
  34. package/dist/node/index.d.mts +365 -0
  35. package/dist/node/index.mjs +69 -0
  36. package/dist/open-BtOOEldu.mjs +533 -0
  37. package/dist/recipes/open-helpers.d.mts +104 -0
  38. package/dist/recipes/open-helpers.mjs +69 -0
  39. package/dist/rpc/client.d.mts +9 -0
  40. package/dist/rpc/client.mjs +13 -0
  41. package/dist/rpc/index.d.mts +2 -0
  42. package/dist/rpc/index.mjs +3 -0
  43. package/dist/rpc/server.d.mts +8 -0
  44. package/dist/rpc/server.mjs +10 -0
  45. package/dist/rpc/transports/ws-client.d.mts +2 -0
  46. package/dist/rpc/transports/ws-client.mjs +43 -0
  47. package/dist/rpc/transports/ws-server.d.mts +2 -0
  48. package/dist/rpc/transports/ws-server.mjs +58 -0
  49. package/dist/rpc-9FNa3Inb.mjs +474 -0
  50. package/dist/server-DrBxa6ZV.mjs +49 -0
  51. package/dist/src-BoIqXRc9.mjs +85 -0
  52. package/dist/static-dump-CQUC1aIW.mjs +82 -0
  53. package/dist/transports-BPUzHhI2.mjs +15 -0
  54. package/dist/types/index.d.mts +4 -0
  55. package/dist/types/index.mjs +6 -0
  56. package/dist/utils/events.d.mts +9 -0
  57. package/dist/utils/events.mjs +40 -0
  58. package/dist/utils/human-id.d.mts +10 -0
  59. package/dist/utils/human-id.mjs +3 -0
  60. package/dist/utils/nanoid.d.mts +4 -0
  61. package/dist/utils/nanoid.mjs +10 -0
  62. package/dist/utils/promise.d.mts +8 -0
  63. package/dist/utils/promise.mjs +15 -0
  64. package/dist/utils/shared-state.d.mts +2 -0
  65. package/dist/utils/shared-state.mjs +36 -0
  66. package/dist/utils/state.d.mts +49 -0
  67. package/dist/utils/state.mjs +26 -0
  68. package/dist/utils/when.d.mts +2 -0
  69. package/dist/utils/when.mjs +424 -0
  70. package/dist/when-CGLewRtm.d.mts +401 -0
  71. package/dist/ws-client-CklfxUHE.d.mts +17 -0
  72. package/dist/ws-server--IuUAaGi.d.mts +37 -0
  73. package/package.json +116 -8
@@ -0,0 +1,365 @@
1
+ import { $ as DevToolsLogsHost$1, A as DevToolsViewHost$1, At as AgentHandle, Ct as DevToolsCommandHandle, Et as DevToolsCommandsHost$1, F as DevToolsChildProcessTerminalSession, Ft as AgentTool, H as DevToolsRpcClientFunctions, I as DevToolsTerminalHost$1, It as AgentToolInput, J as DevToolsLogEntryInput, K as DevToolsLogEntry, L as DevToolsTerminalSession, Lt as DevToolsAgentHost$1, M as PartialWithoutId, Mt as AgentResource, Nt as AgentResourceContent, Ot as DevToolsServerCommandEntry, P as DevToolsChildProcessExecuteOptions, Pt as AgentResourceInput, R as DevToolsTerminalSessionBase, Rt as DevToolsAgentHostEvents, U as DevToolsRpcServerFunctions, V as DevToolsDocksUserSettings, X as DevToolsLogHandle, ct as DevToolsDockUserEntry, d as DevToolsNodeContext, et as DevToolsHost, g as RpcFunctionsHost$1, h as RpcBroadcastOptions, jt as AgentManifest, kt as DevToolsServerCommandInput, m as DevToolsNodeRpcSession, rt as DevToolsDockEntry, st as DevToolsDockHost$1, tt as ClientScriptEntry, v as RpcSharedStateHost, w as SharedState, zt as EventEmitter } from "../devtool-OJ3QW0ns.mjs";
2
+ import { E as RpcFunctionDefinitionAny, u as RpcFunctionsCollectorBase } from "../index-DvKDO5H8.mjs";
3
+ import { BirpcGroup } from "birpc";
4
+ import { WebSocketServer } from "ws";
5
+ import { AsyncLocalStorage } from "node:async_hooks";
6
+ import { App } from "h3";
7
+
8
+ //#region src/node/context-internal.d.ts
9
+ interface InternalAnonymousAuthStorage {
10
+ trusted: Record<string, {
11
+ authToken: string;
12
+ ua: string;
13
+ origin: string;
14
+ timestamp: number;
15
+ } | undefined>;
16
+ }
17
+ interface RemoteTokenRecord {
18
+ dockId: string;
19
+ /** Dock URL origin — matched against WS handshake `Origin` header when `originLock` is on. */
20
+ origin: string;
21
+ originLock: boolean;
22
+ }
23
+ interface DevToolsInternalContext {
24
+ storage: {
25
+ auth: SharedState<InternalAnonymousAuthStorage>;
26
+ };
27
+ /**
28
+ * Revoke an auth token: remove from storage and notify all connected clients
29
+ * using this token that they are no longer trusted.
30
+ */
31
+ revokeAuthToken: (token: string) => Promise<void>;
32
+ /**
33
+ * Session-only tokens issued to remote-UI iframe docks. Not persisted —
34
+ * regenerated on every dev-server restart.
35
+ */
36
+ remoteTokens: Map<string, RemoteTokenRecord>;
37
+ allocateRemoteToken: (dockId: string, origin: string, originLock: boolean) => string;
38
+ revokeRemoteToken: (token: string) => void;
39
+ revokeRemoteTokensForDock: (dockId: string) => void;
40
+ /**
41
+ * Returns true if `token` is a valid remote token and, when `originLock` is
42
+ * on, `requestOrigin` matches the recorded dock origin.
43
+ */
44
+ isRemoteTokenTrusted: (token: string, requestOrigin?: string) => boolean;
45
+ /**
46
+ * Populated by `createWsServer` once the WS port is bound. Consumed by the
47
+ * docks host when enriching remote iframe URLs with a connection descriptor.
48
+ */
49
+ wsEndpoint?: {
50
+ /** Full `ws://` or `wss://` URL with host and port. */url: string;
51
+ };
52
+ }
53
+ declare const internalContextMap: WeakMap<DevToolsNodeContext, DevToolsInternalContext>;
54
+ declare function getInternalContext(context: DevToolsNodeContext): DevToolsInternalContext;
55
+ //#endregion
56
+ //#region src/node/auth-revoke.d.ts
57
+ /**
58
+ * Flip `isTrusted` to false on any live WS clients connected with `token`
59
+ * and broadcast the `auth:revoked` event so they can react.
60
+ *
61
+ * Shared between persisted-auth revocation and remote-dock token revocation.
62
+ */
63
+ declare function revokeActiveConnectionsForToken(context: DevToolsNodeContext, token: string): Promise<void>;
64
+ /**
65
+ * Revoke an auth token: remove from storage and notify all connected clients
66
+ * using this token that they are no longer trusted.
67
+ */
68
+ declare function revokeAuthToken(context: DevToolsNodeContext, storage: SharedState<InternalAnonymousAuthStorage>, token: string): Promise<void>;
69
+ //#endregion
70
+ //#region src/node/auth-state.d.ts
71
+ interface PendingAuthRequest {
72
+ clientAuthToken: string;
73
+ session: DevToolsNodeRpcSession;
74
+ ua: string;
75
+ origin: string;
76
+ resolve: (result: {
77
+ isTrusted: boolean;
78
+ }) => void;
79
+ abortController: AbortController;
80
+ timeout: ReturnType<typeof setTimeout>;
81
+ }
82
+ declare function getTempAuthToken(): string;
83
+ declare function refreshTempAuthToken(): string;
84
+ declare function getPendingAuth(): PendingAuthRequest | null;
85
+ declare function setPendingAuth(request: PendingAuthRequest | null): void;
86
+ /**
87
+ * Abort and clean up any existing pending auth request.
88
+ */
89
+ declare function abortPendingAuth(): void;
90
+ /**
91
+ * Consume the temp auth ID: verify it matches, trust the pending client, and clean up.
92
+ * Returns the client's authToken if successful, null otherwise.
93
+ */
94
+ declare function consumeTempAuthToken(id: string, storage: SharedState<InternalAnonymousAuthStorage>): string | null;
95
+ //#endregion
96
+ //#region src/node/context.d.ts
97
+ interface CreateHostContextOptions {
98
+ cwd: string;
99
+ workspaceRoot?: string;
100
+ mode: 'dev' | 'build';
101
+ host: DevToolsHost;
102
+ /**
103
+ * Built-in RPC declarations to register on the host. Framework
104
+ * adapters (vite, rolldown, cli) can pass the ones they need; the
105
+ * host itself has no opinions about the built-in set.
106
+ */
107
+ builtinRpcDeclarations?: readonly RpcFunctionDefinitionAny[];
108
+ }
109
+ /**
110
+ * Framework-neutral core of the DevTools node context. Wires the six
111
+ * host subsystems, the JSON-render factory, and the standard shared-state
112
+ * bookkeeping. Framework-specific extensions (Vite plugin scan, Vite
113
+ * config/server fields, built-in RPCs like `open-in-editor`) layer on
114
+ * top via wrapper functions such as kit's `createDevToolsContext`.
115
+ */
116
+ declare function createHostContext(options: CreateHostContextOptions): Promise<DevToolsNodeContext>;
117
+ //#endregion
118
+ //#region src/node/context-utils.d.ts
119
+ declare const ContextUtils: {
120
+ createSimpleClientScript(fn: string | ((ctx: any) => void)): ClientScriptEntry;
121
+ };
122
+ //#endregion
123
+ //#region src/node/host-agent.d.ts
124
+ /**
125
+ * Framework-neutral host aggregating the agent-exposed surface of a
126
+ * devtool. Auto-discovers RPC functions with an `agent` field from
127
+ * `ctx.rpc.definitions`, and accepts plugin-registered tools /
128
+ * resources via `registerTool` / `registerResource`.
129
+ *
130
+ * @experimental
131
+ */
132
+ declare class DevToolsAgentHost implements DevToolsAgentHost$1 {
133
+ readonly context: DevToolsNodeContext;
134
+ readonly events: EventEmitter<DevToolsAgentHostEvents>;
135
+ private readonly tools;
136
+ private readonly resources;
137
+ private _rpcUnsubscribe;
138
+ constructor(context: DevToolsNodeContext);
139
+ registerTool(input: AgentToolInput): AgentHandle;
140
+ unregisterTool(id: string): boolean;
141
+ registerResource(input: AgentResourceInput): AgentHandle;
142
+ unregisterResource(id: string): boolean;
143
+ list(): AgentManifest;
144
+ getTool(id: string): AgentTool | undefined;
145
+ getResource(id: string): AgentResource | undefined;
146
+ invoke(id: string, args: unknown): Promise<unknown>;
147
+ read(id: string): Promise<AgentResourceContent>;
148
+ /** @internal */
149
+ _dispose(): void;
150
+ private _validateToolId;
151
+ private _projectTool;
152
+ private _collectRpcTools;
153
+ private _findRpcDefinition;
154
+ private _coercePositionalArgs;
155
+ }
156
+ //#endregion
157
+ //#region src/node/host-commands.d.ts
158
+ declare class DevToolsCommandsHost implements DevToolsCommandsHost$1 {
159
+ readonly context: DevToolsNodeContext;
160
+ readonly commands: DevToolsCommandsHost$1['commands'];
161
+ readonly events: DevToolsCommandsHost$1['events'];
162
+ constructor(context: DevToolsNodeContext);
163
+ register(command: DevToolsServerCommandInput): DevToolsCommandHandle;
164
+ unregister(id: string): boolean;
165
+ execute(id: string, ...args: any[]): Promise<unknown>;
166
+ list(): DevToolsServerCommandEntry[];
167
+ private findCommand;
168
+ private toSerializable;
169
+ }
170
+ //#endregion
171
+ //#region src/node/host-docks.d.ts
172
+ declare class DevToolsDockHost implements DevToolsDockHost$1 {
173
+ readonly context: DevToolsNodeContext;
174
+ readonly views: DevToolsDockHost$1['views'];
175
+ readonly events: DevToolsDockHost$1['events'];
176
+ userSettings: SharedState<DevToolsDocksUserSettings>;
177
+ /** Dock-id → allocated remote token + resolved options. */
178
+ private readonly remoteDocks;
179
+ constructor(context: DevToolsNodeContext);
180
+ init(): Promise<void>;
181
+ values({
182
+ includeBuiltin
183
+ }?: {
184
+ includeBuiltin?: boolean;
185
+ }): DevToolsDockEntry[];
186
+ private projectView;
187
+ private resolveDevServerOrigin;
188
+ register<T extends DevToolsDockUserEntry>(view: T, force?: boolean): {
189
+ update: (patch: Partial<T>) => void;
190
+ };
191
+ update(view: DevToolsDockUserEntry): void;
192
+ private prepareRemoteRegistration;
193
+ }
194
+ //#endregion
195
+ //#region src/node/host-functions.d.ts
196
+ declare class RpcFunctionsHost extends RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> implements RpcFunctionsHost$1 {
197
+ /**
198
+ * @internal
199
+ */
200
+ _rpcGroup: BirpcGroup<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
201
+ _asyncStorage: AsyncLocalStorage<DevToolsNodeRpcSession>;
202
+ constructor(context: DevToolsNodeContext);
203
+ sharedState: RpcSharedStateHost;
204
+ invokeLocal<T extends keyof DevToolsRpcServerFunctions, Args extends Parameters<DevToolsRpcServerFunctions[T]>>(method: T, ...args: Args): Promise<Awaited<ReturnType<DevToolsRpcServerFunctions[T]>>>;
205
+ broadcast<T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>): Promise<void>;
206
+ getCurrentRpcSession(): DevToolsNodeRpcSession | undefined;
207
+ }
208
+ //#endregion
209
+ //#region src/node/host-h3.d.ts
210
+ interface CreateH3DevToolsHostOptions {
211
+ /** The h3 app instance — registered once the CLI adapter lands. */
212
+ app?: unknown;
213
+ /**
214
+ * Host the standalone server listens on, e.g. `http://localhost:9999`.
215
+ * Consumed by `resolveOrigin` for dock entries that need an absolute URL.
216
+ */
217
+ origin: string;
218
+ /**
219
+ * Register a static-file handler at `base` serving files from `distDir`.
220
+ * Wired into the h3 app once the CLI adapter lands (commit 5). For now
221
+ * the CLI isn't running, so the default is a no-op.
222
+ */
223
+ mount?: (base: string, distDir: string) => void | Promise<void>;
224
+ }
225
+ /**
226
+ * h3-backed {@link DevToolsHost} — used by the standalone CLI adapter.
227
+ * This commit adds the shell; the CLI adapter in commit 5 wires it up
228
+ * with a real h3 app and sirv handler.
229
+ */
230
+ declare function createH3DevToolsHost(options: CreateH3DevToolsHostOptions): DevToolsHost;
231
+ //#endregion
232
+ //#region src/node/host-logs.d.ts
233
+ declare class DevToolsLogsHost implements DevToolsLogsHost$1 {
234
+ readonly context: DevToolsNodeContext;
235
+ readonly entries: DevToolsLogsHost$1['entries'];
236
+ readonly events: DevToolsLogsHost$1['events'];
237
+ /** Tracks when each entry was last added or updated (monotonic) */
238
+ readonly lastModified: Map<string, number>;
239
+ /** Tracks recently removed entry IDs with their removal time */
240
+ readonly removals: Array<{
241
+ id: string;
242
+ time: number;
243
+ }>;
244
+ private _autoDeleteTimers;
245
+ private _clock;
246
+ private _tick;
247
+ constructor(context: DevToolsNodeContext);
248
+ add(input: DevToolsLogEntryInput): Promise<DevToolsLogHandle>;
249
+ update(id: string, patch: Partial<DevToolsLogEntryInput>): Promise<DevToolsLogEntry | undefined>;
250
+ remove(id: string): Promise<void>;
251
+ clear(): Promise<void>;
252
+ private _createHandle;
253
+ }
254
+ //#endregion
255
+ //#region src/node/host-terminals.d.ts
256
+ declare class DevToolsTerminalHost implements DevToolsTerminalHost$1 {
257
+ readonly context: DevToolsNodeContext;
258
+ readonly sessions: DevToolsTerminalHost$1['sessions'];
259
+ readonly events: DevToolsTerminalHost$1['events'];
260
+ private _boundStreams;
261
+ constructor(context: DevToolsNodeContext);
262
+ register(session: DevToolsTerminalSession): DevToolsTerminalSession;
263
+ update(patch: PartialWithoutId<DevToolsTerminalSession>): void;
264
+ remove(session: DevToolsTerminalSession): void;
265
+ private bindStream;
266
+ startChildProcess(executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>): Promise<DevToolsChildProcessTerminalSession>;
267
+ }
268
+ //#endregion
269
+ //#region src/node/host-views.d.ts
270
+ declare class DevToolsViewHost implements DevToolsViewHost$1 {
271
+ readonly context: DevToolsNodeContext;
272
+ /**
273
+ * @internal
274
+ */
275
+ buildStaticDirs: {
276
+ baseUrl: string;
277
+ distDir: string;
278
+ }[];
279
+ constructor(context: DevToolsNodeContext);
280
+ hostStatic(baseUrl: string, distDir: string): void;
281
+ }
282
+ //#endregion
283
+ //#region src/node/rpc-shared-state.d.ts
284
+ declare function createRpcSharedStateServerHost(rpc: RpcFunctionsHost$1): RpcSharedStateHost;
285
+ //#endregion
286
+ //#region src/node/server.d.ts
287
+ interface StartHttpAndWsOptions {
288
+ context: DevToolsNodeContext;
289
+ host?: string;
290
+ port: number;
291
+ /**
292
+ * Optional h3 app to mount on. When omitted a fresh one is created;
293
+ * when provided, callers can add their own routes (sirv etc.) first.
294
+ */
295
+ app?: App;
296
+ /**
297
+ * When `false`, the RPC server is started without a trust handshake.
298
+ * Intended for single-user localhost tools where an auth round-trip
299
+ * would only get in the way. The Vite-flavoured auth layer in
300
+ * `@vitejs/devtools` already honors the equivalent
301
+ * `devtools.clientAuth` setting; devframe records the intent here so
302
+ * future auth plumbing can consult it without another API change.
303
+ *
304
+ * Default: `true`.
305
+ */
306
+ auth?: boolean;
307
+ /**
308
+ * Called once the WS server is bound so callers can mount static
309
+ * handlers whose origin depends on the resolved port, or print their
310
+ * own startup banner. Devframe does not print one itself.
311
+ */
312
+ onReady?: (info: {
313
+ origin: string;
314
+ port: number;
315
+ app: App;
316
+ }) => void | Promise<void>;
317
+ }
318
+ interface StartedServer {
319
+ /** Listening origin, e.g. `http://localhost:9999`. */
320
+ origin: string;
321
+ port: number;
322
+ app: App;
323
+ wss: WebSocketServer;
324
+ rpcGroup: BirpcGroup<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
325
+ close: () => Promise<void>;
326
+ }
327
+ /**
328
+ * Compose an h3 + WebSocket server for a devtool context. The RPC
329
+ * group is bound to `context.rpc.functions`; the WS endpoint lives on
330
+ * the same port as the HTTP server.
331
+ */
332
+ declare function startHttpAndWs(options: StartHttpAndWsOptions): Promise<StartedServer>;
333
+ //#endregion
334
+ //#region src/node/static-dump.d.ts
335
+ interface StaticRpcDumpManifestStaticEntry {
336
+ type: 'static';
337
+ path: string;
338
+ }
339
+ interface StaticRpcDumpManifestQueryEntry {
340
+ type: 'query';
341
+ records: Record<string, string>;
342
+ fallback?: string;
343
+ }
344
+ type StaticRpcDumpManifestValue = StaticRpcDumpManifestStaticEntry | StaticRpcDumpManifestQueryEntry | any;
345
+ type StaticRpcDumpManifest = Record<string, StaticRpcDumpManifestValue>;
346
+ interface StaticRpcDumpCollection {
347
+ manifest: StaticRpcDumpManifest;
348
+ files: Record<string, any>;
349
+ }
350
+ declare function collectStaticRpcDump(definitions: Iterable<RpcFunctionDefinitionAny>, context: any): Promise<StaticRpcDumpCollection>;
351
+ //#endregion
352
+ //#region src/node/storage.d.ts
353
+ interface CreateStorageOptions<T extends object> {
354
+ filepath: string;
355
+ initialValue: T;
356
+ mergeInitialValue?: false | ((initialValue: T, savedValue: T) => T);
357
+ debounce?: number;
358
+ }
359
+ declare function createStorage<T extends object>(options: CreateStorageOptions<T>): SharedState<T>;
360
+ //#endregion
361
+ //#region src/node/utils.d.ts
362
+ declare function isObject(value: unknown): value is Record<string, any>;
363
+ declare function normalizeHttpServerUrl(host: string, port: number | string): string;
364
+ //#endregion
365
+ export { ContextUtils, CreateH3DevToolsHostOptions, CreateHostContextOptions, CreateStorageOptions, DevToolsAgentHost, DevToolsCommandsHost, DevToolsDockHost, DevToolsInternalContext, DevToolsLogsHost, DevToolsTerminalHost, DevToolsViewHost, InternalAnonymousAuthStorage, PendingAuthRequest, RemoteTokenRecord, RpcFunctionsHost, StartHttpAndWsOptions, StartedServer, StaticRpcDumpCollection, StaticRpcDumpManifest, StaticRpcDumpManifestQueryEntry, StaticRpcDumpManifestStaticEntry, StaticRpcDumpManifestValue, abortPendingAuth, collectStaticRpcDump, consumeTempAuthToken, createH3DevToolsHost, createHostContext, createRpcSharedStateServerHost, createStorage, getInternalContext, getPendingAuth, getTempAuthToken, internalContextMap, isObject, normalizeHttpServerUrl, refreshTempAuthToken, revokeActiveConnectionsForToken, revokeAuthToken, setPendingAuth, startHttpAndWs };
@@ -0,0 +1,69 @@
1
+ import { t as import_dist } from "../human-id-CHS0s28X.mjs";
2
+ import { a as RpcFunctionsHost, c as getInternalContext, d as DevToolsCommandsHost, f as DevToolsAgentHost, g as revokeAuthToken, h as revokeActiveConnectionsForToken, i as DevToolsLogsHost, l as internalContextMap, m as ContextUtils, n as DevToolsViewHost, o as createRpcSharedStateServerHost, r as DevToolsTerminalHost, s as DevToolsDockHost, t as createHostContext, u as createStorage } from "../context-BrePWeyd.mjs";
3
+ import { n as createH3DevToolsHost, t as collectStaticRpcDump } from "../static-dump-CQUC1aIW.mjs";
4
+ import { t as startHttpAndWs } from "../server-DrBxa6ZV.mjs";
5
+ import { isIP } from "node:net";
6
+ //#region src/node/auth-state.ts
7
+ let pendingAuth = null;
8
+ let tempAuthToken = generateTempId();
9
+ function generateTempId() {
10
+ return (0, import_dist.humanId)({
11
+ separator: "-",
12
+ capitalize: false
13
+ });
14
+ }
15
+ function getTempAuthToken() {
16
+ return tempAuthToken;
17
+ }
18
+ function refreshTempAuthToken() {
19
+ tempAuthToken = generateTempId();
20
+ return tempAuthToken;
21
+ }
22
+ function getPendingAuth() {
23
+ return pendingAuth;
24
+ }
25
+ function setPendingAuth(request) {
26
+ pendingAuth = request;
27
+ }
28
+ /**
29
+ * Abort and clean up any existing pending auth request.
30
+ */
31
+ function abortPendingAuth() {
32
+ if (pendingAuth) {
33
+ pendingAuth.abortController.abort();
34
+ clearTimeout(pendingAuth.timeout);
35
+ pendingAuth = null;
36
+ }
37
+ }
38
+ /**
39
+ * Consume the temp auth ID: verify it matches, trust the pending client, and clean up.
40
+ * Returns the client's authToken if successful, null otherwise.
41
+ */
42
+ function consumeTempAuthToken(id, storage) {
43
+ if (id !== tempAuthToken || !pendingAuth) return null;
44
+ const { clientAuthToken, session, ua, origin, resolve } = pendingAuth;
45
+ storage.mutate((state) => {
46
+ state.trusted[clientAuthToken] = {
47
+ authToken: clientAuthToken,
48
+ ua,
49
+ origin,
50
+ timestamp: Date.now()
51
+ };
52
+ });
53
+ session.meta.clientAuthToken = clientAuthToken;
54
+ session.meta.isTrusted = true;
55
+ resolve({ isTrusted: true });
56
+ abortPendingAuth();
57
+ refreshTempAuthToken();
58
+ return clientAuthToken;
59
+ }
60
+ //#endregion
61
+ //#region src/node/utils.ts
62
+ function isObject(value) {
63
+ return Object.prototype.toString.call(value) === "[object Object]";
64
+ }
65
+ function normalizeHttpServerUrl(host, port) {
66
+ return `http://${host === "127.0.0.1" ? "localhost" : isIP(host) === 6 ? `[${host}]` : host}:${port}`;
67
+ }
68
+ //#endregion
69
+ export { ContextUtils, DevToolsAgentHost, DevToolsCommandsHost, DevToolsDockHost, DevToolsLogsHost, DevToolsTerminalHost, DevToolsViewHost, RpcFunctionsHost, abortPendingAuth, collectStaticRpcDump, consumeTempAuthToken, createH3DevToolsHost, createHostContext, createRpcSharedStateServerHost, createStorage, getInternalContext, getPendingAuth, getTempAuthToken, internalContextMap, isObject, normalizeHttpServerUrl, refreshTempAuthToken, revokeActiveConnectionsForToken, revokeAuthToken, setPendingAuth, startHttpAndWs };