@babylonjs-toolkit/server 0.0.0-stage → 9.35.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 (236) hide show
  1. package/CUSTOM.md +1690 -0
  2. package/DEPLOY.md +2012 -0
  3. package/README.md +1081 -2
  4. package/lib/AbuseLimits.d.ts +64 -0
  5. package/lib/AbuseLimits.js +121 -0
  6. package/lib/Authentication.d.ts +86 -0
  7. package/lib/Authentication.js +272 -0
  8. package/lib/BootSessionOwner.d.ts +86 -0
  9. package/lib/BootSessionOwner.js +116 -0
  10. package/lib/ColyseusLoggerAdapter.d.ts +32 -0
  11. package/lib/ColyseusLoggerAdapter.js +73 -0
  12. package/lib/DedicatedSceneRegistry.d.ts +52 -0
  13. package/lib/DedicatedSceneRegistry.js +74 -0
  14. package/lib/DedicatedSession.d.ts +152 -0
  15. package/lib/DedicatedSession.js +173 -0
  16. package/lib/DualTransport.d.ts +112 -0
  17. package/lib/DualTransport.js +197 -0
  18. package/lib/GameServer.d.ts +64 -0
  19. package/lib/GameServer.js +647 -0
  20. package/lib/GameServerConfig.d.ts +387 -0
  21. package/lib/GameServerConfig.js +1059 -0
  22. package/lib/GameServerLobbyRoom.d.ts +33 -0
  23. package/lib/GameServerLobbyRoom.js +56 -0
  24. package/lib/GameServerLogger.d.ts +111 -0
  25. package/lib/GameServerLogger.js +190 -0
  26. package/lib/GameServerMetrics.d.ts +158 -0
  27. package/lib/GameServerMetrics.js +276 -0
  28. package/lib/GameServerState.d.ts +164 -0
  29. package/lib/GameServerState.js +26 -0
  30. package/lib/HeadlessRuntime.d.ts +316 -0
  31. package/lib/HeadlessRuntime.js +380 -0
  32. package/lib/JoinGate.d.ts +34 -0
  33. package/lib/JoinGate.js +221 -0
  34. package/lib/NetworkAddresses.d.ts +33 -0
  35. package/lib/NetworkAddresses.js +90 -0
  36. package/lib/PlayerTokens.d.ts +17 -0
  37. package/lib/PlayerTokens.js +24 -0
  38. package/lib/RoomServerTransport.d.ts +73 -0
  39. package/lib/RoomServerTransport.js +90 -0
  40. package/lib/ServerEndpoints.d.ts +133 -0
  41. package/lib/ServerEndpoints.js +247 -0
  42. package/lib/ServerInit.d.ts +28 -0
  43. package/lib/ServerInit.js +113 -0
  44. package/lib/SessionRoom.d.ts +391 -0
  45. package/lib/SessionRoom.js +930 -0
  46. package/lib/TlsCertificates.d.ts +35 -0
  47. package/lib/TlsCertificates.js +130 -0
  48. package/lib/admin/AccountRoutes.d.ts +8 -0
  49. package/lib/admin/AccountRoutes.js +502 -0
  50. package/lib/admin/AdminAccounts.d.ts +329 -0
  51. package/lib/admin/AdminAccounts.js +607 -0
  52. package/lib/admin/AdminApiRouter.d.ts +202 -0
  53. package/lib/admin/AdminApiRouter.js +465 -0
  54. package/lib/admin/AdminApiTypes.d.ts +1782 -0
  55. package/lib/admin/AdminApiTypes.js +4 -0
  56. package/lib/admin/AdminAudit.d.ts +113 -0
  57. package/lib/admin/AdminAudit.js +266 -0
  58. package/lib/admin/AdminCli.d.ts +7 -0
  59. package/lib/admin/AdminCli.js +351 -0
  60. package/lib/admin/AdminClock.d.ts +51 -0
  61. package/lib/admin/AdminClock.js +10 -0
  62. package/lib/admin/AdminConsole.d.ts +39 -0
  63. package/lib/admin/AdminConsole.js +325 -0
  64. package/lib/admin/AdminConstants.d.ts +147 -0
  65. package/lib/admin/AdminConstants.js +167 -0
  66. package/lib/admin/AdminCrypto.d.ts +19 -0
  67. package/lib/admin/AdminCrypto.js +29 -0
  68. package/lib/admin/AdminExtensionsHost.d.ts +176 -0
  69. package/lib/admin/AdminExtensionsHost.js +307 -0
  70. package/lib/admin/AdminPasswords.d.ts +33 -0
  71. package/lib/admin/AdminPasswords.js +92 -0
  72. package/lib/admin/AdminPermissions.d.ts +28 -0
  73. package/lib/admin/AdminPermissions.js +74 -0
  74. package/lib/admin/AdminRecords.d.ts +196 -0
  75. package/lib/admin/AdminRecords.js +3 -0
  76. package/lib/admin/AdminRequestBodies.d.ts +47 -0
  77. package/lib/admin/AdminRequestBodies.js +84 -0
  78. package/lib/admin/AdminRequestGate.d.ts +38 -0
  79. package/lib/admin/AdminRequestGate.js +59 -0
  80. package/lib/admin/AdminResponses.d.ts +103 -0
  81. package/lib/admin/AdminResponses.js +164 -0
  82. package/lib/admin/AdminServices.d.ts +99 -0
  83. package/lib/admin/AdminServices.js +4 -0
  84. package/lib/admin/AdminStaticFiles.d.ts +29 -0
  85. package/lib/admin/AdminStaticFiles.js +97 -0
  86. package/lib/admin/AdminStore.d.ts +152 -0
  87. package/lib/admin/AdminStore.js +46 -0
  88. package/lib/admin/AlertChannels.d.ts +43 -0
  89. package/lib/admin/AlertChannels.js +120 -0
  90. package/lib/admin/AlertEngine.d.ts +231 -0
  91. package/lib/admin/AlertEngine.js +681 -0
  92. package/lib/admin/AlertRoutes.d.ts +8 -0
  93. package/lib/admin/AlertRoutes.js +180 -0
  94. package/lib/admin/ApiKeyRoutes.d.ts +8 -0
  95. package/lib/admin/ApiKeyRoutes.js +53 -0
  96. package/lib/admin/ApiKeys.d.ts +63 -0
  97. package/lib/admin/ApiKeys.js +167 -0
  98. package/lib/admin/AuditRoutes.d.ts +8 -0
  99. package/lib/admin/AuditRoutes.js +106 -0
  100. package/lib/admin/AuthToolRoutes.d.ts +13 -0
  101. package/lib/admin/AuthToolRoutes.js +164 -0
  102. package/lib/admin/BanList.d.ts +87 -0
  103. package/lib/admin/BanList.js +152 -0
  104. package/lib/admin/CborDecoder.d.ts +18 -0
  105. package/lib/admin/CborDecoder.js +201 -0
  106. package/lib/admin/ColyseusCloudClient.d.ts +313 -0
  107. package/lib/admin/ColyseusCloudClient.js +272 -0
  108. package/lib/admin/ColyseusCloudRoutes.d.ts +8 -0
  109. package/lib/admin/ColyseusCloudRoutes.js +91 -0
  110. package/lib/admin/ColyseusCloudService.d.ts +180 -0
  111. package/lib/admin/ColyseusCloudService.js +476 -0
  112. package/lib/admin/ColyseusCloudSettings.d.ts +16 -0
  113. package/lib/admin/ColyseusCloudSettings.js +29 -0
  114. package/lib/admin/ColyseusCloudViews.d.ts +105 -0
  115. package/lib/admin/ColyseusCloudViews.js +371 -0
  116. package/lib/admin/CommonPasswords.d.ts +6 -0
  117. package/lib/admin/CommonPasswords.js +19 -0
  118. package/lib/admin/ConfigOverrides.d.ts +174 -0
  119. package/lib/admin/ConfigOverrides.js +406 -0
  120. package/lib/admin/ConfigRoutes.d.ts +8 -0
  121. package/lib/admin/ConfigRoutes.js +91 -0
  122. package/lib/admin/ConsoleSessions.d.ts +112 -0
  123. package/lib/admin/ConsoleSessions.js +201 -0
  124. package/lib/admin/DedicatedRoutes.d.ts +21 -0
  125. package/lib/admin/DedicatedRoutes.js +254 -0
  126. package/lib/admin/ExtensionRoutes.d.ts +8 -0
  127. package/lib/admin/ExtensionRoutes.js +145 -0
  128. package/lib/admin/FileAdminStore.d.ts +157 -0
  129. package/lib/admin/FileAdminStore.js +349 -0
  130. package/lib/admin/FleetDirectory.d.ts +323 -0
  131. package/lib/admin/FleetDirectory.js +489 -0
  132. package/lib/admin/FleetLeader.d.ts +43 -0
  133. package/lib/admin/FleetLeader.js +89 -0
  134. package/lib/admin/FleetRoutes.d.ts +55 -0
  135. package/lib/admin/FleetRoutes.js +465 -0
  136. package/lib/admin/HealthWarnings.d.ts +10 -0
  137. package/lib/admin/HealthWarnings.js +95 -0
  138. package/lib/admin/LeaderboardRoutes.d.ts +8 -0
  139. package/lib/admin/LeaderboardRoutes.js +569 -0
  140. package/lib/admin/LogBuffer.d.ts +60 -0
  141. package/lib/admin/LogBuffer.js +92 -0
  142. package/lib/admin/LogRedaction.d.ts +15 -0
  143. package/lib/admin/LogRedaction.js +72 -0
  144. package/lib/admin/LogRoutes.d.ts +45 -0
  145. package/lib/admin/LogRoutes.js +307 -0
  146. package/lib/admin/MaintenanceMode.d.ts +41 -0
  147. package/lib/admin/MaintenanceMode.js +74 -0
  148. package/lib/admin/MaintenanceWindows.d.ts +91 -0
  149. package/lib/admin/MaintenanceWindows.js +207 -0
  150. package/lib/admin/MetricsRoutes.d.ts +8 -0
  151. package/lib/admin/MetricsRoutes.js +209 -0
  152. package/lib/admin/MetricsSampler.d.ts +124 -0
  153. package/lib/admin/MetricsSampler.js +211 -0
  154. package/lib/admin/OneTimeCodes.d.ts +60 -0
  155. package/lib/admin/OneTimeCodes.js +162 -0
  156. package/lib/admin/OpenIdConnect.d.ts +146 -0
  157. package/lib/admin/OpenIdConnect.js +335 -0
  158. package/lib/admin/Passkeys.d.ts +130 -0
  159. package/lib/admin/Passkeys.js +432 -0
  160. package/lib/admin/PlayerRoutes.d.ts +20 -0
  161. package/lib/admin/PlayerRoutes.js +676 -0
  162. package/lib/admin/RedisAdminStore.d.ts +114 -0
  163. package/lib/admin/RedisAdminStore.js +258 -0
  164. package/lib/admin/RolloutCoordinator.d.ts +99 -0
  165. package/lib/admin/RolloutCoordinator.js +321 -0
  166. package/lib/admin/ServerEvents.d.ts +57 -0
  167. package/lib/admin/ServerEvents.js +89 -0
  168. package/lib/admin/SessionRoutes.d.ts +113 -0
  169. package/lib/admin/SessionRoutes.js +386 -0
  170. package/lib/admin/UserRoutes.d.ts +8 -0
  171. package/lib/admin/UserRoutes.js +214 -0
  172. package/lib/cli.d.ts +2 -0
  173. package/lib/cli.js +221 -0
  174. package/lib/console/assets/index-CI5N7c-T.js +21 -0
  175. package/lib/console/assets/index-DPitvzLp.css +1 -0
  176. package/lib/console/favicon.svg +1 -0
  177. package/lib/console/index.html +16 -0
  178. package/lib/discord/DiscordOAuth.d.ts +57 -0
  179. package/lib/discord/DiscordOAuth.js +127 -0
  180. package/lib/discord/DiscordSessions.d.ts +79 -0
  181. package/lib/discord/DiscordSessions.js +135 -0
  182. package/lib/discord/DiscordSignInConstants.d.ts +54 -0
  183. package/lib/discord/DiscordSignInConstants.js +55 -0
  184. package/lib/discord/DiscordSignInRoutes.d.ts +51 -0
  185. package/lib/discord/DiscordSignInRoutes.js +359 -0
  186. package/lib/index.d.ts +24 -0
  187. package/lib/index.js +18 -0
  188. package/lib/leaderboards/FileLeaderboardRankStore.d.ts +293 -0
  189. package/lib/leaderboards/FileLeaderboardRankStore.js +808 -0
  190. package/lib/leaderboards/LeaderboardConstants.d.ts +63 -0
  191. package/lib/leaderboards/LeaderboardConstants.js +70 -0
  192. package/lib/leaderboards/LeaderboardError.d.ts +15 -0
  193. package/lib/leaderboards/LeaderboardError.js +20 -0
  194. package/lib/leaderboards/LeaderboardIdentity.d.ts +44 -0
  195. package/lib/leaderboards/LeaderboardIdentity.js +72 -0
  196. package/lib/leaderboards/LeaderboardPublicApi.d.ts +17 -0
  197. package/lib/leaderboards/LeaderboardPublicApi.js +389 -0
  198. package/lib/leaderboards/LeaderboardRankStore.d.ts +296 -0
  199. package/lib/leaderboards/LeaderboardRankStore.js +18 -0
  200. package/lib/leaderboards/LeaderboardRules.d.ts +122 -0
  201. package/lib/leaderboards/LeaderboardRules.js +472 -0
  202. package/lib/leaderboards/LeaderboardScheduler.d.ts +43 -0
  203. package/lib/leaderboards/LeaderboardScheduler.js +103 -0
  204. package/lib/leaderboards/LeaderboardService.d.ts +669 -0
  205. package/lib/leaderboards/LeaderboardService.js +1667 -0
  206. package/lib/leaderboards/LeaderboardTransfer.d.ts +35 -0
  207. package/lib/leaderboards/LeaderboardTransfer.js +580 -0
  208. package/lib/leaderboards/RedisLeaderboardRankStore.d.ts +282 -0
  209. package/lib/leaderboards/RedisLeaderboardRankStore.js +691 -0
  210. package/package.json +64 -4
  211. package/templates/init/Caddyfile +6 -0
  212. package/templates/init/DEPLOY.md +233 -0
  213. package/templates/init/Dockerfile +12 -0
  214. package/templates/init/app.json +21 -0
  215. package/templates/init/aws/README.md +118 -0
  216. package/templates/init/aws/ecs-fargate-alb.yml +207 -0
  217. package/templates/init/aws/ecs-fargate-nlb-quic.yml +210 -0
  218. package/templates/init/babylon-game-server.config.mjs +158 -0
  219. package/templates/init/colyseus-cloud/README.md +133 -0
  220. package/templates/init/colyseus-cloud/babylon-game-server.config.mjs +36 -0
  221. package/templates/init/colyseus-cloud/ecosystem.config.cjs +35 -0
  222. package/templates/init/colyseus-cloud/gitignore +6 -0
  223. package/templates/init/colyseus-cloud/package.json +15 -0
  224. package/templates/init/digitalocean-app.yaml +30 -0
  225. package/templates/init/docker-compose.full.yml +45 -0
  226. package/templates/init/docker-compose.websocket.yml +41 -0
  227. package/templates/init/fly.toml +56 -0
  228. package/templates/init/heroku.yml +11 -0
  229. package/templates/init/kubernetes/deployment.yaml +71 -0
  230. package/templates/init/kubernetes/redis.yaml +73 -0
  231. package/templates/init/kubernetes/service.yaml +24 -0
  232. package/templates/init/monitoring/grafana-dashboard.json +539 -0
  233. package/templates/init/monitoring/prometheus-alerts.yml +51 -0
  234. package/templates/init/monitoring/prometheus-scrape.yml +17 -0
  235. package/templates/init/railway.json +13 -0
  236. package/templates/init/render.yaml +19 -0
