@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.
Files changed (45) hide show
  1. package/client/dist/assets/{index-DeYshswm.js → index-CX6eCHuc.js} +47 -47
  2. package/client/dist/index.html +1 -1
  3. package/client/node_modules/.vite/deps/@rjsf_core.js +95 -95
  4. package/client/node_modules/.vite/deps/@rjsf_validator-ajv8.js +4 -3
  5. package/client/node_modules/.vite/deps/@roster-lock_ts-client.js +25 -25
  6. package/client/node_modules/.vite/deps/@roster-lock_types.js +2 -1
  7. package/client/node_modules/.vite/deps/@roster-lock_utils.js +2 -1
  8. package/client/node_modules/.vite/deps/_metadata.json +27 -27
  9. package/client/node_modules/.vite/deps/{chunk-4D2L7OBZ.js → chunk-3IRPLLFB.js} +498 -501
  10. package/client/node_modules/.vite/deps/{chunk-4D2L7OBZ.js.map → chunk-3IRPLLFB.js.map} +1 -1
  11. package/client/node_modules/.vite/deps/{chunk-I55GDNGV.js → chunk-7DRNB6P7.js} +5 -5
  12. package/client/node_modules/.vite/deps/{chunk-NE7PXY4V.js → chunk-CKYX73LL.js} +99 -98
  13. package/client/node_modules/.vite/deps/{chunk-NE7PXY4V.js.map → chunk-CKYX73LL.js.map} +3 -3
  14. package/client/node_modules/.vite/deps/{chunk-IIDO6PKU.js → chunk-EDVVVQBR.js} +97 -97
  15. package/client/node_modules/.vite/deps/{chunk-IIDO6PKU.js.map → chunk-EDVVVQBR.js.map} +1 -1
  16. package/client/node_modules/.vite/deps/{chunk-77TXW5ZT.js → chunk-FFVS6IUX.js} +6 -6
  17. package/client/node_modules/.vite/deps/{chunk-5KLROPUR.js → chunk-G44QLPFQ.js} +6 -6
  18. package/client/node_modules/.vite/deps/chunk-WMTNK64S.js +1 -0
  19. package/client/node_modules/.vite/deps/react-dom.js +3 -2
  20. package/client/node_modules/.vite/deps/react-dom_client.js +12 -12
  21. package/client/node_modules/.vite/deps/react-dom_client.js.map +1 -1
  22. package/client/node_modules/.vite/deps/react-router-dom.js +42 -9
  23. package/client/node_modules/.vite/deps/react.js +2 -1
  24. package/client/node_modules/.vite/deps/react_jsx-dev-runtime.js +5 -5
  25. package/client/node_modules/.vite/deps/react_jsx-runtime.js +3 -2
  26. package/client/src/api/matchAgent.ts +15 -0
  27. package/client/src/bridge/hostBridge.ts +24 -5
  28. package/client/src/components/InstallGameLauncherLightbox.tsx +27 -14
  29. package/client/src/pages/MatchMaking/index.tsx +8 -4
  30. package/client/tsconfig.tsbuildinfo +1 -1
  31. package/dist/handle-room/version-1/game-launcher.js +17 -1
  32. package/dist/handle-room/version-1/game-launcher.js.map +1 -1
  33. package/dist/handle-room/version-1/index.js +1 -0
  34. package/dist/handle-room/version-1/index.js.map +1 -1
  35. package/package.json +12 -10
  36. package/src/handle-room/version-1/game-launcher.ts +24 -0
  37. package/src/handle-room/version-1/index.ts +3 -2
  38. package/tests/integration/helpers/relayHarness.ts +24 -0
  39. package/tests/integration/piece-ensure-ws.test.ts +1 -1
  40. package/tests/integration/relay-protocol.test.ts +100 -0
  41. package/tests/integration/sync-dl.test.ts +1 -1
  42. package/client/node_modules/.vite/deps_temp_ab51ebe9/package.json +0 -3
  43. /package/client/node_modules/.vite/deps/{chunk-I55GDNGV.js.map → chunk-7DRNB6P7.js.map} +0 -0
  44. /package/client/node_modules/.vite/deps/{chunk-77TXW5ZT.js.map → chunk-FFVS6IUX.js.map} +0 -0
  45. /package/client/node_modules/.vite/deps/{chunk-5KLROPUR.js.map → chunk-G44QLPFQ.js.map} +0 -0
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  require_react_dom
3
- } from "./chunk-77TXW5ZT.js";
3
+ } from "./chunk-FFVS6IUX.js";
4
4
  import {
5
5
  require_react
6
- } from "./chunk-I55GDNGV.js";
6
+ } from "./chunk-7DRNB6P7.js";
7
7
  import {
8
8
  __commonJS,
9
9
  __toESM
10
10
  } from "./chunk-WMTNK64S.js";
