Skip to content

Commit 83d0dac

Browse files
author
Oclw
committed
fix(gateway): include device identity in probe clients
1 parent 14bbcad commit 83d0dac

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/gateway/probe.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const gatewayClientState = vi.hoisted(() => ({
44
options: null as Record<string, unknown> | null,
55
}));
66

7+
const mockDeviceIdentity = vi.hoisted(() => ({
8+
deviceId: "dev-123",
9+
publicKeyPem: "pub",
10+
privateKeyPem: "priv",
11+
}));
12+
713
class MockGatewayClient {
814
private readonly opts: Record<string, unknown>;
915

@@ -33,6 +39,10 @@ class MockGatewayClient {
3339
}
3440
}
3541

42+
vi.mock("../infra/device-identity.js", () => ({
43+
loadOrCreateDeviceIdentity: vi.fn(() => mockDeviceIdentity),
44+
}));
45+
3646
vi.mock("./client.js", () => ({
3747
GatewayClient: MockGatewayClient,
3848
}));
@@ -48,6 +58,7 @@ describe("probeGateway", () => {
4858
});
4959

5060
expect(gatewayClientState.options?.scopes).toEqual(["operator.read"]);
61+
expect(gatewayClientState.options?.deviceIdentity).toEqual(mockDeviceIdentity);
5162
expect(result.ok).toBe(true);
5263
});
5364
});

src/gateway/probe.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { randomUUID } from "node:crypto";
2+
import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js";
23
import { formatErrorMessage } from "../infra/errors.js";
34
import type { SystemPresence } from "../infra/system-presence.js";
45
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
@@ -60,6 +61,7 @@ export async function probeGateway(opts: {
6061
clientVersion: "dev",
6162
mode: GATEWAY_CLIENT_MODES.PROBE,
6263
instanceId,
64+
deviceIdentity: loadOrCreateDeviceIdentity(),
6365
onConnectError: (err) => {
6466
connectError = formatErrorMessage(err);
6567
},

0 commit comments

Comments
 (0)