@anweather/game-plugin-ssdk 1.16.0 → 1.17.0

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 (36) hide show
  1. package/dist-cjs/runtime/auth.js +8 -0
  2. package/dist-cjs/runtime/conformance.js +6 -0
  3. package/dist-cjs/runtime/index.js +15 -1
  4. package/dist-cjs/runtime/live/checkpoint.js +31 -0
  5. package/dist-cjs/runtime/live/conformance.js +215 -0
  6. package/dist-cjs/runtime/live/harness.js +144 -0
  7. package/dist-cjs/runtime/live/outbox.js +72 -0
  8. package/dist-cjs/runtime/live/protocol.js +227 -0
  9. package/dist-cjs/runtime/live/rooms.js +579 -0
  10. package/dist-cjs/runtime/live/server.js +105 -0
  11. package/dist-cjs/runtime/servePlugin.js +8 -2
  12. package/dist-cjs/tsconfig.cjs.tsbuildinfo +1 -1
  13. package/dist-es/runtime/auth.js +5 -0
  14. package/dist-es/runtime/conformance.js +6 -0
  15. package/dist-es/runtime/index.js +5 -0
  16. package/dist-es/runtime/live/checkpoint.js +28 -0
  17. package/dist-es/runtime/live/conformance.js +210 -0
  18. package/dist-es/runtime/live/harness.js +141 -0
  19. package/dist-es/runtime/live/outbox.js +68 -0
  20. package/dist-es/runtime/live/protocol.js +217 -0
  21. package/dist-es/runtime/live/rooms.js +575 -0
  22. package/dist-es/runtime/live/server.js +102 -0
  23. package/dist-es/runtime/servePlugin.js +8 -2
  24. package/dist-es/tsconfig.es.tsbuildinfo +1 -1
  25. package/dist-types/runtime/auth.d.ts +3 -0
  26. package/dist-types/runtime/conformance.d.ts +6 -0
  27. package/dist-types/runtime/index.d.ts +11 -0
  28. package/dist-types/runtime/live/checkpoint.d.ts +15 -0
  29. package/dist-types/runtime/live/conformance.d.ts +24 -0
  30. package/dist-types/runtime/live/harness.d.ts +71 -0
  31. package/dist-types/runtime/live/outbox.d.ts +39 -0
  32. package/dist-types/runtime/live/protocol.d.ts +169 -0
  33. package/dist-types/runtime/live/rooms.d.ts +302 -0
  34. package/dist-types/runtime/live/server.d.ts +36 -0
  35. package/dist-types/runtime/servePlugin.d.ts +8 -0
  36. package/package.json +6 -3
@@ -9,6 +9,8 @@ const defaultService_1 = require("./defaultService");
9
9
  const express_2 = require("./express");
10
10
  const registration_1 = require("./registration");
11
11
  const version_1 = require("./version");
12
+ const server_1 = require("./live/server");
13
+ const auth_1 = require("./auth");
12
14
  const permissiveValidation = () => undefined;
13
15
  function createPluginApp(options) {
14
16
  const env = options.env ?? process.env;
@@ -34,7 +36,7 @@ function createPluginApp(options) {
34
36
  return next();
35
37
  if (!authToken)
36
38
  return next();
37
- if (req.header("X-Plugin-Auth") === `Bearer ${authToken}`)
39
+ if ((0, auth_1.bearerMatches)(req.header("X-Plugin-Auth"), authToken))
38
40
  return next();
39
41
  res.status(401).json({ __type: "Unauthorized", message: "missing or invalid X-Plugin-Auth" });
40
42
  });
@@ -63,10 +65,14 @@ async function servePlugin(options) {
63
65
  });
64
66
  const boundPort = server.address().port;
65
67
  log.log(`${options.gameType} plugin backend listening on :${boundPort}`);
68
+ const live = options.live
69
+ ? (0, server_1.attachLive)(server, { gameType: options.gameType, authToken: built.authToken, live: options.live, log })
70
+ : undefined;
66
71
  built.registration.start();
67
72
  let closing;
68
73
  const close = () => (closing ??= (async () => {
69
74
  await built.registration.stop();
75
+ await live?.close();
70
76
  await new Promise((resolve) => server.close(() => resolve()));
71
77
  })());
72
78
  if (options.handleSignals ?? true) {
@@ -76,5 +82,5 @@ async function servePlugin(options) {
76
82
  process.once("SIGTERM", onSignal);
77
83
  process.once("SIGINT", onSignal);
78
84
  }
79
- return { ...built, server, port: boundPort, close };
85
+ return { ...built, server, live, port: boundPort, close };
80
86
  }