@roster-lock/match-agent 0.2.0 → 0.3.1
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.
- package/client/dist/assets/{index-DeYshswm.js → index-CX6eCHuc.js} +47 -47
- package/client/dist/index.html +1 -1
- package/client/node_modules/.vite/deps/@rjsf_core.js +95 -95
- package/client/node_modules/.vite/deps/@rjsf_validator-ajv8.js +4 -3
- package/client/node_modules/.vite/deps/@roster-lock_ts-client.js +25 -25
- package/client/node_modules/.vite/deps/@roster-lock_types.js +2 -1
- package/client/node_modules/.vite/deps/@roster-lock_utils.js +2 -1
- package/client/node_modules/.vite/deps/_metadata.json +27 -27
- package/client/node_modules/.vite/deps/{chunk-4D2L7OBZ.js → chunk-3IRPLLFB.js} +498 -501
- package/client/node_modules/.vite/deps/{chunk-4D2L7OBZ.js.map → chunk-3IRPLLFB.js.map} +1 -1
- package/client/node_modules/.vite/deps/{chunk-I55GDNGV.js → chunk-7DRNB6P7.js} +5 -5
- package/client/node_modules/.vite/deps/{chunk-NE7PXY4V.js → chunk-CKYX73LL.js} +99 -98
- package/client/node_modules/.vite/deps/{chunk-NE7PXY4V.js.map → chunk-CKYX73LL.js.map} +3 -3
- package/client/node_modules/.vite/deps/{chunk-IIDO6PKU.js → chunk-EDVVVQBR.js} +97 -97
- package/client/node_modules/.vite/deps/{chunk-IIDO6PKU.js.map → chunk-EDVVVQBR.js.map} +1 -1
- package/client/node_modules/.vite/deps/{chunk-77TXW5ZT.js → chunk-FFVS6IUX.js} +6 -6
- package/client/node_modules/.vite/deps/{chunk-5KLROPUR.js → chunk-G44QLPFQ.js} +6 -6
- package/client/node_modules/.vite/deps/chunk-WMTNK64S.js +1 -0
- package/client/node_modules/.vite/deps/react-dom.js +3 -2
- package/client/node_modules/.vite/deps/react-dom_client.js +12 -12
- package/client/node_modules/.vite/deps/react-dom_client.js.map +1 -1
- package/client/node_modules/.vite/deps/react-router-dom.js +42 -9
- package/client/node_modules/.vite/deps/react.js +2 -1
- package/client/node_modules/.vite/deps/react_jsx-dev-runtime.js +5 -5
- package/client/node_modules/.vite/deps/react_jsx-runtime.js +3 -2
- package/client/src/api/matchAgent.ts +15 -0
- package/client/src/bridge/hostBridge.ts +24 -5
- package/client/src/components/InstallGameLauncherLightbox.tsx +27 -14
- package/client/src/pages/MatchMaking/index.tsx +8 -4
- package/client/tsconfig.tsbuildinfo +1 -1
- package/dist/handle-room/version-1/game-launcher.js +17 -1
- package/dist/handle-room/version-1/game-launcher.js.map +1 -1
- package/dist/handle-room/version-1/index.js +1 -0
- package/dist/handle-room/version-1/index.js.map +1 -1
- package/package.json +12 -10
- package/src/handle-room/version-1/game-launcher.ts +24 -0
- package/src/handle-room/version-1/index.ts +3 -2
- package/tests/integration/helpers/relayHarness.ts +24 -0
- package/tests/integration/piece-ensure-ws.test.ts +1 -1
- package/tests/integration/relay-protocol.test.ts +100 -0
- package/tests/integration/sync-dl.test.ts +1 -1
- package/client/node_modules/.vite/deps_temp_ab51ebe9/package.json +0 -3
- /package/client/node_modules/.vite/deps/{chunk-I55GDNGV.js.map → chunk-7DRNB6P7.js.map} +0 -0
- /package/client/node_modules/.vite/deps/{chunk-77TXW5ZT.js.map → chunk-FFVS6IUX.js.map} +0 -0
- /package/client/node_modules/.vite/deps/{chunk-5KLROPUR.js.map → chunk-G44QLPFQ.js.map} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import { SIGNATURE_ASYMMETRIC } from "@roster-lock/utils";
|
|
3
|
+
import { RosterLockV1Config, RosterLockV1SyncDLRequestClientToAgent } from "@roster-lock/types";
|
|
4
|
+
import {
|
|
5
|
+
RelayHarness, CONFORMANCE_CONFIG, generateMachineDef, registerMatchmaker, createRoom, MachineDef,
|
|
6
|
+
} from "@roster-lock/relay-conformance";
|
|
7
|
+
import { exchangeAndDownloadSelections } from "../../src/handle-room/version-1/room-handler-bridge/exchange-and-download-selections";
|
|
8
|
+
import { FakeFolderDB } from "./helpers/fakeFolderDB";
|
|
9
|
+
import { FakePluginManager } from "./helpers/fakePluginRuntime";
|
|
10
|
+
import { createSingleHostHarness } from "./helpers/relayHarness";
|
|
11
|
+
|
|
12
|
+
// A schema-valid RosterLockV1Config with zero piece types. runSelection
|
|
13
|
+
// (core/shared/.../validate-select) iterates config.engine.pieceDefinitions -
|
|
14
|
+
// empty means it resolves to an empty FinalSelection without ever calling
|
|
15
|
+
// runUntrustedScript, and handleDownloads then iterates that empty
|
|
16
|
+
// FinalSelection without ever touching fileDB. That's what lets this test
|
|
17
|
+
// drive match-agent's *real* relay-facing client - the actual signing,
|
|
18
|
+
// fetch, WebSocket, MessageBridge, encryption, and step state machine - while
|
|
19
|
+
// staying entirely out of match-agent's plugin/download machinery, which
|
|
20
|
+
// already has its own coverage (e.g. piece-ensure-ws.test.ts).
|
|
21
|
+
const EMPTY_LOCK_CONFIG: RosterLockV1Config = {
|
|
22
|
+
configIdentity: { namespace: "roster-lock", purpose: "lock", version: 1 },
|
|
23
|
+
author: "match-agent-conformance",
|
|
24
|
+
title: "match-agent-conformance-empty-config",
|
|
25
|
+
version: "1.0.0",
|
|
26
|
+
engine: { name: "conformance-engine", version: "1.0.0", pieceDefinitions: {} },
|
|
27
|
+
rosters: {},
|
|
28
|
+
selection: { piece: {}, globalValidation: [], scriptDictionary: {} },
|
|
29
|
+
pieceMeta: {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// The room protocol has every machine decrypt every other machine's
|
|
33
|
+
// contribution (steps.ts's "all-decryption-for-user-final"), so both sides
|
|
34
|
+
// of this test must submit genuine ciphertext - @roster-lock/relay-conformance's
|
|
35
|
+
// wireHonestMachine deliberately returns fixed placeholder strings instead
|
|
36
|
+
// (it exists to prove the *relay* drives the protocol correctly without
|
|
37
|
+
// caring about payload contents), which the real client would then try to
|
|
38
|
+
// decrypt as if they were real. So this test pairs two real match-agent
|
|
39
|
+
// clients against each other over a real relay, rather than a real client
|
|
40
|
+
// against that fake one.
|
|
41
|
+
async function buildRoomRequest(
|
|
42
|
+
baseUrl: string, roomId: string, machine: MachineDef,
|
|
43
|
+
): Promise<RosterLockV1SyncDLRequestClientToAgent> {
|
|
44
|
+
const timestamp = Date.now();
|
|
45
|
+
const signature = await SIGNATURE_ASYMMETRIC.createSignature(machine.keys.privateSigningKey, {
|
|
46
|
+
service: "room-ws",
|
|
47
|
+
roomId,
|
|
48
|
+
publicKey: machine.keys.publicVerificationKey,
|
|
49
|
+
timestamp,
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
relay: { url: baseUrl, roomId },
|
|
53
|
+
machine: { timestamp, publicKey: machine.keys.publicVerificationKey, signature },
|
|
54
|
+
rosterConfig: EMPTY_LOCK_CONFIG,
|
|
55
|
+
playerSelections: { 0: {} },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Proves a real relay-server (single-host) and match-agent's real client
|
|
60
|
+
// (exchangeAndDownloadSelections/bindStepsToBridge) actually agree on the
|
|
61
|
+
// room protocol end to end - real signing, fetch, WebSocket, MessageBridge,
|
|
62
|
+
// encryption, and step state machine, driven against a real relay process.
|
|
63
|
+
describe("match-agent real client vs a real single-host relay", () => {
|
|
64
|
+
let harness: RelayHarness;
|
|
65
|
+
let baseUrl: string;
|
|
66
|
+
|
|
67
|
+
beforeAll(async () => {
|
|
68
|
+
harness = createSingleHostHarness();
|
|
69
|
+
({ baseUrl } = await harness.start(CONFORMANCE_CONFIG));
|
|
70
|
+
}, 60_000);
|
|
71
|
+
|
|
72
|
+
afterAll(async () => {
|
|
73
|
+
await harness.stop();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("two real machines converge on an empty final selection", async () => {
|
|
77
|
+
const loginRes = await fetch(`${baseUrl}/api/v1/admin/login`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json" },
|
|
80
|
+
body: JSON.stringify(CONFORMANCE_CONFIG.initialAdmin),
|
|
81
|
+
});
|
|
82
|
+
const { token: adminToken } = await loginRes.json() as { token: string };
|
|
83
|
+
|
|
84
|
+
const matchmakerKeys = await registerMatchmaker(baseUrl, adminToken, "match-agent-conformance");
|
|
85
|
+
const machineA = await generateMachineDef("machine-a", "Machine A");
|
|
86
|
+
const machineB = await generateMachineDef("machine-b", "Machine B");
|
|
87
|
+
|
|
88
|
+
const roomId = await createRoom(baseUrl, matchmakerKeys, [machineA, machineB]);
|
|
89
|
+
|
|
90
|
+
const [resultA, resultB] = await Promise.all([machineA, machineB].map(async (machine) => {
|
|
91
|
+
const roomRequest = await buildRoomRequest(baseUrl, roomId, machine);
|
|
92
|
+
return exchangeAndDownloadSelections(new FakeFolderDB(), new FakePluginManager(), roomRequest);
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
expect(resultA.finalSelection).toEqual({});
|
|
96
|
+
expect(resultA.downloadResults).toEqual({});
|
|
97
|
+
expect(resultB.finalSelection).toEqual({});
|
|
98
|
+
expect(resultB.downloadResults).toEqual({});
|
|
99
|
+
}, 20_000);
|
|
100
|
+
});
|
|
@@ -54,7 +54,7 @@ describe("WS /v1/sync-dl", () => {
|
|
|
54
54
|
await readyPromise;
|
|
55
55
|
|
|
56
56
|
await expect(bridge.sendRequest("connect-to-relay", { not: "a valid room request" }))
|
|
57
|
-
.rejects.
|
|
57
|
+
.rejects.toThrow("Invalid request");
|
|
58
58
|
} finally {
|
|
59
59
|
ws.close();
|
|
60
60
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|