devframe 0.9.0-beta.3 → 0.9.0-beta.5

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 (65) hide show
  1. package/dist/{_shared-CGPVmXUM.mjs → _shared-CKZPvSrN.mjs} +2 -1
  2. package/dist/{_shared-Bm8p4-fD.d.mts → _shared-QkI6ljJS.d.mts} +2 -2
  3. package/dist/adapters/build.d.mts +10 -12
  4. package/dist/adapters/build.mjs +23 -27
  5. package/dist/adapters/cac.d.mts +1 -1
  6. package/dist/adapters/cac.mjs +3 -4
  7. package/dist/adapters/dev.d.mts +19 -5
  8. package/dist/adapters/dev.mjs +2 -2
  9. package/dist/adapters/embedded.d.mts +1 -1
  10. package/dist/adapters/initiate.d.mts +4 -3
  11. package/dist/adapters/initiate.mjs +1 -1
  12. package/dist/adapters/mcp.d.mts +1 -1
  13. package/dist/adapters/mcp.mjs +1 -1
  14. package/dist/cli/main.mjs +2 -2
  15. package/dist/client/index.d.mts +1 -1
  16. package/dist/client/index.mjs +2 -1175
  17. package/dist/constants.d.mts +1 -2
  18. package/dist/constants.mjs +1 -2
  19. package/dist/{context-DV4uWieM.d.mts → context-CQkRTbAc.d.mts} +1 -1
  20. package/dist/{context-b6iSomtv.mjs → context-D0HD0F7C.mjs} +19 -7
  21. package/dist/{context-CMSryXs-.mjs → context-D0jErmlx.mjs} +1 -1
  22. package/dist/{dev-4xjiynUD.mjs → dev-QEuT8SOF.mjs} +15 -9
  23. package/dist/{devframe-5oblos7I.d.mts → devframe-Cfx6doi4.d.mts} +41 -64
  24. package/dist/{diagnostics-C7IGWppM.mjs → diagnostics-DEuH3P5O.mjs} +32 -0
  25. package/dist/{host-agent-BBkKT27Q.mjs → host-agent-C5HjzfBz.mjs} +41 -3
  26. package/dist/{host-h3-CzCZwtuV.mjs → host-h3-Crkzm42q.mjs} +2 -2
  27. package/dist/{http-Z0w9baEe.mjs → http-CVwj7b4g.mjs} +2 -2
  28. package/dist/{index-BzDl02lt.d.mts → index-MYi1SZVL.d.mts} +2 -2
  29. package/dist/index.d.mts +3 -2
  30. package/dist/{instance-registry-Du_hbx-j.mjs → instance-registry-M2p-z6xE.mjs} +1 -1
  31. package/dist/{instance-shell-B0TwOxCl.mjs → instance-shell-DJ8s-MFw.mjs} +5 -5
  32. package/dist/{instance-shell-B-BSVp37.d.mts → instance-shell-D_UA0Idz.d.mts} +2 -2
  33. package/dist/internal/index.d.mts +72 -10
  34. package/dist/internal/index.mjs +7 -7
  35. package/dist/node/auth.d.mts +2 -2
  36. package/dist/node/auth.mjs +1 -1
  37. package/dist/node/hub-internals.d.mts +2 -2
  38. package/dist/node/hub-internals.mjs +2 -2
  39. package/dist/node/index.d.mts +1 -1
  40. package/dist/node/index.mjs +2 -2
  41. package/dist/recipes/common-rpc-functions.d.mts +1 -1
  42. package/dist/recipes/interactive-auth.d.mts +2 -2
  43. package/dist/recipes/interactive-auth.mjs +2 -2
  44. package/dist/remote-assets-DclsYyoL.d.mts +106 -0
  45. package/dist/rpc/transports/ws-bun.d.mts +1 -1
  46. package/dist/{rpc-core-B4Qm66Qt.d.mts → rpc-core-C8JQ3p7A.d.mts} +2 -2
  47. package/dist/{rpc-core-Cva-0pw0.mjs → rpc-core-IhcWl_xn.mjs} +1 -1
  48. package/dist/state-Cc1IeSmQ.mjs +1291 -0
  49. package/dist/storage-BVuipbGS.mjs +137 -0
  50. package/dist/types/index.d.mts +3 -2
  51. package/dist/utils/events.d.mts +1 -1
  52. package/dist/utils/open.d.mts +2 -10
  53. package/dist/utils/open.mjs +56 -1
  54. package/dist/utils/remote-assets.d.mts +15 -0
  55. package/dist/utils/remote-assets.mjs +309 -0
  56. package/dist/utils/serve-static.d.mts +13 -5
  57. package/dist/utils/serve-static.mjs +103 -9
  58. package/dist/utils/shared-state.d.mts +1 -1
  59. package/dist/utils/streaming-channel.d.mts +1 -1
  60. package/package.json +2 -3
  61. package/skills/devframe/SKILL.md +4 -5
  62. package/dist/open-Dz4V4irZ.mjs +0 -547
  63. package/dist/state-BeUHDDjk.mjs +0 -108
  64. package/dist/storage-CaUVrBrG.mjs +0 -1122
  65. package/skills/devframe/templates/spa-devframe.ts +0 -38
