Skip to content

Commit 3cbca5f

Browse files
fix(connection): adapt LAN credentials to current auth and discovery APIs
1 parent 9da3ec5 commit 3cbca5f

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎apps/server/src/auth/EnvironmentAuth.test.ts‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -823,17 +823,19 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodePlatformCrypto.layer))(
823823
const url = `https://${host}/api/auth/lan-credential`;
824824
const iat = Math.floor((yield* DateTime.now).epochMilliseconds / 1_000);
825825
const mint = (authorization: string, dpop?: string) =>
826-
serverAuth.issueLanCredential({
827-
method: "POST",
828-
url: "/api/auth/lan-credential",
829-
cookies: {},
830-
headers: {
831-
host,
832-
"x-forwarded-proto": "https",
833-
authorization,
834-
...(dpop === undefined ? {} : { dpop }),
835-
},
836-
} as never);
826+
serverAuth.issueLanCredential(
827+
HttpServerRequest.fromWeb(
828+
new Request(url, {
829+
method: "POST",
830+
headers: {
831+
host,
832+
"x-forwarded-proto": "https",
833+
authorization,
834+
...(dpop === undefined ? {} : { dpop }),
835+
},
836+
}),
837+
),
838+
);
837839
const parent = yield* sessions.issue({
838840
method: "bearer-access-token",
839841
subject: "paired-phone",

‎apps/server/src/auth/EnvironmentAuth.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ export const make = Effect.gen(function* () {
10561056
}
10571057
const proofKeyThumbprint = yield* verifyRequestDpopProof({ request }).pipe(
10581058
Effect.provideService(ServerSecretStore.ServerSecretStore, secretStore),
1059-
Effect.provideService(Crypto.Crypto, crypto),
1059+
Effect.provideService(Digest.Digest, digest),
10601060
);
10611061
const now = yield* DateTime.now;
10621062
const session = yield* sessions

‎packages/client-runtime/src/connection/supervisor.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ const makeHarness = Effect.fn("TestConnectionHarness.make")(function* (options?:
261261
Layer.succeed(
262262
ConnectionDriver.ConnectionDriver,
263263
ConnectionDriver.ConnectionDriver.of({
264+
mintLanCredential: () => Effect.die("Unexpected LAN credential mint."),
264265
connect,
265266
preflight: (_entry, route) =>
266267
options?.preflight?.(route) ??
@@ -2122,7 +2123,7 @@ describe("EnvironmentSupervisor routes", () => {
21222123
return;
21232124
}
21242125
if (discovery === "initial") {
2125-
yield* Deferred.await(discoveryProcessed);
2126+
yield* awaitState(supervisor.state, (state) => state.phase === "connected");
21262127
expect((yield* SubscriptionRef.get(supervisor.state)).generation).toBe(1);
21272128
expect(
21282129
Option.getOrThrow(yield* SubscriptionRef.get(supervisor.prepared)).target._tag,
@@ -2145,7 +2146,7 @@ describe("EnvironmentSupervisor routes", () => {
21452146
"BearerConnectionTarget",
21462147
);
21472148
expect(yield* Ref.get(learned)).toEqual([
2148-
`learned:${TARGET.environmentId}:${discovery !== "initial" ? "https://fixture.tail1234.ts.net" : "http://192.168.1.10:3773"}`,
2149+
`learned:${TARGET.environmentId}:https://fixture.tail1234.ts.net`,
21492150
]);
21502151
}),
21512152
);

0 commit comments

Comments
 (0)