Skip to content

Commit 61c2e62

Browse files
committed
chore: merge main
# Conflicts: # apps/server/src/preview/PortScanner.test.ts # apps/server/src/preview/PortScanner.ts
2 parents 83591ea + 5fe9d02 commit 61c2e62

673 files changed

Lines changed: 14357 additions & 8552 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
"electron": "44.4.5",
2828
"electron-store": "^8.2.0",
2929
"electron-updater": "^6.8.9",
30+
"electron-webauthn": "catalog:",
3031
"ffi-rs": "1.3.2",
3132
"playwright-core": "1.60.0",
32-
"react-grab": "^0.1.32"
33+
"react-grab": "^0.1.32",
34+
"tldts": "catalog:"
3335
},
3436
"devDependencies": {
3537
"@effect/vitest": "catalog:",

‎apps/desktop/src/app/DesktopApp.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as DesktopAppIdentity from "./DesktopAppIdentity.ts";
1717
import * as DesktopClerk from "./DesktopClerk.ts";
1818
import * as DesktopApplicationMenu from "../window/DesktopApplicationMenu.ts";
1919
import * as DesktopWindow from "../window/DesktopWindow.ts";
20+
import * as PreviewPasskeys from "../preview/Passkeys.ts";
2021
import * as DesktopBackendPool from "../backend/DesktopBackendPool.ts";
2122
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
2223
import * as DesktopLegacyLocalStorage from "./DesktopLegacyLocalStorage.ts";
@@ -34,6 +35,7 @@ import * as DesktopUpdates from "../updates/DesktopUpdates.ts";
3435
import * as DesktopSnapShot from "../snapShot/DesktopSnapShot.ts";
3536
import * as DesktopWslBackend from "../wsl/DesktopWslBackend.ts";
3637
import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts";
38+
import * as HostProcess from "@t3tools/shared/HostProcess";
3739

3840
const DEFAULT_DESKTOP_BACKEND_PORT = 3773;
3941
const MAX_TCP_PORT = 65_535;
@@ -276,13 +278,16 @@ const startup = Effect.gen(function* () {
276278
const safeStorage = yield* ElectronSafeStorage.ElectronSafeStorage;
277279
const updates = yield* DesktopUpdates.DesktopUpdates;
278280
const environment = yield* DesktopEnvironment.DesktopEnvironment;
281+
const previewPasskeys = yield* PreviewPasskeys.PreviewPasskeys;
279282

280283
yield* shellEnvironment.installIntoProcess;
281284
const hasCommandLinePasswordStore =
282285
preReadyElectronOptions.linuxPasswordStoreCommandLine !== null;
283286
const linuxElectronOptions =
284287
environment.platform === "linux" && !hasCommandLinePasswordStore
285-
? DesktopPreReadyPlatform.resolveEarlyLinuxElectronOptionsFromProcess()
288+
? DesktopPreReadyPlatform.resolveEarlyLinuxElectronOptionsFromProcess(
289+
yield* HostProcess.HomeDirectory,
290+
)
286291
: preReadyElectronOptions.linux;
287292
if (linuxElectronOptions !== null && !hasCommandLinePasswordStore) {
288293
if (
@@ -329,6 +334,7 @@ const startup = Effect.gen(function* () {
329334
});
330335
}
331336
yield* appIdentity.configure;
337+
yield* previewPasskeys.configure;
332338
yield* applicationMenu.configure;
333339
yield* updates.configure;
334340
yield* DesktopRemoteUpdates.listen;

‎apps/desktop/src/app/DesktopAppActivation.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type DesktopAppActivationResponse,
1212
} from "@t3tools/contracts";
1313
import { resolveDesktopAppControlAddress } from "@t3tools/shared/desktopAppControl";
14-
import { HostProcessPlatform, HostProcessUserId } from "@t3tools/shared/hostProcess";
14+
import * as HostProcess from "@t3tools/shared/HostProcess";
1515
import { it } from "@effect/vitest";
1616
import * as Effect from "effect/Effect";
1717
import { afterEach, describe, expect } from "vite-plus/test";
@@ -83,8 +83,8 @@ function exchange(address: string, payload: DesktopAppActivationRequest) {
8383
describe("desktop app control server", () => {
8484
it.effect("roundtrips a request and removes its socket on shutdown", () =>
8585
Effect.gen(function* () {
86-
const platform = yield* HostProcessPlatform;
87-
const userId = yield* HostProcessUserId;
86+
const platform = yield* HostProcess.Platform;
87+
const userId = yield* HostProcess.UserId;
8888
yield* Effect.promise(async () => {
8989
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-control-test-"));
9090
const target = makeTarget(NodePath.join(root, "userdata"), platform, userId);
@@ -123,8 +123,8 @@ describe("desktop app control server", () => {
123123

124124
it.effect("cancels a queued request when the client disconnects", () =>
125125
Effect.gen(function* () {
126-
const platform = yield* HostProcessPlatform;
127-
const userId = yield* HostProcessUserId;
126+
const platform = yield* HostProcess.Platform;
127+
const userId = yield* HostProcess.UserId;
128128
yield* Effect.promise(async () => {
129129
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-cancel-test-"));
130130
const target = makeTarget(NodePath.join(root, "userdata"), platform, userId);
@@ -162,8 +162,8 @@ describe("desktop app control server", () => {
162162
// Two desktop apps can share one state dir, such as nightly and a preview build.
163163
it.effect("keeps a newer app's socket when an older app on the same state dir quits", () =>
164164
Effect.gen(function* () {
165-
const platform = yield* HostProcessPlatform;
166-
const userId = yield* HostProcessUserId;
165+
const platform = yield* HostProcess.Platform;
166+
const userId = yield* HostProcess.UserId;
167167
if (platform === "win32") return;
168168
yield* Effect.promise(async () => {
169169
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-takeover-test-"));
@@ -183,8 +183,8 @@ describe("desktop app control server", () => {
183183

184184
it.effect("binds its address again after the socket file is removed", () =>
185185
Effect.gen(function* () {
186-
const platform = yield* HostProcessPlatform;
187-
const userId = yield* HostProcessUserId;
186+
const platform = yield* HostProcess.Platform;
187+
const userId = yield* HostProcess.UserId;
188188
if (platform === "win32") return;
189189
yield* Effect.promise(async () => {
190190
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-reclaim-test-"));

‎apps/desktop/src/app/DesktopAppActivation.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type DesktopAppActivationResponse,
1313
} from "@t3tools/contracts";
1414
import { resolveDesktopAppControlAddress } from "@t3tools/shared/desktopAppControl";
15-
import { HostProcessUserId } from "@t3tools/shared/hostProcess";
15+
import * as HostProcess from "@t3tools/shared/HostProcess";
1616
import * as Context from "effect/Context";
1717
import * as Effect from "effect/Effect";
1818
import * as Layer from "effect/Layer";
@@ -315,7 +315,7 @@ export const make = Effect.gen(function* () {
315315
const desktopWindow = yield* DesktopWindow.DesktopWindow;
316316
const electronWindow = yield* ElectronWindow.ElectronWindow;
317317
const path = yield* Path.Path;
318-
const userId = yield* HostProcessUserId;
318+
const userId = yield* HostProcess.UserId;
319319
const runPromise = Effect.runPromiseWith(yield* Effect.context<never>());
320320
const address = resolveDesktopAppControlAddress({
321321
stateDir: path.resolve(desktopEnvironment.stateDir),

‎apps/desktop/src/app/DesktopClerk.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as NodeHttp from "node:http";
33
import * as NodePath from "@effect/platform-node/NodePath";
44
import { codexAuthHandoffUrl, readCodexAuthDelivery } from "@t3tools/shared/codexAuthHandoff";
55
import { EnvironmentId, ProviderInstanceId } from "@t3tools/contracts";
6-
import { HostProcessArguments } from "@t3tools/shared/hostProcess";
6+
import * as HostProcess from "@t3tools/shared/HostProcess";
77
import { assert, describe, it } from "@effect/vitest";
88
import * as Cause from "effect/Cause";
99
import * as Effect from "effect/Effect";
@@ -375,7 +375,7 @@ it.effect.each(["startup", "open-url"] as const)(
375375
assert.strictEqual(delivery?.returnUrl, request.returnUrl);
376376
}).pipe(
377377
Effect.provide(layerDesktopClerk(true, [], "darwin", undefined, shell)),
378-
Effect.provideService(HostProcessArguments, entry === "startup" ? ["t3", link] : ["t3"]),
378+
Effect.provideService(HostProcess.Arguments, entry === "startup" ? ["t3", link] : ["t3"]),
379379
Effect.provideService(ElectronApp.ElectronApp, electronApp),
380380
Effect.provideService(
381381
ElectronWindow.ElectronWindow,

‎apps/desktop/src/app/DesktopClerk.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { codexAuthDeliveryUrl, readCodexAuthHandoff } from "@t3tools/shared/code
1111
import { receiveCodexAuthCallback, CodexAuthCallbackError } from "./CodexAuthCallback.ts";
1212
import * as ElectronShell from "../electron/ElectronShell.ts";
1313
import { providerAuthReturnUrl } from "@t3tools/shared/providerAuthReturnUrl";
14-
import { HostProcessArguments } from "@t3tools/shared/hostProcess";
14+
import * as HostProcess from "@t3tools/shared/HostProcess";
1515
import { clerkFrontendApiHostnameFromPublishableKey } from "@t3tools/shared/relayAuth";
1616
import * as ElectronApp from "../electron/ElectronApp.ts";
1717
import * as ElectronProtocol from "../electron/ElectronProtocol.ts";
@@ -182,7 +182,7 @@ export const make = Effect.gen(function* () {
182182
);
183183
return true;
184184
};
185-
const args = yield* HostProcessArguments;
185+
const args = yield* HostProcess.Arguments;
186186
args.some((value) => startProviderAuthHandoff(value));
187187
yield* electronApp.on("open-url", (event: { preventDefault: () => void }, url: string) => {
188188
if (startProviderAuthHandoff(url) || resumeProviderAuth(url)) event.preventDefault();

‎apps/desktop/src/app/DesktopPreReadyFileSystem.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
22
import { assert, it } from "@effect/vitest";
3-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
3+
import * as HostProcess from "@t3tools/shared/HostProcess";
44
import * as Effect from "effect/Effect";
55
import * as Exit from "effect/Exit";
66
import * as FileSystem from "effect/FileSystem";
@@ -32,7 +32,7 @@ it.layer(NodeServices.layer)("DesktopPreReadyFileSystem", (it) => {
3232
}),
3333
);
3434

35-
it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32" || process.getuid?.() === 0)(
35+
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32" || process.getuid?.() === 0)(
3636
"fails instead of treating an unreadable profile as missing",
3737
() =>
3838
Effect.gen(function* () {

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert, describe, it } from "@effect/vitest";
2-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
2+
import * as HostProcess from "@t3tools/shared/HostProcess";
33
import * as Context from "effect/Context";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
@@ -75,7 +75,7 @@ describe("DesktopPreReadyPlatform", () => {
7575
}).pipe(
7676
Effect.provide(
7777
DesktopPreReadyPlatform.layer.pipe(
78-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
78+
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
7979
),
8080
),
8181
);
@@ -111,7 +111,7 @@ describe("DesktopPreReadyPlatform", () => {
111111
}));
112112
yield* Layer.build(
113113
DesktopPreReadyPlatform.layer.pipe(
114-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
114+
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
115115
),
116116
);
117117
const identity = yield* Effect.promise(() => portalIdentity);
@@ -135,7 +135,7 @@ describe("DesktopPreReadyPlatform", () => {
135135
});
136136

137137
return DesktopPreReadyPlatform.make.pipe(
138-
Effect.provideService(HostProcessPlatform, "linux"),
138+
Effect.provideService(HostProcess.Platform, "linux"),
139139
Effect.asVoid,
140140
);
141141
});
@@ -151,7 +151,7 @@ describe("DesktopPreReadyPlatform", () => {
151151
assert.include(contents, "MimeType=x-scheme-handler/t3code;");
152152
assert.include(contents, "Icon=");
153153
assert.equal(setDesktopNameMock.mock.calls.length, 1);
154-
}).pipe(Effect.provideService(HostProcessPlatform, "linux"));
154+
}).pipe(Effect.provideService(HostProcess.Platform, "linux"));
155155
});
156156

157157
it.effect(
@@ -168,7 +168,7 @@ describe("DesktopPreReadyPlatform", () => {
168168
});
169169

170170
const layerPreReady = DesktopPreReadyPlatform.layer.pipe(
171-
Layer.provide(Layer.succeed(HostProcessPlatform, "darwin")),
171+
Layer.provide(Layer.succeed(HostProcess.Platform, "darwin")),
172172
);
173173

174174
const layerClerkShaped = Layer.effect(

‎apps/desktop/src/app/DesktopPreReadyPlatform.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// @effect-diagnostics nodeBuiltinImport:off - pre-ready Electron setup reads settings and prepares the Linux desktop entry synchronously before app services are available.
22
import * as NodeFS from "node:fs";
3-
import * as NodeOS from "node:os";
43
import * as NodePath from "node:path";
54
import * as Context from "effect/Context";
65
import * as Effect from "effect/Effect";
76
import * as Layer from "effect/Layer";
87

98
import * as Electron from "electron";
10-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
9+
import * as HostProcess from "@t3tools/shared/HostProcess";
1110

1211
import * as DesktopEarlyElectronStartup from "./DesktopEarlyElectronStartup.ts";
1312
import { resolveDesktopAppBranding } from "./DesktopEnvironment.ts";
@@ -31,14 +30,15 @@ function readCommandLineSwitchValue(
3130
return value.length > 0 ? value : null;
3231
}
3332

34-
export const resolveEarlyLinuxElectronOptionsFromProcess =
35-
(): DesktopEarlyElectronStartup.EarlyLinuxElectronOptions =>
36-
DesktopEarlyElectronStartup.resolveEarlyLinuxElectronOptions({
37-
env: process.env,
38-
homeDirectory: NodeOS.homedir(),
39-
joinPath: NodePath.posix.join,
40-
readFileString: (path) => NodeFS.readFileSync(path, "utf8"),
41-
});
33+
export const resolveEarlyLinuxElectronOptionsFromProcess = (
34+
homeDirectory: string,
35+
): DesktopEarlyElectronStartup.EarlyLinuxElectronOptions =>
36+
DesktopEarlyElectronStartup.resolveEarlyLinuxElectronOptions({
37+
env: process.env,
38+
homeDirectory,
39+
joinPath: NodePath.posix.join,
40+
readFileString: (path) => NodeFS.readFileSync(path, "utf8"),
41+
});
4242

4343
export class DesktopPreReadyElectronOptions extends Context.Service<
4444
DesktopPreReadyElectronOptions,
@@ -50,21 +50,23 @@ export class DesktopPreReadyElectronOptions extends Context.Service<
5050

5151
/** @public Service construction is part of the canonical Effect module API. */
5252
export const make = Effect.gen(function* () {
53-
const platform = yield* HostProcessPlatform;
53+
const platform = yield* HostProcess.Platform;
54+
const homeDirectory = yield* HostProcess.HomeDirectory;
5455
return yield* Effect.sync((): DesktopPreReadyElectronOptions["Service"] => {
5556
const linuxPasswordStoreCommandLine =
5657
platform === "linux"
5758
? readCommandLineSwitchValue(Electron.app.commandLine, "password-store")
5859
: null;
59-
const linux = platform === "linux" ? resolveEarlyLinuxElectronOptionsFromProcess() : null;
60+
const linux =
61+
platform === "linux" ? resolveEarlyLinuxElectronOptionsFromProcess(homeDirectory) : null;
6062

6163
if (linux !== null) {
6264
// The portal also requires a valid desktop entry. An AppImage update may
6365
// have removed the executable referenced by the previous launch's entry.
6466
try {
6567
const applicationsDir = NodePath.posix.join(
6668
process.env.XDG_DATA_HOME?.trim() ||
67-
NodePath.posix.join(NodeOS.homedir(), ".local", "share"),
69+
NodePath.posix.join(homeDirectory, ".local", "share"),
6870
"applications",
6971
);
7072
NodeFS.mkdirSync(applicationsDir, { recursive: true });

‎apps/desktop/src/backend/DesktopNetworkInterfaces.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert, describe, it } from "@effect/vitest";
2-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
2+
import * as HostProcess from "@t3tools/shared/HostProcess";
33
import * as Cause from "effect/Cause";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
@@ -16,7 +16,7 @@ vi.mock("node:os", () => ({
1616
import * as DesktopNetworkInterfaces from "./DesktopNetworkInterfaces.ts";
1717

1818
const layerTest = DesktopNetworkInterfaces.layer.pipe(
19-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
19+
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
2020
);
2121

2222
describe("DesktopNetworkInterfaces", () => {

0 commit comments

Comments
 (0)