@@ -1,547 +0,0 @@
1
- import { promisify } from "node:util";
2
- import fs from "node:fs";
3
- import process from "node:process";
4
- import os from "node:os";
5
- import path from "node:path";
6
- import fs$1, { constants } from "node:fs/promises";
7
- import { fileURLToPath } from "node:url";
8
- import childProcess, { execFile } from "node:child_process";
9
- import { Buffer } from "node:buffer";
10
- //#region ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
11
- let isDockerCached;
12
- function hasDockerEnv() {
13
- try {
14
- fs.statSync("/.dockerenv");
15
- return true;
16
- } catch {
17
- return false;
18
- }
19
- }
20
- function hasDockerCGroup() {
21
- try {
22
- return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
23
- } catch {
24
- return false;
25
- }
26
- }
27
- function isDocker() {
28
- if (isDockerCached === void 0) isDockerCached = hasDockerEnv() || hasDockerCGroup();
29
- return isDockerCached;
30
- }
31
- //#endregion
32
- //#region ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
33
- let cachedResult;
34
- const hasContainerEnv = () => {
35
- try {
36
- fs.statSync("/run/.containerenv");
37
- return true;
38
- } catch {
39
- return false;
40
- }
41
- };
42
- function isInsideContainer() {
43
- if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
44
- return cachedResult;
45
- }
46
- //#endregion
47
- //#region ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
48
- const isWsl = () => {
49
- if (process.platform !== "linux") return false;
50
- if (os.release().toLowerCase().includes("microsoft")) {
51
- if (isInsideContainer()) return false;
52
- return true;
53
- }
54
- try {
55
- if (fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) return !isInsideContainer();
56
- } catch {}
57
- if (fs.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs.existsSync("/run/WSL")) return !isInsideContainer();
58
- return false;
59
- };
60
- var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
61
- //#endregion
62
- //#region ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
63
- const execFile$2 = promisify(childProcess.execFile);
64
- const powerShellPath$1 = () => `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
65
- const executePowerShell = async (command, options = {}) => {
66
- const { powerShellPath: psPath, ...execFileOptions } = options;
67
- const encodedCommand = executePowerShell.encodeCommand(command);
68
- return execFile$2(psPath ?? powerShellPath$1(), [...executePowerShell.argumentsPrefix, encodedCommand], {
69
- encoding: "utf8",
70
- ...execFileOptions
71
- });
72
- };
73
- executePowerShell.argumentsPrefix = [
74
- "-NoProfile",
75
- "-NonInteractive",
76
- "-ExecutionPolicy",
77
- "Bypass",
78
- "-EncodedCommand"
79
- ];
80
- executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
81
- executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
82
- //#endregion
83
- //#region ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
84
- function parseMountPointFromConfig(content) {
85
- for (const line of content.split("\n")) {
86
- if (/^\s*#/.test(line)) continue;
87
- const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
88
- if (!match) continue;
89
- return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
90
- }
91
- }
92
- //#endregion
93
- //#region ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
94
- const execFile$1 = promisify(childProcess.execFile);
95
- const wslDrivesMountPoint = (() => {
96
- const defaultMountPoint = "/mnt/";
97
- let mountPoint;
98
- return async function() {
99
- if (mountPoint) return mountPoint;
100
- const configFilePath = "/etc/wsl.conf";
101
- let isConfigFileExists = false;
102
- try {
103
- await fs$1.access(configFilePath, constants.F_OK);
104
- isConfigFileExists = true;
105
- } catch {}
106
- if (!isConfigFileExists) return defaultMountPoint;
107
- const parsedMountPoint = parseMountPointFromConfig(await fs$1.readFile(configFilePath, { encoding: "utf8" }));
108
- if (parsedMountPoint === void 0) return defaultMountPoint;
109
- mountPoint = parsedMountPoint;
110
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
111
- return mountPoint;
112
- };
113
- })();
114
- const powerShellPathFromWsl = async () => {
115
- return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
116
- };
117
- const powerShellPath = is_wsl_default ? powerShellPathFromWsl : powerShellPath$1;
118
- let canAccessPowerShellPromise;
119
- const canAccessPowerShell = async () => {
120
- canAccessPowerShellPromise ??= (async () => {
121
- try {
122
- const psPath = await powerShellPath();
123
- await fs$1.access(psPath, constants.X_OK);
124
- return true;
125
- } catch {
126
- return false;
127
- }
128
- })();
129
- return canAccessPowerShellPromise;
130
- };
131
- const wslDefaultBrowser = async () => {
132
- const psPath = await powerShellPath();
133
- const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
134
- return stdout.trim();
135
- };
136
- const convertWslPathToWindows = async (path) => {
137
- if (/^[a-z]+:\/\//i.test(path)) return path;
138
- try {
139
- const { stdout } = await execFile$1("wslpath", ["-aw", path], { encoding: "utf8" });
140
- return stdout.trim();
141
- } catch {
142
- return path;
143
- }
144
- };
145
- //#endregion
146
- //#region ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
147
- function defineLazyProperty(object, propertyName, valueGetter) {
148
- const define = (value) => Object.defineProperty(object, propertyName, {
149
- value,
150
- enumerable: true,
151
- writable: true
152
- });
153
- Object.defineProperty(object, propertyName, {
154
- configurable: true,
155
- enumerable: true,
156
- get() {
157
- const result = valueGetter();
158
- define(result);
159
- return result;
160
- },
161
- set(value) {
162
- define(value);
163
- }
164
- });
165
- return object;
166
- }
167
- //#endregion
168
- //#region ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
169
- const execFileAsync$3 = promisify(execFile);
170
- async function defaultBrowserId() {
171
- if (process.platform !== "darwin") throw new Error("macOS only");
172
- const { stdout } = await execFileAsync$3("defaults", [
173
- "read",
174
- "com.apple.LaunchServices/com.apple.launchservices.secure",
175
- "LSHandlers"
176
- ]);
177
- const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout)?.groups.id ?? "com.apple.Safari";
178
- if (browserId === "com.apple.safari") return "com.apple.Safari";
179
- return browserId;
180
- }
181
- //#endregion
182
- //#region ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
183
- const execFileAsync$2 = promisify(execFile);
184
- async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
185
- if (process.platform !== "darwin") throw new Error("macOS only");
186
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
187
- const execOptions = {};
188
- if (signal) execOptions.signal = signal;
189
- const { stdout } = await execFileAsync$2("osascript", [
190
- "-e",
191
- script,
192
- outputArguments
193
- ], execOptions);
194
- return stdout.trim();
195
- }
196
- //#endregion
197
- //#region ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
198
- async function bundleName(bundleId) {
199
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
200
- }
201
- //#endregion
202
- //#region ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
203
- const execFileAsync$1 = promisify(execFile);
204
- const windowsBrowserProgIds = {
205
- MSEdgeHTM: {
206
- name: "Edge",
207
- id: "com.microsoft.edge"
208
- },
209
- MSEdgeBHTML: {
210
- name: "Edge Beta",
211
- id: "com.microsoft.edge.beta"
212
- },
213
- MSEdgeDHTML: {
214
- name: "Edge Dev",
215
- id: "com.microsoft.edge.dev"
216
- },
217
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
218
- name: "Edge",
219
- id: "com.microsoft.edge.old"
220
- },
221
- ChromeHTML: {
222
- name: "Chrome",
223
- id: "com.google.chrome"
224
- },
225
- ChromeBHTML: {
226
- name: "Chrome Beta",
227
- id: "com.google.chrome.beta"
228
- },
229
- ChromeDHTML: {
230
- name: "Chrome Dev",
231
- id: "com.google.chrome.dev"
232
- },
233
- ChromiumHTM: {
234
- name: "Chromium",
235
- id: "org.chromium.Chromium"
236
- },
237
- BraveHTML: {
238
- name: "Brave",
239
- id: "com.brave.Browser"
240
- },
241
- BraveBHTML: {
242
- name: "Brave Beta",
243
- id: "com.brave.Browser.beta"
244
- },
245
- BraveDHTML: {
246
- name: "Brave Dev",
247
- id: "com.brave.Browser.dev"
248
- },
249
- BraveSSHTM: {
250
- name: "Brave Nightly",
251
- id: "com.brave.Browser.nightly"
252
- },
253
- FirefoxURL: {
254
- name: "Firefox",
255
- id: "org.mozilla.firefox"
256
- },
257
- OperaStable: {
258
- name: "Opera",
259
- id: "com.operasoftware.Opera"
260
- },
261
- VivaldiHTM: {
262
- name: "Vivaldi",
263
- id: "com.vivaldi.Vivaldi"
264
- },
265
- "IE.HTTP": {
266
- name: "Internet Explorer",
267
- id: "com.microsoft.ie"
268
- }
269
- };
270
- const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
271
- var UnknownBrowserError = class extends Error {};
272
- async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
273
- const { stdout } = await _execFileAsync("reg", [
274
- "QUERY",
275
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
276
- "/v",
277
- "ProgId"
278
- ]);
279
- const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
280
- if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
281
- const { id } = match.groups;
282
- const dotIndex = id.lastIndexOf(".");
283
- const hyphenIndex = id.lastIndexOf("-");
284
- const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
285
- const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
286
- return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
287
- name: id,
288
- id
289
- };
290
- }
291
- //#endregion
292
- //#region ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
293
- const execFileAsync = promisify(execFile);
294
- const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
295
- async function defaultBrowser() {
296
- if (process.platform === "darwin") {
297
- const id = await defaultBrowserId();
298
- return {
299
- name: await bundleName(id),
300
- id
301
- };
302
- }
303
- if (process.platform === "linux") {
304
- const { stdout } = await execFileAsync("xdg-mime", [
305
- "query",
306
- "default",
307
- "x-scheme-handler/http"
308
- ]);
309
- const id = stdout.trim();
310
- return {
311
- name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
312
- id
313
- };
314
- }
315
- if (process.platform === "win32") return defaultBrowser$1();
316
- throw new Error("Only macOS, Linux, and Windows are supported");
317
- }
318
- //#endregion
319
- //#region ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
320
- const isInSsh = Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
321
- //#endregion
322
- //#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
323
- const fallbackAttemptSymbol = Symbol("fallbackAttempt");
324
- const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
325
- const localXdgOpenPath = path.join(__dirname, "xdg-open");
326
- const { platform, arch } = process;
327
- const tryEachApp = async (apps, opener) => {
328
- if (apps.length === 0) return;
329
- const errors = [];
330
- for (const app of apps) try {
331
- return await opener(app);
332
- } catch (error) {
333
- errors.push(error);
334
- }
335
- throw new AggregateError(errors, "Failed to open in all supported apps");
336
- };
337
- const baseOpen = async (options) => {
338
- options = {
339
- wait: false,
340
- background: false,
341
- newInstance: false,
342
- allowNonzeroExitCode: false,
343
- ...options
344
- };
345
- const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
346
- delete options[fallbackAttemptSymbol];
347
- if (Array.isArray(options.app)) return tryEachApp(options.app, (singleApp) => baseOpen({
348
- ...options,
349
- app: singleApp,
350
- [fallbackAttemptSymbol]: true
351
- }));
352
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
353
- appArguments = [...appArguments];
354
- if (Array.isArray(app)) return tryEachApp(app, (appName) => baseOpen({
355
- ...options,
356
- app: {
357
- name: appName,
358
- arguments: appArguments
359
- },
360
- [fallbackAttemptSymbol]: true
361
- }));
362
- if (app === "browser" || app === "browserPrivate") {
363
- const ids = {
364
- "com.google.chrome": "chrome",
365
- "google-chrome.desktop": "chrome",
366
- "com.brave.browser": "brave",
367
- "org.mozilla.firefox": "firefox",
368
- "firefox.desktop": "firefox",
369
- "com.microsoft.msedge": "edge",
370
- "com.microsoft.edge": "edge",
371
- "com.microsoft.edgemac": "edge",
372
- "microsoft-edge.desktop": "edge",
373
- "com.apple.safari": "safari"
374
- };
375
- const flags = {
376
- chrome: "--incognito",
377
- brave: "--incognito",
378
- firefox: "--private-window",
379
- edge: "--inPrivate"
380
- };
381
- let browser;
382
- if (is_wsl_default) {
383
- const progId = await wslDefaultBrowser();
384
- browser = _windowsBrowserProgIdMap.get(progId) ?? {};
385
- } else browser = await defaultBrowser();
386
- if (browser.id in ids) {
387
- const browserName = ids[browser.id.toLowerCase()];
388
- if (app === "browserPrivate") {
389
- if (browserName === "safari") throw new Error("Safari doesn't support opening in private mode via command line");
390
- appArguments.push(flags[browserName]);
391
- }
392
- return baseOpen({
393
- ...options,
394
- app: {
395
- name: apps[browserName],
396
- arguments: appArguments
397
- }
398
- });
399
- }
400
- throw new Error(`${browser.name} is not supported as a default browser`);
401
- }
402
- let command;
403
- const cliArguments = [];
404
- const childProcessOptions = {};
405
- let shouldUseWindowsInWsl = false;
406
- if (is_wsl_default && !isInsideContainer() && !isInSsh && !app) shouldUseWindowsInWsl = await canAccessPowerShell();
407
- if (platform === "darwin") {
408
- command = "open";
409
- if (options.wait) cliArguments.push("--wait-apps");
410
- if (options.background) cliArguments.push("--background");
411
- if (options.newInstance) cliArguments.push("--new");
412
- if (app) cliArguments.push("-a", app);
413
- } else if (platform === "win32" || shouldUseWindowsInWsl) {
414
- command = await powerShellPath();
415
- cliArguments.push(...executePowerShell.argumentsPrefix);
416
- if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
417
- if (is_wsl_default && options.target) options.target = await convertWslPathToWindows(options.target);
418
- const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
419
- if (options.wait) encodedArguments.push("-Wait");
420
- if (app) {
421
- encodedArguments.push(executePowerShell.escapeArgument(app));
422
- if (options.target) appArguments.push(options.target);
423
- } else if (options.target) encodedArguments.push(executePowerShell.escapeArgument(options.target));
424
- if (appArguments.length > 0) {
425
- appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
426
- encodedArguments.push("-ArgumentList", appArguments.join(","));
427
- }
428
- options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
429
- if (!options.wait) childProcessOptions.stdio = "ignore";
430
- } else {
431
- if (app) command = app;
432
- else {
433
- const isBundled = !__dirname || __dirname === "/";
434
- let exeLocalXdgOpen = false;
435
- try {
436
- await fs$1.access(localXdgOpenPath, constants.X_OK);
437
- exeLocalXdgOpen = true;
438
- } catch {}
439
- command = process.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
440
- }
441
- if (appArguments.length > 0) cliArguments.push(...appArguments);
442
- if (!options.wait) {
443
- childProcessOptions.stdio = "ignore";
444
- childProcessOptions.detached = true;
445
- }
446
- }
447
- if (platform === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
448
- if (options.target) cliArguments.push(options.target);
449
- const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
450
- if (options.wait) return new Promise((resolve, reject) => {
451
- subprocess.once("error", reject);
452
- subprocess.once("close", (exitCode) => {
453
- if (!options.allowNonzeroExitCode && exitCode !== 0) {
454
- reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
455
- return;
456
- }
457
- resolve(subprocess);
458
- });
459
- });
460
- if (isFallbackAttempt) return new Promise((resolve, reject) => {
461
- subprocess.once("error", reject);
462
- subprocess.once("spawn", () => {
463
- subprocess.once("close", (exitCode) => {
464
- subprocess.off("error", reject);
465
- if (exitCode !== 0) {
466
- reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
467
- return;
468
- }
469
- subprocess.unref();
470
- resolve(subprocess);
471
- });
472
- });
473
- });
474
- subprocess.unref();
475
- return new Promise((resolve, reject) => {
476
- subprocess.once("error", reject);
477
- subprocess.once("spawn", () => {
478
- subprocess.off("error", reject);
479
- resolve(subprocess);
480
- });
481
- });
482
- };
483
- const open$1 = (target, options) => {
484
- if (typeof target !== "string") throw new TypeError("Expected a `target`");
485
- return baseOpen({
486
- ...options,
487
- target
488
- });
489
- };
490
- function detectArchBinary(binary) {
491
- if (typeof binary === "string" || Array.isArray(binary)) return binary;
492
- const { [arch]: archBinary } = binary;
493
- if (!archBinary) throw new Error(`${arch} is not supported`);
494
- return archBinary;
495
- }
496
- function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
497
- if (wsl && is_wsl_default) return detectArchBinary(wsl);
498
- if (!platformBinary) throw new Error(`${platform} is not supported`);
499
- return detectArchBinary(platformBinary);
500
- }
501
- const apps = {
502
- browser: "browser",
503
- browserPrivate: "browserPrivate"
504
- };
505
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
506
- darwin: "google chrome",
507
- win32: "chrome",
508
- linux: [
509
- "google-chrome",
510
- "google-chrome-stable",
511
- "chromium",
512
- "chromium-browser"
513
- ]
514
- }, { wsl: {
515
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
516
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
517
- } }));
518
- defineLazyProperty(apps, "brave", () => detectPlatformBinary({
519
- darwin: "brave browser",
520
- win32: "brave",
521
- linux: ["brave-browser", "brave"]
522
- }, { wsl: {
523
- ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
524
- x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
525
- } }));
526
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
527
- darwin: "firefox",
528
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
529
- linux: "firefox"
530
- }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
531
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
532
- darwin: "microsoft edge",
533
- win32: "msedge",
534
- linux: ["microsoft-edge", "microsoft-edge-dev"]
535
- }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
536
- defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" }));
537
- //#endregion
538
- //#region src/utils/open.ts
539
- /**
540
- * Open a URL, file, or other target in its default OS handler
541
- * (browser for URLs, Finder/Explorer for paths, etc.).
542
- */
543
- async function open(target, options) {
544
- await open$1(target, options);
545
- }
546
- //#endregion
547
- export { open as t };
@@ -1,108 +0,0 @@
1
- import { DEVFRAME_OTP_URL_PARAM } from "./constants.mjs";
2
- import { n as randomToken, r as timingSafeEqual, t as randomDigits } from "./crypto-token-XCqTSMg9.mjs";
3
- //#region src/node/auth/state.ts
4
- /** Number of decimal digits in a human-typed one-time authentication code. */
5
- const TEMP_AUTH_CODE_LENGTH = 6;
6
- /**
7
- * How long an authentication code stays valid after it is (re)generated. A
8
- * 6-digit code only has ~20 bits of entropy, so a short lifetime plus the
9
- * attempt cap below are what keep it brute-force resistant.
10
- */
11
- const TEMP_AUTH_CODE_TTL = 5 * 6e4;
12
- /** Failed attempts allowed against a single code before it is rotated. */
13
- const TEMP_AUTH_MAX_ATTEMPTS = 5;
14
- let tempAuthCode = generateTempCode();
15
- let tempAuthCodeExpiresAt = Date.now() + TEMP_AUTH_CODE_TTL;
16
- let tempAuthFailedAttempts = 0;
17
- function generateTempCode() {
18
- return randomDigits(TEMP_AUTH_CODE_LENGTH);
19
- }
20
- /**
21
- * The current one-time authentication code. Display this to the user (e.g. in
22
- * the dev-server terminal) so they can type it into the browser to authenticate.
23
- */
24
- function getTempAuthCode() {
25
- return tempAuthCode;
26
- }
27
- /**
28
- * Rotate the authentication code, resetting its expiry window and failed-attempt
29
- * counter. Call this when a new authentication flow begins (e.g. when an
30
- * untrusted client starts authenticating) so the displayed code is freshly
31
- * valid for its full TTL.
32
- */
33
- function refreshTempAuthCode() {
34
- tempAuthCode = generateTempCode();
35
- tempAuthCodeExpiresAt = Date.now() + TEMP_AUTH_CODE_TTL;
36
- tempAuthFailedAttempts = 0;
37
- return tempAuthCode;
38
- }
39
- /**
40
- * Build a "magic link" authentication URL that embeds a one-time code (OTP) in
41
- * the URL **fragment**. Opening it authenticates the client without typing —
42
- * print it on startup (devframe stays headless, so the host prints its own
43
- * banner). Defaults to the current code; the link is subject to the same TTL.
44
- *
45
- * The code rides the fragment (`#devframe_otp=…`), not the query string, so it
46
- * is never sent to the server, written to an access log, or leaked in a
47
- * `Referer` header — the browser client reads it locally (see
48
- * `consumeOtpFromUrl`). Any existing fragment parameters are preserved.
49
- */
50
- function buildOtpAuthUrl(baseUrl, code = tempAuthCode) {
51
- const url = new URL(baseUrl);
52
- const fragment = new URLSearchParams(url.hash.replace(/^#/, ""));
53
- fragment.set(DEVFRAME_OTP_URL_PARAM, code);
54
- url.hash = fragment.toString();
55
- return url.href;
56
- }
57
- /**
58
- * Re-authenticate a connection that presents a previously-issued bearer token.
59
- * Returns `true` and marks the session trusted when the token is known.
60
- *
61
- * Used by the `anonymous:devframe:auth` handler so a client that already
62
- * authenticated (token persisted in the browser) is trusted on reconnect
63
- * without entering the code again.
64
- */
65
- function verifyAuthToken(token, session, storage) {
66
- if (!token || !storage.value().trusted[token]) return false;
67
- session.meta.clientAuthToken = token;
68
- session.meta.isTrusted = true;
69
- return true;
70
- }
71
- /**
72
- * Exchange a one-time authentication code for a fresh, node-issued bearer token.
73
- *
74
- * On success this mints a high-entropy token, records it in the trusted store,
75
- * marks the calling session trusted, rotates the code, and returns the token
76
- * for the client to persist. Returns `null` on any failure.
77
- *
78
- * Because the code is short and human-typed, verification is hardened against
79
- * brute force: it enforces a time-to-live, compares in constant time, and
80
- * rotates the code after {@link TEMP_AUTH_MAX_ATTEMPTS} failed attempts so an
81
- * attacker cannot keep guessing against the same code.
82
- */
83
- function exchangeTempAuthCode(code, session, info, storage) {
84
- if (Date.now() > tempAuthCodeExpiresAt) {
85
- refreshTempAuthCode();
86
- return null;
87
- }
88
- if (!timingSafeEqual(code, tempAuthCode)) {
89
- tempAuthFailedAttempts += 1;
90
- if (tempAuthFailedAttempts >= TEMP_AUTH_MAX_ATTEMPTS) refreshTempAuthCode();
91
- return null;
92
- }
93
- const authToken = randomToken();
94
- storage.mutate((state) => {
95
- state.trusted[authToken] = {
96
- authToken,
97
- ua: info.ua,
98
- origin: info.origin,
99
- timestamp: Date.now()
100
- };
101
- });
102
- session.meta.clientAuthToken = authToken;
103
- session.meta.isTrusted = true;
104
- refreshTempAuthCode();
105
- return authToken;
106
- }
107
- //#endregion
108
- export { verifyAuthToken as a, refreshTempAuthCode as i, exchangeTempAuthCode as n, getTempAuthCode as r, buildOtpAuthUrl as t };