11
11
 
12
- // ../../node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js
12
+ // ../../../node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js
13
13
  var require_dist = __commonJS({
14
- "../../node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js"(exports) {
14
+ "../../../node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js"(exports) {
15
15
  "use strict";
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.parseCookie = parseCookie;
@@ -258,9 +258,9 @@ var require_dist = __commonJS({
258
258
  }
259
259
  });
260
260
 
261
- // ../../node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js
261
+ // ../../../node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js
262
262
  var require_set_cookie = __commonJS({
263
- "../../node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
263
+ "../../../node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
264
264
  "use strict";
265
265
  var defaultParseOptions = {
266
266
  decodeValues: true,
@@ -441,7 +441,7 @@ var require_set_cookie = __commonJS({
441
441
  }
442
442
  });
443
443
 
444
- // ../../node_modules/.pnpm/react-router@7.18.0_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/react-router/dist/development/chunk-4ZMWKKQ3.mjs
444
+ // ../../../node_modules/.pnpm/react-router@7.18.0_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/react-router/dist/development/chunk-4ZMWKKQ3.mjs
445
445
  var React = __toESM(require_react(), 1);
446
446
  var React2 = __toESM(require_react(), 1);
447
447
  var React3 = __toESM(require_react(), 1);
@@ -11938,7 +11938,7 @@ function encodeLocation(to) {
11938
11938
  };
11939
11939
  }
11940
11940
 
11941
- // ../../node_modules/.pnpm/react-router@7.18.0_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/react-router/dist/development/chunk-E4MTK73K.mjs
11941
+ // ../../../node_modules/.pnpm/react-router@7.18.0_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/react-router/dist/development/chunk-E4MTK73K.mjs
11942
11942
  var React12 = __toESM(require_react(), 1);
11943
11943
  var React22 = __toESM(require_react(), 1);
11944
11944
  var import_cookie = __toESM(require_dist(), 1);
@@ -14321,7 +14321,7 @@ function getHydrationData({
14321
14321
  return hydrationData;
14322
14322
  }
14323
14323
 
14324
- // ../../node_modules/.pnpm/react-router@7.18.0_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/react-router/dist/development/dom-export.mjs
14324
+ // ../../../node_modules/.pnpm/react-router@7.18.0_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/react-router/dist/development/dom-export.mjs
14325
14325
  var React13 = __toESM(require_react(), 1);
14326
14326
  var ReactDOM = __toESM(require_react_dom(), 1);
14327
14327
  var React23 = __toESM(require_react(), 1);
@@ -14673,8 +14673,41 @@ export {
14673
14673
  /*! Bundled license information:
14674
14674
 
14675
14675
  react-router/dist/development/chunk-4ZMWKKQ3.mjs:
14676
+ (**
14677
+ * react-router v7.18.0
14678
+ *
14679
+ * Copyright (c) Remix Software Inc.
14680
+ *
14681
+ * This source code is licensed under the MIT license found in the
14682
+ * LICENSE.md file in the root directory of this source tree.
14683
+ *
14684
+ * @license MIT
14685
+ *)
14686
+
14676
14687
  react-router/dist/development/chunk-E4MTK73K.mjs:
14688
+ (**
14689
+ * react-router v7.18.0
14690
+ *
14691
+ * Copyright (c) Remix Software Inc.
14692
+ *
14693
+ * This source code is licensed under the MIT license found in the
14694
+ * LICENSE.md file in the root directory of this source tree.
14695
+ *
14696
+ * @license MIT
14697
+ *)
14698
+
14677
14699
  react-router/dist/development/dom-export.mjs:
14700
+ (**
14701
+ * react-router v7.18.0
14702
+ *
14703
+ * Copyright (c) Remix Software Inc.
14704
+ *
14705
+ * This source code is licensed under the MIT license found in the
14706
+ * LICENSE.md file in the root directory of this source tree.
14707
+ *
14708
+ * @license MIT
14709
+ *)
14710
+
14678
14711
  react-router/dist/development/index.mjs:
14679
14712
  (**
14680
14713
  * react-router v7.18.0
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  require_react
3
- } from "./chunk-I55GDNGV.js";
3
+ } from "./chunk-7DRNB6P7.js";
4
4
  import "./chunk-WMTNK64S.js";
5
5
  export default require_react();
6
+ //# sourceMappingURL=react.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  require_react
3
- } from "./chunk-I55GDNGV.js";
3
+ } from "./chunk-7DRNB6P7.js";
4
4
  import {
5
5
  __commonJS
6
6
  } from "./chunk-WMTNK64S.js";
7
7
 
8
- // ../../node_modules/.pnpm/react@19.2.7/node_modules/react/cjs/react-jsx-dev-runtime.development.js
8
+ // ../../../node_modules/.pnpm/react@19.2.7/node_modules/react/cjs/react-jsx-dev-runtime.development.js
9
9
  var require_react_jsx_dev_runtime_development = __commonJS({
10
- "../../node_modules/.pnpm/react@19.2.7/node_modules/react/cjs/react-jsx-dev-runtime.development.js"(exports) {
10
+ "../../../node_modules/.pnpm/react@19.2.7/node_modules/react/cjs/react-jsx-dev-runtime.development.js"(exports) {
11
11
  "use strict";
12
12
  (function() {
13
13
  function getComponentNameFromType(type) {
@@ -251,9 +251,9 @@ var require_react_jsx_dev_runtime_development = __commonJS({
251
251
  }
252
252
  });
253
253
 
254
- // ../../node_modules/.pnpm/react@19.2.7/node_modules/react/jsx-dev-runtime.js
254
+ // ../../../node_modules/.pnpm/react@19.2.7/node_modules/react/jsx-dev-runtime.js
255
255
  var require_jsx_dev_runtime = __commonJS({
256
- "../../node_modules/.pnpm/react@19.2.7/node_modules/react/jsx-dev-runtime.js"(exports, module) {
256
+ "../../../node_modules/.pnpm/react@19.2.7/node_modules/react/jsx-dev-runtime.js"(exports, module) {
257
257
  if (false) {
258
258
  module.exports = null;
259
259
  } else {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  require_jsx_runtime
3
- } from "./chunk-5KLROPUR.js";
4
- import "./chunk-I55GDNGV.js";
3
+ } from "./chunk-G44QLPFQ.js";
4
+ import "./chunk-7DRNB6P7.js";
5
5
  import "./chunk-WMTNK64S.js";
6
6
  export default require_jsx_runtime();
7
+ //# sourceMappingURL=react_jsx-runtime.js.map
@@ -102,6 +102,21 @@ export async function validateGameLauncherBinaryLocation(
102
102
  return res.json();
103
103
  }
104
104
 
105
+ export async function validateGameLauncherGameConfig(
106
+ matchAgentUrl: string, authCode: string, pluginName: string, gameConfig: unknown, rosterConfig: unknown
107
+ ): Promise<Array<string>> {
108
+ const res = await matchAgentFetch(
109
+ matchAgentUrl, authCode, `/v1/game-launcher/${encodeURIComponent(pluginName)}/validate-game-config`,
110
+ {
111
+ method: "POST",
112
+ headers: { "Content-Type": "application/json" },
113
+ body: JSON.stringify({ gameConfig, rosterConfig }),
114
+ }
115
+ );
116
+ const { problems } = await res.json();
117
+ return problems;
118
+ }
119
+
105
120
  export async function updateGameLauncherBinary(
106
121
  matchAgentUrl: string, authCode: string, pluginName: string, target?: PlatformTarget
107
122
  ): Promise<void> {
@@ -7,15 +7,16 @@ import {
7
7
  GetIdentityResponse,
8
8
  RequestSelectionRequest, RequestSelectionResponse,
9
9
  UpdateGameLauncherSettingsRequest, UpdateGameLauncherSettingsResponse,
10
+ ValidateGameConfigRequest, ValidateGameConfigResponse,
10
11
  InitiateRelayEvent,
11
12
  } from "@roster-lock/types";
12
13
  import { UserKeyPair } from "@roster-lock/ts-client";
13
- import { listAvailableGameLaunchers } from "../api/matchAgent";
14
+ import { listAvailableGameLaunchers, validateGameLauncherGameConfig } from "../api/matchAgent";
14
15
  import { PlayerSlot } from "../context/JoinSettingsContext";
15
16
  import { DownloadSession } from "../context/DownloadSessionContext";
16
17
 
17
18
  export type PendingLightbox = (
18
- | { type: "install", pluginName: string, resolve: () => void }
19
+ | { type: "install", pluginName: string, resolve: () => void, reject: (e: Error) => void }
19
20
  | { type: "selection", rosterConfig: RequestSelectionRequest["rosterLockConfig"], numPlayers: number, resolve: (v: RequestSelectionResponse) => void, reject: (e: Error) => void }
20
21
  );
21
22
 
@@ -64,8 +65,8 @@ export function useHostBridge(args: {
64
65
  window.addEventListener("message", onMessage);
65
66
 
66
67
  bridge.onRequest(MATCHMAKER_BRIDGE_PATHS.installGameLauncherPlugin, ({ pluginName }: InstallGameLauncherPluginRequest) => {
67
- return new Promise<InstallGameLauncherPluginResponse>((resolve) => {
68
- setPendingLightbox({ type: "install", pluginName, resolve: () => resolve({}) });
68
+ return new Promise<InstallGameLauncherPluginResponse>((resolve, reject) => {
69
+ setPendingLightbox({ type: "install", pluginName, resolve: () => resolve({}), reject: (e) => reject(e) });
69
70
  });
70
71
  });
71
72
 
@@ -106,6 +107,16 @@ export function useHostBridge(args: {
106
107
  }
107
108
  );
108
109
 
110
+ bridge.onRequest(
111
+ MATCHMAKER_BRIDGE_PATHS.validateGameConfig,
112
+ async ({ pluginName, gameConfig, rosterConfig }: ValidateGameConfigRequest): Promise<ValidateGameConfigResponse> => {
113
+ const problems = await validateGameLauncherGameConfig(
114
+ latest.current.matchAgent.url, latest.current.matchAgent.authCode, pluginName, gameConfig, rosterConfig
115
+ );
116
+ return { problems };
117
+ }
118
+ );
119
+
109
120
  bridge.onEvent(MATCHMAKER_BRIDGE_PATHS.initiateRelay, (payload: InitiateRelayEvent) => {
110
121
  if (!pendingSelectionRef.current) return;
111
122
  latest.current.onInitiateRelay({
@@ -135,6 +146,11 @@ export function useHostBridge(args: {
135
146
  setPendingLightbox(null);
136
147
  };
137
148
 
149
+ const cancelInstallLightbox = () => {
150
+ if (pendingLightbox?.type === "install") pendingLightbox.reject(new Error("cancelled"));
151
+ setPendingLightbox(null);
152
+ };
153
+
138
154
  const resolveSelectionLightbox = (selection: RequestSelectionResponse) => {
139
155
  if (pendingLightbox?.type === "selection") pendingLightbox.resolve(selection);
140
156
  setPendingLightbox(null);
@@ -145,5 +161,8 @@ export function useHostBridge(args: {
145
161
  setPendingLightbox(null);
146
162
  };
147
163
 
148
- return { connected, connectionError, pendingLightbox, resolveInstallLightbox, resolveSelectionLightbox, cancelSelectionLightbox };
164
+ return {
165
+ connected, connectionError, pendingLightbox,
166
+ resolveInstallLightbox, cancelInstallLightbox, resolveSelectionLightbox, cancelSelectionLightbox,
167
+ };
149
168
  }
@@ -1,31 +1,44 @@
1
- import { useEffect, useState } from "react";
1
+ import { useState } from "react";
2
2
  import { useMatchAgent } from "../context/MatchAgentContext";
3
3
  import { installGameLauncherPlugin } from "../api/matchAgent";
4
4
  import { GameLauncherSettingsForm } from "./GameLauncherSettingsForm";
5
5
 
6
- // Content for the Lightbox opened by the installGameLauncherPlugin bridge
7
- // request: installs the plugin package, then lets the user finish local
8
- // config (binaryLocation) with the same form the standalone
9
- // /game-launcher/:pluginName route uses, before resolving the bridge request.
10
- export function InstallGameLauncherLightbox({ pluginName, onDone }: { pluginName: string, onDone: () => void }) {
6
+ type Phase = "confirm" | "installing" | "done";
7
+
8
+ // Content for the Lightbox opened by the installGameLauncherPlugin bridge request. Starts by
9
+ // asking the user to confirm - the embedding game picked this plugin name, not the user, so
10
+ // nothing gets installed on their machine without them explicitly agreeing to it here. Only after
11
+ // that does it install the plugin package, then let the user finish local config (binaryLocation)
12
+ // with the same form the standalone /game-launcher/:pluginName route uses, before resolving the
13
+ // bridge request.
14
+ export function InstallGameLauncherLightbox(
15
+ { pluginName, onDone, onCancel }: { pluginName: string, onDone: () => void, onCancel: () => void }
16
+ ) {
11
17
  const { settings } = useMatchAgent();
12
- const [installing, setInstalling] = useState(true);
18
+ const [phase, setPhase] = useState<Phase>("confirm");
13
19
  const [error, setError] = useState<string | null>(null);
14
20
 
15
- useEffect(() => {
21
+ const confirmInstall = () => {
22
+ setPhase("installing");
16
23
  installGameLauncherPlugin(settings.url, settings.authCode, pluginName)
17
24
  .catch((e) => setError((e as Error).message))
18
- .finally(() => setInstalling(false));
19
- // eslint-disable-next-line react-hooks/exhaustive-deps
20
- }, [pluginName]);
25
+ .finally(() => setPhase("done"));
26
+ };
21
27
 
22
28
  return (
23
29
  <div className="page">
24
30
  <h1>Install {pluginName}</h1>
25
- {installing && <p>Installing...</p>}
31
+ {phase === "confirm" && (
32
+ <>
33
+ <p>This game wants to install the "{pluginName}" game launcher plugin on this machine.</p>
34
+ <button type="button" onClick={confirmInstall}>Install</button>
35
+ <button type="button" onClick={onCancel}>Cancel</button>
36
+ </>
37
+ )}
38
+ {phase === "installing" && <p>Installing...</p>}
26
39
  {error && <p className="error">{error}</p>}
27
- {!installing && <GameLauncherSettingsForm pluginName={pluginName} />}
28
- <button type="button" onClick={onDone}>Done</button>
40
+ {phase === "done" && <GameLauncherSettingsForm pluginName={pluginName} />}
41
+ {phase === "done" && <button type="button" onClick={onDone}>Done</button>}
29
42
  </div>
30
43
  );
31
44
  }
@@ -45,8 +45,10 @@ export function MatchMakingPage() {
45
45
  const [errorMessage, setErrorMessage] = useState<string | null>(null);
46
46
  const iframeRef = useRef<HTMLIFrameElement>(null);
47
47
 
48
- const { connectionError, pendingLightbox, resolveInstallLightbox, resolveSelectionLightbox, cancelSelectionLightbox } =
49
- useHostBridge({
48
+ const {
49
+ connectionError, pendingLightbox,
50
+ resolveInstallLightbox, cancelInstallLightbox, resolveSelectionLightbox, cancelSelectionLightbox,
51
+ } = useHostBridge({
50
52
  iframeRef,
51
53
  iframeLoaded,
52
54
  matchAgent: matchAgent.settings,
@@ -169,8 +171,10 @@ export function MatchMakingPage() {
169
171
  )}
170
172
 
171
173
  {pendingLightbox?.type === "install" && (
172
- <Lightbox>
173
- <InstallGameLauncherLightbox pluginName={pendingLightbox.pluginName} onDone={resolveInstallLightbox} />
174
+ <Lightbox onClose={cancelInstallLightbox}>
175
+ <InstallGameLauncherLightbox
176
+ pluginName={pendingLightbox.pluginName} onDone={resolveInstallLightbox} onCancel={cancelInstallLightbox}
177
+ />
174
178
  </Lightbox>
175
179
  )}
176
180