@@ -0,0 +1,387 @@
1
+ /** Every setting of a Babylon Game Server (D3). Defaults are DEFAULT_GAME_SERVER_CONFIG. */
2
+ export interface GameServerConfig {
3
+ /** TCP (and UDP) port. Default 2567; env GAME_SERVER_PORT, else PORT. */
4
+ port: number;
5
+ /** Address to bind. Default "0.0.0.0". */
6
+ host: string;
7
+ /** Public ws(s):// URL players use, shown in logs and docs (null: derived from host/port/TLS). */
8
+ publicUrl: string | null;
9
+ /** host[:port] each instance advertises for seat reservations when scaled out (D18), or null. */
10
+ publicAddress: string | null;
11
+ /** Trust x-forwarded-for / x-real-ip for the client address (D11). Default false. */
12
+ trustProxy: boolean;
13
+ /** "auto" (JSON when NODE_ENV=production), "json" or "text". */
14
+ logFormat: "auto" | "json" | "text";
15
+ /** Least severe level logged. Default "info". */
16
+ logLevel: GameServerLogLevel;
17
+ /** TLS on the server itself. */
18
+ tls: TlsConfig;
19
+ /** HTTP/3 WebTransport. */
20
+ udp: UdpConfig;
21
+ /** Player authentication. */
22
+ auth: AuthConfig;
23
+ /** Discord sign-in for players (discord-sign-in). */
24
+ discordSignIn: DiscordSignInConfig;
25
+ /** Admin API, console and their data. */
26
+ admin: AdminConfig;
27
+ /** Prometheus endpoint. */
28
+ metrics: MetricsConfig;
29
+ /** Abuse limits. */
30
+ limits: LimitsConfig;
31
+ /** Multi-instance scaling. */
32
+ redis: RedisConfig;
33
+ /** Dedicated Server-mode sessions. */
34
+ dedicated: DedicatedConfig;
35
+ /** Leaderboards (game-server-leaderboards). */
36
+ leaderboards: LeaderboardsConfig;
37
+ /** Seconds running sessions may continue after SIGTERM (D17). Default 30. */
38
+ drainSeconds: number;
39
+ }
40
+ /** Log levels, most severe first. */
41
+ export type GameServerLogLevel = "error" | "warn" | "info" | "debug";
42
+ /** TLS on the server itself (D2, D9). */
43
+ export interface TlsConfig {
44
+ /** Serve https:// and wss:// (and HTTP/3 when UDP is on). Default false. */
45
+ enabled: boolean;
46
+ /** Path of the PEM certificate chain file, or null. */
47
+ certFile: string | null;
48
+ /** Path of the PEM private key file, or null. */
49
+ keyFile: string | null;
50
+ /** PEM certificate chain text (container secrets), or null. */
51
+ certPem: string | null;
52
+ /** PEM private key text (container secrets), or null. */
53
+ keyPem: string | null;
54
+ /** Make a local development certificate (refused when NODE_ENV=production). Default false. */
55
+ developmentCertificate: boolean;
56
+ }
57
+ /** HTTP/3 WebTransport (D2, D8). */
58
+ export interface UdpConfig {
59
+ /** Also accept WebTransport over HTTP/3 (UDP) on the same port. Needs TLS. Default false. */
60
+ enabled: boolean;
61
+ }
62
+ /** How player tokens are verified. */
63
+ export type AuthMode = "shared-secret" | "jwt" | "webhook" | "custom";
64
+ /** Player authentication (D2, D13). */
65
+ export interface AuthConfig {
66
+ /** Require a valid token on every join. Default false. */
67
+ enabled: boolean;
68
+ /** The verifier. Default "shared-secret". */
69
+ mode: AuthMode;
70
+ /** Shared-secret mode: the accepted tokens. */
71
+ sharedSecret: {
72
+ tokens: string[];
73
+ };
74
+ /** JWT mode: an HMAC secret or a JWKS URL, plus the expected claims. */
75
+ jwt: {
76
+ secret: string | null;
77
+ jwksUrl: string | null;
78
+ issuer: string | null;
79
+ audience: string | null;
80
+ algorithms: string[];
81
+ };
82
+ /** Webhook mode: the URL that approves players, and its timeout in milliseconds. */
83
+ webhook: {
84
+ url: string | null;
85
+ timeoutMs: number;
86
+ };
87
+ }
88
+ /** Discord sign-in for players (discord-sign-in D12): website OAuth2 with PKCE, scope identify; off by default. */
89
+ export interface DiscordSignInConfig {
90
+ /** Let players sign in with Discord. Default false. */
91
+ enabled: boolean;
92
+ /** The Discord application's client id. */
93
+ clientId: string | null;
94
+ /** The Discord application's client secret (from the environment; never logged or shown). */
95
+ clientSecret: string | null;
96
+ /** This server's callback address exactly as registered with Discord, ending in /game-server/discord/callback. */
97
+ redirectUri: string | null;
98
+ /** Game origins (scheme://host[:port]) a sign-in may return to. */
99
+ returnOrigins: string[];
100
+ /** Days a sign-in lasts before the player signs in again (1–365). Default 30. */
101
+ sessionDays: number;
102
+ }
103
+ /** Admin API, console and their data (D15; game-server-admin-console D7, D30). */
104
+ export interface AdminConfig {
105
+ /** Bearer token of the legacy admin endpoints and a full-access API key (null: legacy API off). Secret. */
106
+ token: string | null;
107
+ /** Serve the web console when an admin account exists or a setup is pending. Default true. */
108
+ console: boolean;
109
+ /** Folder of the file data store when Redis is not configured. Default "./babylon-game-server-data". */
110
+ dataDir: string;
111
+ /** Console sign-out after this many idle minutes. Default 30. */
112
+ sessionIdleMinutes: number;
113
+ /** Console sign-out after this many hours in all. Default 12. */
114
+ sessionMaxHours: number;
115
+ /** Addresses or CIDR ranges that may reach the console and its API (empty: any). */
116
+ allowedNetworks: string[];
117
+ /** Log entries each instance keeps for the console. Default 10000. */
118
+ logBufferEntries: number;
119
+ /** Hours of metrics history kept for the charts. Default 24. */
120
+ metricsHistoryHours: number;
121
+ /** An external Grafana dashboard URL the console links to (null: none). */
122
+ grafanaUrl: string | null;
123
+ /** A region or label shown beside this instance (null: none). */
124
+ instanceLabel: string | null;
125
+ /** OpenID Connect single sign-on (game-server-admin-console D26). */
126
+ oidc: AdminOpenIdConfig;
127
+ /** Passkeys (game-server-admin-console D31). */
128
+ passkeys: AdminPasskeyConfig;
129
+ /** The console's Colyseus Cloud page (colyseus-cloud-console). */
130
+ colyseusCloud: AdminColyseusCloudConfig;
131
+ }
132
+ /** OpenID Connect settings of the admin console (D26); enabled needs issuer and clientId. */
133
+ export interface AdminOpenIdConfig {
134
+ /** Offer single sign-on. Default false. */
135
+ enabled: boolean;
136
+ /** Issuer URL with a /.well-known/openid-configuration (null: none). */
137
+ issuer: string | null;
138
+ /** The console's client id at the provider (null: none). */
139
+ clientId: string | null;
140
+ /** The console's client secret (null: a public client). Secret. */
141
+ clientSecret: string | null;
142
+ /** Sign-in button label. Default "Single sign-on". */
143
+ label: string;
144
+ /** Claim that carries groups or roles. Default "groups". */
145
+ roleClaim: string;
146
+ /** Claim value → role, as "value=role" pairs. Default none. */
147
+ roleMapping: string[];
148
+ /** Allow username and password sign-in too. Default true. */
149
+ allowLocalSignIn: boolean;
150
+ }
151
+ /** Passkey settings of the admin console (D31). */
152
+ export interface AdminPasskeyConfig {
153
+ /** Offer passkeys. Default true. */
154
+ enabled: boolean;
155
+ /** Relying party id (null: the console host). */
156
+ rpId: string | null;
157
+ }
158
+ /** The console's Colyseus Cloud page: the read-only Cloud API it reads (colyseus-cloud-console). */
159
+ export interface AdminColyseusCloudConfig {
160
+ /** Team API token from the Colyseus Cloud dashboard (API tokens); null turns the page off. Secret. */
161
+ apiToken: string | null;
162
+ /** Slug of the application the page shows, e.g. "1234-my-game"; null uses the team's only application. */
163
+ application: string | null;
164
+ /** Base URL of the Cloud API, without a trailing slash. */
165
+ apiUrl: string;
166
+ }
167
+ /** Prometheus endpoint (D16). */
168
+ export interface MetricsConfig {
169
+ /** Serve GET /metrics. Default true. */
170
+ enabled: boolean;
171
+ /** Require the admin token on /metrics. Default false. */
172
+ requireAdminToken: boolean;
173
+ }
174
+ /** Abuse limits (D14). */
175
+ export interface LimitsConfig {
176
+ /** Browser origins allowed to join (empty: any). */
177
+ allowedOrigins: string[];
178
+ /** Accept joins that send no Origin header (native clients, tests). Default true. */
179
+ allowMissingOrigin: boolean;
180
+ /** Join requests one client address may make per minute. Default 120. */
181
+ joinRequestsPerMinutePerAddress: number;
182
+ /** Sessions one process hosts. Default 1000. */
183
+ maxSessions: number;
184
+ /** Players one session accepts; larger requests are clamped. Default 255. */
185
+ maxPlayersPerSession: number;
186
+ /** Dedicated sessions one process runs. Default 4. */
187
+ maxDedicatedSessions: number;
188
+ /** Largest WebSocket message in bytes. Default 65536. */
189
+ maxMessageBytes: number;
190
+ /** Messages one client may send per second before it is disconnected. Default 2000. */
191
+ maxMessagesPerSecond: number;
192
+ /** Longest session name in characters. Default 128. */
193
+ maxSessionNameLength: number;
194
+ }
195
+ /** Multi-instance scaling (D18). */
196
+ export interface RedisConfig {
197
+ /** redis:// URL shared by every instance, or null for one process. */
198
+ url: string | null;
199
+ }
200
+ /** Dedicated Server-mode sessions (D19). */
201
+ export interface DedicatedConfig {
202
+ /** The scenes dedicated sessions may run. */
203
+ scenes: DedicatedSceneConfig[];
204
+ /** Dedicated sessions started with the server. */
205
+ boot: DedicatedBootSession[];
206
+ }
207
+ /** Leaderboards (game-server-leaderboards D11): on by default, with boards created from an optional definitions file. */
208
+ export interface LeaderboardsConfig {
209
+ /**
210
+ * JSON file of boards created on start when missing (game-server-leaderboards D11), relative to the working
211
+ * directory; null for none.
212
+ */
213
+ definitionsFile: string | null;
214
+ /**
215
+ * true: only callers whose verified auth identity has a user id may submit; anonymous players' existing entries are
216
+ * moved to the removed list on start (leaderboard-signed-in-only D1). Default false.
217
+ */
218
+ signedInPlayersOnly: boolean;
219
+ }
220
+ /** One scene a dedicated session may run. */
221
+ export interface DedicatedSceneConfig {
222
+ /** Name clients and the admin API use. */
223
+ name: string;
224
+ /** http(s):// URL or folder of the exported scene. */
225
+ sceneRoot: string;
226
+ /** Exported scene file. */
227
+ sceneFile: string;
228
+ /** Extra script bundles loaded before the scene. */
229
+ projectScripts: string[];
230
+ /** Most players. Default 8. */
231
+ maxPlayers: number;
232
+ /** True when a Client join may start it. Default false. */
233
+ onDemand: boolean;
234
+ /** Seconds an on-demand session stays up empty. Default 60. */
235
+ idleSeconds: number;
236
+ }
237
+ /** A dedicated session started with the server. */
238
+ export interface DedicatedBootSession {
239
+ /** The session name clients join. */
240
+ sessionName: string;
241
+ /** The DedicatedSceneConfig name it runs. */
242
+ sceneName: string;
243
+ }
244
+ /** A recursive partial, for config files and API overrides. */
245
+ export type DeepPartial<Value> = {
246
+ [Key in keyof Value]?: Value[Key] extends Array<infer Item> ? Item[] : Value[Key] extends object | null ? DeepPartial<Value[Key]> : Value[Key];
247
+ };
248
+ /** One leaf option: where it lives and how flags and env vars spell it (D3). */
249
+ export interface ConfigOptionDefinition {
250
+ /** Dotted path in GameServerConfig, e.g. "tls.certFile". */
251
+ path: string;
252
+ /** Environment variable, e.g. "GAME_SERVER_TLS_CERT_FILE". */
253
+ environmentVariable: string;
254
+ /** CLI flag without dashes, e.g. "tls-cert-file", or null. */
255
+ flag: string | null;
256
+ /** How text values parse. */
257
+ valueType: "string" | "nullable-string" | "number" | "boolean" | "string-list" | "enum";
258
+ /** Allowed values of an enum option. */
259
+ allowedValues?: string[];
260
+ /** One sentence for README, .env.example and --help. */
261
+ description: string;
262
+ /** True for secrets: redacted in logs. */
263
+ isSecret: boolean;
264
+ }
265
+ /**
266
+ * Where an option's value came from (game-server-admin-console D20); "platform" is a default of the host the server
267
+ * runs on (Colyseus Cloud), "code" is a value given to createGameServer.
268
+ */
269
+ export type ConfigSource = "default" | "platform" | "file" | "environment" | "flag" | "code";
270
+ /** The source of each CONFIG_OPTIONS path, keyed by dotted path. */
271
+ export type ConfigSourceMap = Record<string, ConfigSource>;
272
+ /** Where loadGameServerConfig reads from. */
273
+ export interface GameServerConfigSources {
274
+ /** Command-line arguments after the subcommand. */
275
+ argv: string[];
276
+ /** Environment variables. */
277
+ environment: NodeJS.ProcessEnv;
278
+ /** Folder the config file is looked for in, and relative paths resolve against. */
279
+ workingDirectory: string;
280
+ /** CPUs on this machine (default: the real count). More than one means Colyseus Cloud runs on Redis. */
281
+ processorCount?: number;
282
+ /** The user's home folder (default: the real one), which holds the admin data on Colyseus Cloud. */
283
+ homeDirectory?: string;
284
+ }
285
+ /** Thrown when the config is invalid; lists every problem. */
286
+ export declare class GameServerConfigError extends Error {
287
+ /** Every problem, one readable sentence each. */
288
+ readonly problems: string[];
289
+ /**
290
+ * Creates the error.
291
+ * @param problems Every problem found.
292
+ */
293
+ constructor(problems: string[]);
294
+ }
295
+ /** The settings a server uses when nothing overrides them (D2: TLS, UDP and auth off). */
296
+ export declare const DEFAULT_GAME_SERVER_CONFIG: GameServerConfig;
297
+ /** Every leaf option, once (D3). Flag parsing, env parsing, redaction and the docs all derive from it. */
298
+ export declare const CONFIG_OPTIONS: ConfigOptionDefinition[];
299
+ /**
300
+ * Tells whether this process runs on Colyseus Cloud.
301
+ * @param environment The process environment.
302
+ * @returns True on Colyseus Cloud.
303
+ */
304
+ export declare function isColyseusCloud(environment: NodeJS.ProcessEnv): boolean;
305
+ /**
306
+ * Loads the CLI config: defaults < platform < config file < environment < flags (D3), plus the legacy dedicated flags (D19).
307
+ * @param sources The arguments, environment and working directory.
308
+ * @returns The validated config.
309
+ * @throws GameServerConfigError listing every problem.
310
+ */
311
+ export declare function loadGameServerConfig(sources: GameServerConfigSources): Promise<GameServerConfig>;
312
+ /**
313
+ * Loads the CLI config like loadGameServerConfig and records where each option came from (game-server-admin-console
314
+ * D20): the last layer that set it, else "default".
315
+ * @param sources The arguments, environment and working directory.
316
+ * @returns The validated config and the source of every CONFIG_OPTIONS path.
317
+ * @throws GameServerConfigError listing every problem.
318
+ */
319
+ export declare function loadGameServerConfigWithSources(sources: GameServerConfigSources): Promise<{
320
+ config: GameServerConfig;
321
+ sources: ConfigSourceMap;
322
+ }>;
323
+ /**
324
+ * Parses a value given for an option by its value type (the console's live overrides, game-server-admin-console
325
+ * D20): text parses as it would from an environment variable (so a string-list takes a comma-separated string), any
326
+ * other value is kept as it is for validateGameServerConfig to check.
327
+ * @param definition The option.
328
+ * @param value The value given.
329
+ * @returns The value, or null when text does not parse.
330
+ */
331
+ export declare function parseOptionValue(definition: ConfigOptionDefinition, value: unknown): {
332
+ value: unknown;
333
+ } | null;
334
+ /**
335
+ * The defaults deep-merged with overrides (objects merge, arrays and scalars replace), then validated.
336
+ * @param overrides The values to apply (a full config is fine).
337
+ * @param environment The environment validation checks (NODE_ENV); the process environment when omitted.
338
+ * @returns The validated config.
339
+ * @throws GameServerConfigError listing every problem.
340
+ */
341
+ export declare function resolveGameServerConfig(overrides: DeepPartial<GameServerConfig>, environment?: NodeJS.ProcessEnv): GameServerConfig;
342
+ /**
343
+ * The problems of a config (empty when valid): wrong value types, out-of-range numbers and incomplete opt-ins (D2).
344
+ * @param config The config.
345
+ * @param environment The environment (NODE_ENV); the process environment when omitted.
346
+ * @returns One sentence per problem, each naming the option and its environment variable.
347
+ */
348
+ export declare function validateGameServerConfig(config: GameServerConfig, environment?: NodeJS.ProcessEnv): string[];
349
+ /**
350
+ * A copy safe to log: every isSecret option replaced by "[redacted]" (when set) or null (D4).
351
+ * @param config The config.
352
+ * @returns The redacted copy.
353
+ */
354
+ export declare function describeConfig(config: GameServerConfig): Record<string, unknown>;
355
+ /**
356
+ * The log format a config means here: "auto" is JSON under NODE_ENV=production, else text (D4).
357
+ * @param config The config.
358
+ * @param environment The environment (NODE_ENV); the process environment when omitted.
359
+ * @returns "json" or "text".
360
+ */
361
+ export declare function effectiveLogFormat(config: GameServerConfig, environment?: NodeJS.ProcessEnv): "json" | "text";
362
+ /**
363
+ * Whether NODE_ENV says production.
364
+ * @param environment The environment.
365
+ * @returns True when NODE_ENV is "production".
366
+ */
367
+ export declare function isProductionEnvironment(environment: NodeJS.ProcessEnv): boolean;
368
+ /**
369
+ * Reads a dotted path of an object.
370
+ * @param target The object.
371
+ * @param dottedPath E.g. "tls.certFile".
372
+ * @returns The value, or undefined when a step is missing.
373
+ */
374
+ export declare function readPath(target: object, dottedPath: string): unknown;
375
+ /**
376
+ * Writes a dotted path of an object, creating the objects on the way.
377
+ * @param target The object.
378
+ * @param dottedPath E.g. "tls.certFile".
379
+ * @param value The value.
380
+ */
381
+ export declare function writePath(target: object, dottedPath: string, value: unknown): void;
382
+ /**
383
+ * Whether a text is a bare origin: http(s), a host, an optional port, and nothing else.
384
+ * @param origin The text.
385
+ * @returns True for "https://game.example.com" or "http://localhost:6178".
386
+ */
387
+ export declare function isPlainOrigin(origin: string): boolean;