@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.
- package/CUSTOM.md +1690 -0
- package/DEPLOY.md +2012 -0
- package/README.md +1081 -2
- package/lib/AbuseLimits.d.ts +64 -0
- package/lib/AbuseLimits.js +121 -0
- package/lib/Authentication.d.ts +86 -0
- package/lib/Authentication.js +272 -0
- package/lib/BootSessionOwner.d.ts +86 -0
- package/lib/BootSessionOwner.js +116 -0
- package/lib/ColyseusLoggerAdapter.d.ts +32 -0
- package/lib/ColyseusLoggerAdapter.js +73 -0
- package/lib/DedicatedSceneRegistry.d.ts +52 -0
- package/lib/DedicatedSceneRegistry.js +74 -0
- package/lib/DedicatedSession.d.ts +152 -0
- package/lib/DedicatedSession.js +173 -0
- package/lib/DualTransport.d.ts +112 -0
- package/lib/DualTransport.js +197 -0
- package/lib/GameServer.d.ts +64 -0
- package/lib/GameServer.js +647 -0
- package/lib/GameServerConfig.d.ts +387 -0
- package/lib/GameServerConfig.js +1059 -0
- package/lib/GameServerLobbyRoom.d.ts +33 -0
- package/lib/GameServerLobbyRoom.js +56 -0
- package/lib/GameServerLogger.d.ts +111 -0
- package/lib/GameServerLogger.js +190 -0
- package/lib/GameServerMetrics.d.ts +158 -0
- package/lib/GameServerMetrics.js +276 -0
- package/lib/GameServerState.d.ts +164 -0
- package/lib/GameServerState.js +26 -0
- package/lib/HeadlessRuntime.d.ts +316 -0
- package/lib/HeadlessRuntime.js +380 -0
- package/lib/JoinGate.d.ts +34 -0
- package/lib/JoinGate.js +221 -0
- package/lib/NetworkAddresses.d.ts +33 -0
- package/lib/NetworkAddresses.js +90 -0
- package/lib/PlayerTokens.d.ts +17 -0
- package/lib/PlayerTokens.js +24 -0
- package/lib/RoomServerTransport.d.ts +73 -0
- package/lib/RoomServerTransport.js +90 -0
- package/lib/ServerEndpoints.d.ts +133 -0
- package/lib/ServerEndpoints.js +247 -0
- package/lib/ServerInit.d.ts +28 -0
- package/lib/ServerInit.js +113 -0
- package/lib/SessionRoom.d.ts +391 -0
- package/lib/SessionRoom.js +930 -0
- package/lib/TlsCertificates.d.ts +35 -0
- package/lib/TlsCertificates.js +130 -0
- package/lib/admin/AccountRoutes.d.ts +8 -0
- package/lib/admin/AccountRoutes.js +502 -0
- package/lib/admin/AdminAccounts.d.ts +329 -0
- package/lib/admin/AdminAccounts.js +607 -0
- package/lib/admin/AdminApiRouter.d.ts +202 -0
- package/lib/admin/AdminApiRouter.js +465 -0
- package/lib/admin/AdminApiTypes.d.ts +1782 -0
- package/lib/admin/AdminApiTypes.js +4 -0
- package/lib/admin/AdminAudit.d.ts +113 -0
- package/lib/admin/AdminAudit.js +266 -0
- package/lib/admin/AdminCli.d.ts +7 -0
- package/lib/admin/AdminCli.js +351 -0
- package/lib/admin/AdminClock.d.ts +51 -0
- package/lib/admin/AdminClock.js +10 -0
- package/lib/admin/AdminConsole.d.ts +39 -0
- package/lib/admin/AdminConsole.js +325 -0
- package/lib/admin/AdminConstants.d.ts +147 -0
- package/lib/admin/AdminConstants.js +167 -0
- package/lib/admin/AdminCrypto.d.ts +19 -0
- package/lib/admin/AdminCrypto.js +29 -0
- package/lib/admin/AdminExtensionsHost.d.ts +176 -0
- package/lib/admin/AdminExtensionsHost.js +307 -0
- package/lib/admin/AdminPasswords.d.ts +33 -0
- package/lib/admin/AdminPasswords.js +92 -0
- package/lib/admin/AdminPermissions.d.ts +28 -0
- package/lib/admin/AdminPermissions.js +74 -0
- package/lib/admin/AdminRecords.d.ts +196 -0
- package/lib/admin/AdminRecords.js +3 -0
- package/lib/admin/AdminRequestBodies.d.ts +47 -0
- package/lib/admin/AdminRequestBodies.js +84 -0
- package/lib/admin/AdminRequestGate.d.ts +38 -0
- package/lib/admin/AdminRequestGate.js +59 -0
- package/lib/admin/AdminResponses.d.ts +103 -0
- package/lib/admin/AdminResponses.js +164 -0
- package/lib/admin/AdminServices.d.ts +99 -0
- package/lib/admin/AdminServices.js +4 -0
- package/lib/admin/AdminStaticFiles.d.ts +29 -0
- package/lib/admin/AdminStaticFiles.js +97 -0
- package/lib/admin/AdminStore.d.ts +152 -0
- package/lib/admin/AdminStore.js +46 -0
- package/lib/admin/AlertChannels.d.ts +43 -0
- package/lib/admin/AlertChannels.js +120 -0
- package/lib/admin/AlertEngine.d.ts +231 -0
- package/lib/admin/AlertEngine.js +681 -0
- package/lib/admin/AlertRoutes.d.ts +8 -0
- package/lib/admin/AlertRoutes.js +180 -0
- package/lib/admin/ApiKeyRoutes.d.ts +8 -0
- package/lib/admin/ApiKeyRoutes.js +53 -0
- package/lib/admin/ApiKeys.d.ts +63 -0
- package/lib/admin/ApiKeys.js +167 -0
- package/lib/admin/AuditRoutes.d.ts +8 -0
- package/lib/admin/AuditRoutes.js +106 -0
- package/lib/admin/AuthToolRoutes.d.ts +13 -0
- package/lib/admin/AuthToolRoutes.js +164 -0
- package/lib/admin/BanList.d.ts +87 -0
- package/lib/admin/BanList.js +152 -0
- package/lib/admin/CborDecoder.d.ts +18 -0
- package/lib/admin/CborDecoder.js +201 -0
- package/lib/admin/ColyseusCloudClient.d.ts +313 -0
- package/lib/admin/ColyseusCloudClient.js +272 -0
- package/lib/admin/ColyseusCloudRoutes.d.ts +8 -0
- package/lib/admin/ColyseusCloudRoutes.js +91 -0
- package/lib/admin/ColyseusCloudService.d.ts +180 -0
- package/lib/admin/ColyseusCloudService.js +476 -0
- package/lib/admin/ColyseusCloudSettings.d.ts +16 -0
- package/lib/admin/ColyseusCloudSettings.js +29 -0
- package/lib/admin/ColyseusCloudViews.d.ts +105 -0
- package/lib/admin/ColyseusCloudViews.js +371 -0
- package/lib/admin/CommonPasswords.d.ts +6 -0
- package/lib/admin/CommonPasswords.js +19 -0
- package/lib/admin/ConfigOverrides.d.ts +174 -0
- package/lib/admin/ConfigOverrides.js +406 -0
- package/lib/admin/ConfigRoutes.d.ts +8 -0
- package/lib/admin/ConfigRoutes.js +91 -0
- package/lib/admin/ConsoleSessions.d.ts +112 -0
- package/lib/admin/ConsoleSessions.js +201 -0
- package/lib/admin/DedicatedRoutes.d.ts +21 -0
- package/lib/admin/DedicatedRoutes.js +254 -0
- package/lib/admin/ExtensionRoutes.d.ts +8 -0
- package/lib/admin/ExtensionRoutes.js +145 -0
- package/lib/admin/FileAdminStore.d.ts +157 -0
- package/lib/admin/FileAdminStore.js +349 -0
- package/lib/admin/FleetDirectory.d.ts +323 -0
- package/lib/admin/FleetDirectory.js +489 -0
- package/lib/admin/FleetLeader.d.ts +43 -0
- package/lib/admin/FleetLeader.js +89 -0
- package/lib/admin/FleetRoutes.d.ts +55 -0
- package/lib/admin/FleetRoutes.js +465 -0
- package/lib/admin/HealthWarnings.d.ts +10 -0
- package/lib/admin/HealthWarnings.js +95 -0
- package/lib/admin/LeaderboardRoutes.d.ts +8 -0
- package/lib/admin/LeaderboardRoutes.js +569 -0
- package/lib/admin/LogBuffer.d.ts +60 -0
- package/lib/admin/LogBuffer.js +92 -0
- package/lib/admin/LogRedaction.d.ts +15 -0
- package/lib/admin/LogRedaction.js +72 -0
- package/lib/admin/LogRoutes.d.ts +45 -0
- package/lib/admin/LogRoutes.js +307 -0
- package/lib/admin/MaintenanceMode.d.ts +41 -0
- package/lib/admin/MaintenanceMode.js +74 -0
- package/lib/admin/MaintenanceWindows.d.ts +91 -0
- package/lib/admin/MaintenanceWindows.js +207 -0
- package/lib/admin/MetricsRoutes.d.ts +8 -0
- package/lib/admin/MetricsRoutes.js +209 -0
- package/lib/admin/MetricsSampler.d.ts +124 -0
- package/lib/admin/MetricsSampler.js +211 -0
- package/lib/admin/OneTimeCodes.d.ts +60 -0
- package/lib/admin/OneTimeCodes.js +162 -0
- package/lib/admin/OpenIdConnect.d.ts +146 -0
- package/lib/admin/OpenIdConnect.js +335 -0
- package/lib/admin/Passkeys.d.ts +130 -0
- package/lib/admin/Passkeys.js +432 -0
- package/lib/admin/PlayerRoutes.d.ts +20 -0
- package/lib/admin/PlayerRoutes.js +676 -0
- package/lib/admin/RedisAdminStore.d.ts +114 -0
- package/lib/admin/RedisAdminStore.js +258 -0
- package/lib/admin/RolloutCoordinator.d.ts +99 -0
- package/lib/admin/RolloutCoordinator.js +321 -0
- package/lib/admin/ServerEvents.d.ts +57 -0
- package/lib/admin/ServerEvents.js +89 -0
- package/lib/admin/SessionRoutes.d.ts +113 -0
- package/lib/admin/SessionRoutes.js +386 -0
- package/lib/admin/UserRoutes.d.ts +8 -0
- package/lib/admin/UserRoutes.js +214 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +221 -0
- package/lib/console/assets/index-CI5N7c-T.js +21 -0
- package/lib/console/assets/index-DPitvzLp.css +1 -0
- package/lib/console/favicon.svg +1 -0
- package/lib/console/index.html +16 -0
- package/lib/discord/DiscordOAuth.d.ts +57 -0
- package/lib/discord/DiscordOAuth.js +127 -0
- package/lib/discord/DiscordSessions.d.ts +79 -0
- package/lib/discord/DiscordSessions.js +135 -0
- package/lib/discord/DiscordSignInConstants.d.ts +54 -0
- package/lib/discord/DiscordSignInConstants.js +55 -0
- package/lib/discord/DiscordSignInRoutes.d.ts +51 -0
- package/lib/discord/DiscordSignInRoutes.js +359 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +18 -0
- package/lib/leaderboards/FileLeaderboardRankStore.d.ts +293 -0
- package/lib/leaderboards/FileLeaderboardRankStore.js +808 -0
- package/lib/leaderboards/LeaderboardConstants.d.ts +63 -0
- package/lib/leaderboards/LeaderboardConstants.js +70 -0
- package/lib/leaderboards/LeaderboardError.d.ts +15 -0
- package/lib/leaderboards/LeaderboardError.js +20 -0
- package/lib/leaderboards/LeaderboardIdentity.d.ts +44 -0
- package/lib/leaderboards/LeaderboardIdentity.js +72 -0
- package/lib/leaderboards/LeaderboardPublicApi.d.ts +17 -0
- package/lib/leaderboards/LeaderboardPublicApi.js +389 -0
- package/lib/leaderboards/LeaderboardRankStore.d.ts +296 -0
- package/lib/leaderboards/LeaderboardRankStore.js +18 -0
- package/lib/leaderboards/LeaderboardRules.d.ts +122 -0
- package/lib/leaderboards/LeaderboardRules.js +472 -0
- package/lib/leaderboards/LeaderboardScheduler.d.ts +43 -0
- package/lib/leaderboards/LeaderboardScheduler.js +103 -0
- package/lib/leaderboards/LeaderboardService.d.ts +669 -0
- package/lib/leaderboards/LeaderboardService.js +1667 -0
- package/lib/leaderboards/LeaderboardTransfer.d.ts +35 -0
- package/lib/leaderboards/LeaderboardTransfer.js +580 -0
- package/lib/leaderboards/RedisLeaderboardRankStore.d.ts +282 -0
- package/lib/leaderboards/RedisLeaderboardRankStore.js +691 -0
- package/package.json +64 -4
- package/templates/init/Caddyfile +6 -0
- package/templates/init/DEPLOY.md +233 -0
- package/templates/init/Dockerfile +12 -0
- package/templates/init/app.json +21 -0
- package/templates/init/aws/README.md +118 -0
- package/templates/init/aws/ecs-fargate-alb.yml +207 -0
- package/templates/init/aws/ecs-fargate-nlb-quic.yml +210 -0
- package/templates/init/babylon-game-server.config.mjs +158 -0
- package/templates/init/colyseus-cloud/README.md +133 -0
- package/templates/init/colyseus-cloud/babylon-game-server.config.mjs +36 -0
- package/templates/init/colyseus-cloud/ecosystem.config.cjs +35 -0
- package/templates/init/colyseus-cloud/gitignore +6 -0
- package/templates/init/colyseus-cloud/package.json +15 -0
- package/templates/init/digitalocean-app.yaml +30 -0
- package/templates/init/docker-compose.full.yml +45 -0
- package/templates/init/docker-compose.websocket.yml +41 -0
- package/templates/init/fly.toml +56 -0
- package/templates/init/heroku.yml +11 -0
- package/templates/init/kubernetes/deployment.yaml +71 -0
- package/templates/init/kubernetes/redis.yaml +73 -0
- package/templates/init/kubernetes/service.yaml +24 -0
- package/templates/init/monitoring/grafana-dashboard.json +539 -0
- package/templates/init/monitoring/prometheus-alerts.yml +51 -0
- package/templates/init/monitoring/prometheus-scrape.yml +17 -0
- package/templates/init/railway.json +13 -0
- package/templates/init/render.yaml +19 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Permissions and roles of the admin console (game-server-admin-console D17, DR §5, §13 R1 and R24). Every API route
|
|
2
|
+
// names one permission; no code checks a role name.
|
|
3
|
+
/** Every action the console and API can check (D17), in the order of the AdminPermission union. */
|
|
4
|
+
export const ADMIN_PERMISSIONS = [
|
|
5
|
+
"fleet.view", "fleet.manage", // overview/instances read; maintenance, drain, rollouts, schedules
|
|
6
|
+
"sessions.view", "sessions.manage", // list/detail; close, lock, notice
|
|
7
|
+
"sessions.inspect", // session inspector
|
|
8
|
+
"players.view", "players.viewAddresses", "players.manage", // search/detail; addresses; kick, notice, lobby kick
|
|
9
|
+
"bans.view", "bans.manage",
|
|
10
|
+
"dedicated.view", "dedicated.manage",
|
|
11
|
+
"metrics.view",
|
|
12
|
+
"logs.view", "logs.manage", // read; change level
|
|
13
|
+
"config.view", "config.manage",
|
|
14
|
+
"auth.view", "auth.manage", // auth status/tester; JWKS reload
|
|
15
|
+
"alerts.view", "alerts.manage",
|
|
16
|
+
"audit.view", "audit.retention",
|
|
17
|
+
"users.view", "users.manage",
|
|
18
|
+
"apiKeys.manage",
|
|
19
|
+
"players.notes", // read and write player notes; see notes and kicks on player pages (R24)
|
|
20
|
+
"extensions.run", "extensions.runDeveloper",
|
|
21
|
+
"cloud.view", "cloud.billing", // Colyseus Cloud page; its billing figures (colyseus-cloud-console D7)
|
|
22
|
+
// Leaderboards (game-server-leaderboards D22)
|
|
23
|
+
"leaderboards.view", "leaderboards.manage", "leaderboards.submit"
|
|
24
|
+
];
|
|
25
|
+
/** Compile-time check that ADMIN_PERMISSIONS' source union has exactly these names (R1): a missing or extra key fails tsc. */
|
|
26
|
+
const permissionListIsComplete = {
|
|
27
|
+
"fleet.view": true, "fleet.manage": true, "sessions.view": true, "sessions.manage": true, "sessions.inspect": true,
|
|
28
|
+
"players.view": true, "players.viewAddresses": true, "players.manage": true, "bans.view": true, "bans.manage": true,
|
|
29
|
+
"dedicated.view": true, "dedicated.manage": true, "metrics.view": true, "logs.view": true, "logs.manage": true,
|
|
30
|
+
"config.view": true, "config.manage": true, "auth.view": true, "auth.manage": true, "alerts.view": true,
|
|
31
|
+
"alerts.manage": true, "audit.view": true, "audit.retention": true, "users.view": true, "users.manage": true,
|
|
32
|
+
"apiKeys.manage": true, "players.notes": true, "extensions.run": true, "extensions.runDeveloper": true,
|
|
33
|
+
"cloud.view": true, "cloud.billing": true, "leaderboards.view": true, "leaderboards.manage": true, "leaderboards.submit": true
|
|
34
|
+
};
|
|
35
|
+
/** The fixed roles (D17), highest first. */
|
|
36
|
+
export const ADMIN_ROLES = ["owner", "admin", "operator", "moderator", "developer", "viewer"];
|
|
37
|
+
/** Read-only permissions every role has. */
|
|
38
|
+
const READ_PERMISSIONS = ["fleet.view", "sessions.view", "players.view", "dedicated.view", "metrics.view", "config.view", "alerts.view", "cloud.view", "leaderboards.view"];
|
|
39
|
+
/** What each role may do (spec 1 role table, R24). */
|
|
40
|
+
export const ROLE_PERMISSIONS = {
|
|
41
|
+
owner: new Set(ADMIN_PERMISSIONS),
|
|
42
|
+
admin: new Set(ADMIN_PERMISSIONS.filter((permission) => permission !== "audit.retention")),
|
|
43
|
+
operator: new Set([...READ_PERMISSIONS, "fleet.manage", "sessions.manage", "dedicated.manage", "config.manage", "alerts.manage", "logs.view", "logs.manage", "auth.view", "audit.view", "users.view", "players.notes", "extensions.run", "leaderboards.manage"]),
|
|
44
|
+
moderator: new Set([...READ_PERMISSIONS, "sessions.manage", "players.viewAddresses", "players.manage", "players.notes", "bans.view", "bans.manage", "audit.view", "logs.view", "auth.view", "users.view", "extensions.run", "leaderboards.manage"]),
|
|
45
|
+
developer: new Set([...READ_PERMISSIONS, "sessions.inspect", "dedicated.manage", "logs.view", "auth.view", "audit.view", "bans.view", "users.view", "players.viewAddresses", "extensions.runDeveloper", "leaderboards.submit"]),
|
|
46
|
+
viewer: new Set(READ_PERMISSIONS)
|
|
47
|
+
};
|
|
48
|
+
/** What the configured admin.token may do as an API key: everything except users.manage and audit.retention (D18). */
|
|
49
|
+
export const LEGACY_TOKEN_PERMISSIONS = new Set(ADMIN_PERMISSIONS.filter((permission) => permission !== "users.manage" && permission !== "audit.retention"));
|
|
50
|
+
/**
|
|
51
|
+
* True when a role or key with these permissions may perform the action.
|
|
52
|
+
* @param granted The permissions the caller holds.
|
|
53
|
+
* @param required The permission the route needs.
|
|
54
|
+
* @returns Whether it is allowed.
|
|
55
|
+
*/
|
|
56
|
+
export function hasPermission(granted, required) {
|
|
57
|
+
return granted.has(required);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether a text names a permission (API key requests and the CLI pass names as text).
|
|
61
|
+
* @param name The text.
|
|
62
|
+
* @returns True for one of ADMIN_PERMISSIONS.
|
|
63
|
+
*/
|
|
64
|
+
export function isAdminPermission(name) {
|
|
65
|
+
return name in permissionListIsComplete;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether a text names a role.
|
|
69
|
+
* @param name The text.
|
|
70
|
+
* @returns True for one of ADMIN_ROLES.
|
|
71
|
+
*/
|
|
72
|
+
export function isAdminRole(name) {
|
|
73
|
+
return ADMIN_ROLES.includes(name);
|
|
74
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { AdminAlertSeverity, AdminLogLevel, AdminPermission, AdminPreferences, AdminRole, AlertChannelKind, AlertRuleId, BanHistoryEntry, BanKind, MaintenanceWindowView, PasskeyAlgorithm, RolloutStepView, RolloutView } from "./AdminApiTypes.js";
|
|
2
|
+
/** An admin account (collection "users", id = userId). */
|
|
3
|
+
export interface AdminUserRecord {
|
|
4
|
+
/** 16 random bytes, base64url. */
|
|
5
|
+
userId: string;
|
|
6
|
+
/** Lower case, /^[a-z0-9._-]{3,32}$/. */
|
|
7
|
+
username: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
email: string | null;
|
|
10
|
+
role: AdminRole;
|
|
11
|
+
/** scrypt hash (D8); null for SSO-only accounts. */
|
|
12
|
+
passwordHash: string | null;
|
|
13
|
+
/** Base32 TOTP secret; null until enrolled. */
|
|
14
|
+
totpSecret: string | null;
|
|
15
|
+
/** The last TOTP step used; a code at or below it is refused (D8). */
|
|
16
|
+
lastUsedTotpStep: number;
|
|
17
|
+
/** SHA-256 hex of each unused recovery code. */
|
|
18
|
+
recoveryCodeHashes: string[];
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
/** ISO time the lockout ends, or null. */
|
|
21
|
+
lockedUntil: string | null;
|
|
22
|
+
oidcSubject: string | null;
|
|
23
|
+
preferences: AdminPreferences;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
passwordChangedAt: string;
|
|
26
|
+
lastSignInAt: string | null;
|
|
27
|
+
}
|
|
28
|
+
/** A console session (collection "consoleSessions", id = sha256 hex of the cookie value). */
|
|
29
|
+
export interface ConsoleSessionRecord {
|
|
30
|
+
/** Public id shown in "your sessions" (8 random bytes, base64url). */
|
|
31
|
+
sessionId: string;
|
|
32
|
+
userId: string;
|
|
33
|
+
csrfToken: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
lastSeenAt: string;
|
|
36
|
+
/** When the second factor was last checked (sign-in or step-up). */
|
|
37
|
+
secondFactorAt: string;
|
|
38
|
+
clientAddress: string;
|
|
39
|
+
userAgent: string;
|
|
40
|
+
}
|
|
41
|
+
/** A sign-in waiting for its second factor or enrolment (collection "pendingSignIns", id = sha256 hex of pendingToken). */
|
|
42
|
+
export interface PendingSignInRecord {
|
|
43
|
+
userId: string;
|
|
44
|
+
stage: "secondFactor" | "enrolSecondFactor";
|
|
45
|
+
/** The secret offered by auth/enrol, until it is confirmed. */
|
|
46
|
+
pendingTotpSecret: string | null;
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
viaSingleSignOn: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** An API key (collection "apiKeys", id = keyId). */
|
|
51
|
+
export interface ApiKeyRecord {
|
|
52
|
+
keyId: string;
|
|
53
|
+
name: string;
|
|
54
|
+
/** SHA-256 hex of the secret. */
|
|
55
|
+
secretHash: string;
|
|
56
|
+
permissions: AdminPermission[];
|
|
57
|
+
expiresAt: string | null;
|
|
58
|
+
allowedNetworks: string[];
|
|
59
|
+
/** The creating user's id, or "cli". */
|
|
60
|
+
createdBy: string;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
lastUsedAt: string | null;
|
|
63
|
+
revoked: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** A ban (collection "bans", id = banId). */
|
|
66
|
+
export interface BanRecord {
|
|
67
|
+
banId: string;
|
|
68
|
+
kind: BanKind;
|
|
69
|
+
/** User id, address, or CIDR range. */
|
|
70
|
+
value: string;
|
|
71
|
+
reason: string;
|
|
72
|
+
note: string;
|
|
73
|
+
/** Null = permanent. */
|
|
74
|
+
expiresAt: string | null;
|
|
75
|
+
createdBy: string;
|
|
76
|
+
createdAt: string;
|
|
77
|
+
history: BanHistoryEntry[];
|
|
78
|
+
}
|
|
79
|
+
/** One sign-in failure counter (collection "signInFailures", id = "account:<userId>" or "address:<address>"). */
|
|
80
|
+
export interface SignInFailureRecord {
|
|
81
|
+
/** ISO times within ACCOUNT_LOCKOUT_WINDOW_MS. */
|
|
82
|
+
failures: string[];
|
|
83
|
+
}
|
|
84
|
+
/** An alert rule's stored settings (collection "alertRules", id = ruleId). */
|
|
85
|
+
export interface AlertRuleRecord {
|
|
86
|
+
ruleId: AlertRuleId;
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
threshold: number | null;
|
|
89
|
+
forMinutes: number;
|
|
90
|
+
severity: AdminAlertSeverity;
|
|
91
|
+
channelIds: string[];
|
|
92
|
+
silencedUntil: string | null;
|
|
93
|
+
}
|
|
94
|
+
/** An alert channel (collection "alertChannels", id = channelId); url and routingKey are secrets. */
|
|
95
|
+
export interface AlertChannelRecord {
|
|
96
|
+
channelId: string;
|
|
97
|
+
kind: AlertChannelKind;
|
|
98
|
+
name: string;
|
|
99
|
+
url: string | null;
|
|
100
|
+
routingKey: string | null;
|
|
101
|
+
createdBy: string;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
}
|
|
104
|
+
/** A scheduled maintenance window (collection "maintenanceWindows", id = windowId). */
|
|
105
|
+
export interface MaintenanceWindowRecord {
|
|
106
|
+
windowId: string;
|
|
107
|
+
startsAt: string;
|
|
108
|
+
endsAt: string;
|
|
109
|
+
message: string;
|
|
110
|
+
warningMinutes: number | null;
|
|
111
|
+
allowUserIds: string[];
|
|
112
|
+
allowAddresses: string[];
|
|
113
|
+
leaveReadiness: boolean;
|
|
114
|
+
state: MaintenanceWindowView["state"];
|
|
115
|
+
createdBy: string;
|
|
116
|
+
}
|
|
117
|
+
/** A rolling update (collection "rollouts", id = rolloutId). */
|
|
118
|
+
export interface RolloutRecord {
|
|
119
|
+
rolloutId: string;
|
|
120
|
+
state: RolloutView["state"];
|
|
121
|
+
startedAt: string;
|
|
122
|
+
startedBy: string;
|
|
123
|
+
startingProcessIds: string[];
|
|
124
|
+
startingVersion: string;
|
|
125
|
+
noticeText: string | null;
|
|
126
|
+
noticeLeadSeconds: number;
|
|
127
|
+
perInstanceTimeoutMinutes: number;
|
|
128
|
+
steps: RolloutStepView[];
|
|
129
|
+
stepStartedAt: string | null;
|
|
130
|
+
message: string | null;
|
|
131
|
+
}
|
|
132
|
+
/** A note on a player (collection "playerNotes", id = noteId). */
|
|
133
|
+
export interface PlayerNoteRecord {
|
|
134
|
+
noteId: string;
|
|
135
|
+
/** A user id or an address. */
|
|
136
|
+
subject: string;
|
|
137
|
+
text: string;
|
|
138
|
+
by: string;
|
|
139
|
+
at: string;
|
|
140
|
+
}
|
|
141
|
+
/** A registered passkey (collection "passkeys", id = passkeyId). */
|
|
142
|
+
export interface PasskeyRecord {
|
|
143
|
+
passkeyId: string;
|
|
144
|
+
userId: string;
|
|
145
|
+
name: string;
|
|
146
|
+
/** base64url credential id. */
|
|
147
|
+
credentialId: string;
|
|
148
|
+
publicKeyJwk: JsonWebKey;
|
|
149
|
+
algorithm: PasskeyAlgorithm;
|
|
150
|
+
signCount: number;
|
|
151
|
+
createdAt: string;
|
|
152
|
+
lastUsedAt: string | null;
|
|
153
|
+
}
|
|
154
|
+
/** A temporary log level (settings/logLevel). */
|
|
155
|
+
export interface TemporaryLogLevel {
|
|
156
|
+
level: AdminLogLevel;
|
|
157
|
+
until: string;
|
|
158
|
+
setBy: string;
|
|
159
|
+
}
|
|
160
|
+
/** Console config overrides (settings/configOverrides). */
|
|
161
|
+
export interface ConfigOverrideSettings {
|
|
162
|
+
/** Dotted path → value, for every instance. */
|
|
163
|
+
fleet: Record<string, unknown>;
|
|
164
|
+
/** Process id → dotted path → value. */
|
|
165
|
+
instances: Record<string, Record<string, unknown>>;
|
|
166
|
+
}
|
|
167
|
+
/** A player joined or left a session (stream playerHistory). */
|
|
168
|
+
export interface PlayerSessionEvent {
|
|
169
|
+
kind: "joined" | "left";
|
|
170
|
+
roomId: string;
|
|
171
|
+
sessionName: string;
|
|
172
|
+
processId: string;
|
|
173
|
+
playerId: number;
|
|
174
|
+
userId: string | null;
|
|
175
|
+
clientAddress: string;
|
|
176
|
+
at: string;
|
|
177
|
+
}
|
|
178
|
+
/** A passkey challenge (collection "pendingSignIns", id = "passkey:" + sha256 hex of the challenge, DR §7.11). */
|
|
179
|
+
export interface PasskeyChallengeRecord {
|
|
180
|
+
/** Registration (navigator.credentials.create) or sign-in (navigator.credentials.get). */
|
|
181
|
+
kind: "passkeyRegistration" | "passkeyAssertion";
|
|
182
|
+
/** The account a registration is for, or the account named at sign-in (null: any account's passkey). */
|
|
183
|
+
userId: string | null;
|
|
184
|
+
expiresAt: string;
|
|
185
|
+
}
|
|
186
|
+
/** A started OpenID Connect sign-in (collection "pendingSignIns", id = "oidc:" + sha256 hex of the state, DR §7.10). */
|
|
187
|
+
export interface OpenIdChallengeRecord {
|
|
188
|
+
kind: "oidc";
|
|
189
|
+
/** The nonce the ID token must carry. */
|
|
190
|
+
nonce: string;
|
|
191
|
+
/** The PKCE code verifier (S256). */
|
|
192
|
+
codeVerifier: string;
|
|
193
|
+
/** The redirect URI the authorization request named. */
|
|
194
|
+
redirectUri: string;
|
|
195
|
+
expiresAt: string;
|
|
196
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body as an object.
|
|
3
|
+
* @param body The parsed JSON body.
|
|
4
|
+
* @returns The object (an empty one for a missing body).
|
|
5
|
+
* @throws AdminRequestError 400 when the body is not an object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bodyObject(body: unknown): Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* A required text field.
|
|
10
|
+
* @param body The body object.
|
|
11
|
+
* @param name The field name.
|
|
12
|
+
* @returns The text.
|
|
13
|
+
* @throws AdminRequestError 400 when it is missing or not text.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stringField(body: Record<string, unknown>, name: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* An optional text field.
|
|
18
|
+
* @param body The body object.
|
|
19
|
+
* @param name The field name.
|
|
20
|
+
* @returns The text, or null when absent or null.
|
|
21
|
+
* @throws AdminRequestError 400 when present but not text.
|
|
22
|
+
*/
|
|
23
|
+
export declare function optionalStringField(body: Record<string, unknown>, name: string): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* A required true/false field.
|
|
26
|
+
* @param body The body object.
|
|
27
|
+
* @param name The field name.
|
|
28
|
+
* @returns The value.
|
|
29
|
+
* @throws AdminRequestError 400 when it is missing or not a boolean.
|
|
30
|
+
*/
|
|
31
|
+
export declare function booleanField(body: Record<string, unknown>, name: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* A required number field.
|
|
34
|
+
* @param body The body object.
|
|
35
|
+
* @param name The field name.
|
|
36
|
+
* @returns The number.
|
|
37
|
+
* @throws AdminRequestError 400 when it is missing or not a finite number.
|
|
38
|
+
*/
|
|
39
|
+
export declare function numberField(body: Record<string, unknown>, name: string): number;
|
|
40
|
+
/**
|
|
41
|
+
* A required list-of-text field.
|
|
42
|
+
* @param body The body object.
|
|
43
|
+
* @param name The field name.
|
|
44
|
+
* @returns The texts.
|
|
45
|
+
* @throws AdminRequestError 400 when it is missing or not a list of text.
|
|
46
|
+
*/
|
|
47
|
+
export declare function stringListField(body: Record<string, unknown>, name: string): string[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Reading request bodies of the admin API: each helper returns a typed field or throws a 400 that names the field.
|
|
2
|
+
import { AdminRequestError } from "./AdminApiRouter.js";
|
|
3
|
+
/** HTTP status of a malformed body. */
|
|
4
|
+
const HTTP_BAD_REQUEST = 400;
|
|
5
|
+
/**
|
|
6
|
+
* The body as an object.
|
|
7
|
+
* @param body The parsed JSON body.
|
|
8
|
+
* @returns The object (an empty one for a missing body).
|
|
9
|
+
* @throws AdminRequestError 400 when the body is not an object.
|
|
10
|
+
*/
|
|
11
|
+
export function bodyObject(body) {
|
|
12
|
+
if (body == null)
|
|
13
|
+
return {};
|
|
14
|
+
if (typeof body !== "object" || Array.isArray(body))
|
|
15
|
+
throw new AdminRequestError(HTTP_BAD_REQUEST, "the body must be a JSON object");
|
|
16
|
+
return body;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A required text field.
|
|
20
|
+
* @param body The body object.
|
|
21
|
+
* @param name The field name.
|
|
22
|
+
* @returns The text.
|
|
23
|
+
* @throws AdminRequestError 400 when it is missing or not text.
|
|
24
|
+
*/
|
|
25
|
+
export function stringField(body, name) {
|
|
26
|
+
const value = body[name];
|
|
27
|
+
if (typeof value !== "string")
|
|
28
|
+
throw new AdminRequestError(HTTP_BAD_REQUEST, name + " must be text");
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* An optional text field.
|
|
33
|
+
* @param body The body object.
|
|
34
|
+
* @param name The field name.
|
|
35
|
+
* @returns The text, or null when absent or null.
|
|
36
|
+
* @throws AdminRequestError 400 when present but not text.
|
|
37
|
+
*/
|
|
38
|
+
export function optionalStringField(body, name) {
|
|
39
|
+
const value = body[name];
|
|
40
|
+
if (value == null)
|
|
41
|
+
return null;
|
|
42
|
+
if (typeof value !== "string")
|
|
43
|
+
throw new AdminRequestError(HTTP_BAD_REQUEST, name + " must be text");
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A required true/false field.
|
|
48
|
+
* @param body The body object.
|
|
49
|
+
* @param name The field name.
|
|
50
|
+
* @returns The value.
|
|
51
|
+
* @throws AdminRequestError 400 when it is missing or not a boolean.
|
|
52
|
+
*/
|
|
53
|
+
export function booleanField(body, name) {
|
|
54
|
+
const value = body[name];
|
|
55
|
+
if (typeof value !== "boolean")
|
|
56
|
+
throw new AdminRequestError(HTTP_BAD_REQUEST, name + " must be true or false");
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A required number field.
|
|
61
|
+
* @param body The body object.
|
|
62
|
+
* @param name The field name.
|
|
63
|
+
* @returns The number.
|
|
64
|
+
* @throws AdminRequestError 400 when it is missing or not a finite number.
|
|
65
|
+
*/
|
|
66
|
+
export function numberField(body, name) {
|
|
67
|
+
const value = body[name];
|
|
68
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
69
|
+
throw new AdminRequestError(HTTP_BAD_REQUEST, name + " must be a number");
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A required list-of-text field.
|
|
74
|
+
* @param body The body object.
|
|
75
|
+
* @param name The field name.
|
|
76
|
+
* @returns The texts.
|
|
77
|
+
* @throws AdminRequestError 400 when it is missing or not a list of text.
|
|
78
|
+
*/
|
|
79
|
+
export function stringListField(body, name) {
|
|
80
|
+
const value = body[name];
|
|
81
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === "string"))
|
|
82
|
+
throw new AdminRequestError(HTTP_BAD_REQUEST, name + " must be a list of text");
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GameServerConfig } from "../GameServerConfig.js";
|
|
2
|
+
/** Network restriction and transport rule of the console (D9). */
|
|
3
|
+
export declare class AdminRequestGate {
|
|
4
|
+
/** The resolved config. */
|
|
5
|
+
private readonly config;
|
|
6
|
+
/** admin.allowedNetworks as a block list, or null when every address may reach the console. */
|
|
7
|
+
private readonly allowedNetworks;
|
|
8
|
+
/**
|
|
9
|
+
* Builds the checks from the config.
|
|
10
|
+
* @param config The resolved config.
|
|
11
|
+
*/
|
|
12
|
+
constructor(config: GameServerConfig);
|
|
13
|
+
/**
|
|
14
|
+
* The client address of a router request: the same source JoinGate uses (the socket address unless trustProxy).
|
|
15
|
+
* @param headers The request headers.
|
|
16
|
+
* @returns The normalized address, or "" when unknown.
|
|
17
|
+
*/
|
|
18
|
+
static clientAddressOf(headers: Headers): string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether an address may reach the console at all (DR §6.3 step 1).
|
|
21
|
+
* @param clientAddress The client address.
|
|
22
|
+
* @returns True when admin.allowedNetworks is empty or lists the address.
|
|
23
|
+
*/
|
|
24
|
+
isNetworkAllowed(clientAddress: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a request is secure (R9): TLS on the server, or HTTPS reported by a trusted proxy.
|
|
27
|
+
* @param headers The request headers.
|
|
28
|
+
* @returns True for a secure request.
|
|
29
|
+
*/
|
|
30
|
+
isSecureRequest(headers: Headers): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The D9 transport rule: loopback, TLS, or HTTPS at a trusted proxy.
|
|
33
|
+
* @param headers The request headers.
|
|
34
|
+
* @param clientAddress The client address.
|
|
35
|
+
* @returns True when the console may answer this connection.
|
|
36
|
+
*/
|
|
37
|
+
isTransportSafe(headers: Headers, clientAddress: string): boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The connection checks every console page and API call passes first (game-server-admin-console D9, DR §6.3 steps 1
|
|
2
|
+
// and 4, §13 R9): the admin network restriction and the HTTPS rule.
|
|
3
|
+
import { createAuthContext } from "colyseus";
|
|
4
|
+
import { createNetworkList, isAddressInList, isLoopbackAddress, normalizeAddress } from "../NetworkAddresses.js";
|
|
5
|
+
/** The header a trusted proxy names the original scheme in. */
|
|
6
|
+
const FORWARDED_PROTO_HEADER = "x-forwarded-proto";
|
|
7
|
+
/** The scheme a secure request arrived with. */
|
|
8
|
+
const SECURE_SCHEME = "https";
|
|
9
|
+
/** Network restriction and transport rule of the console (D9). */
|
|
10
|
+
export class AdminRequestGate {
|
|
11
|
+
/** The resolved config. */
|
|
12
|
+
config;
|
|
13
|
+
/** admin.allowedNetworks as a block list, or null when every address may reach the console. */
|
|
14
|
+
allowedNetworks;
|
|
15
|
+
/**
|
|
16
|
+
* Builds the checks from the config.
|
|
17
|
+
* @param config The resolved config.
|
|
18
|
+
*/
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.allowedNetworks = (config.admin.allowedNetworks.length > 0) ? createNetworkList(config.admin.allowedNetworks) : null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The client address of a router request: the same source JoinGate uses (the socket address unless trustProxy).
|
|
25
|
+
* @param headers The request headers.
|
|
26
|
+
* @returns The normalized address, or "" when unknown.
|
|
27
|
+
*/
|
|
28
|
+
static clientAddressOf(headers) {
|
|
29
|
+
const address = createAuthContext({ headers: headers }).ip;
|
|
30
|
+
return (address != null) ? normalizeAddress(address) : "";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether an address may reach the console at all (DR §6.3 step 1).
|
|
34
|
+
* @param clientAddress The client address.
|
|
35
|
+
* @returns True when admin.allowedNetworks is empty or lists the address.
|
|
36
|
+
*/
|
|
37
|
+
isNetworkAllowed(clientAddress) {
|
|
38
|
+
if (this.allowedNetworks == null)
|
|
39
|
+
return true;
|
|
40
|
+
return isAddressInList(this.allowedNetworks, clientAddress);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether a request is secure (R9): TLS on the server, or HTTPS reported by a trusted proxy.
|
|
44
|
+
* @param headers The request headers.
|
|
45
|
+
* @returns True for a secure request.
|
|
46
|
+
*/
|
|
47
|
+
isSecureRequest(headers) {
|
|
48
|
+
return this.config.tls.enabled || (this.config.trustProxy && headers.get(FORWARDED_PROTO_HEADER) === SECURE_SCHEME);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The D9 transport rule: loopback, TLS, or HTTPS at a trusted proxy.
|
|
52
|
+
* @param headers The request headers.
|
|
53
|
+
* @param clientAddress The client address.
|
|
54
|
+
* @returns True when the console may answer this connection.
|
|
55
|
+
*/
|
|
56
|
+
isTransportSafe(headers, clientAddress) {
|
|
57
|
+
return isLoopbackAddress(clientAddress) || this.isSecureRequest(headers);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { AdminCallerKind } from "./AdminApiTypes.js";
|
|
2
|
+
/** Session cookie name over TLS (D10): the __Host- prefix pins it to this host, path / and Secure. */
|
|
3
|
+
export declare const SECURE_SESSION_COOKIE_NAME: string;
|
|
4
|
+
/** Session cookie name on loopback HTTP (D10). */
|
|
5
|
+
export declare const SESSION_COOKIE_NAME: string;
|
|
6
|
+
/** Headers on every console response (D9). */
|
|
7
|
+
export declare const SECURITY_HEADERS: Record<string, string>;
|
|
8
|
+
/** What a handler returns; the router turns it into a response (D5). */
|
|
9
|
+
export interface AdminResult {
|
|
10
|
+
/** HTTP status. */
|
|
11
|
+
status: number;
|
|
12
|
+
/** The JSON body (ignored for downloads and redirects). */
|
|
13
|
+
body: unknown;
|
|
14
|
+
/** Extra cookies, as full Set-Cookie values. */
|
|
15
|
+
setCookies?: string[];
|
|
16
|
+
/** Overrides the JSON body with raw bytes (downloads). */
|
|
17
|
+
download?: {
|
|
18
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
19
|
+
contentType: string;
|
|
20
|
+
fileName: string;
|
|
21
|
+
};
|
|
22
|
+
/** A redirect target (SSO). */
|
|
23
|
+
redirectTo?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The audit detail of a successful action (target and redacted parameters). A public sign-in route names the
|
|
26
|
+
* account that signed in as its actor, since the request had no caller yet.
|
|
27
|
+
*/
|
|
28
|
+
audit?: {
|
|
29
|
+
target: string;
|
|
30
|
+
parameters: Record<string, unknown>;
|
|
31
|
+
actor?: {
|
|
32
|
+
kind: AdminCallerKind;
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Builds the single-buffer answer of an API call (DR §7.3): JSON, a download, or a redirect, with the D9 headers, the
|
|
40
|
+
* console origin as the only CORS origin (credentials off, overriding the router's CORS answer) and each cookie.
|
|
41
|
+
* @param result The handler's result.
|
|
42
|
+
* @param request The console origin of the request.
|
|
43
|
+
* @returns The response.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildAdminResponse(result: AdminResult, request: {
|
|
46
|
+
consoleOrigin: string;
|
|
47
|
+
}): Response;
|
|
48
|
+
/**
|
|
49
|
+
* A JSON answer outside the API pipeline (static-path refusals), with the same single-buffer headers.
|
|
50
|
+
* @param status HTTP status.
|
|
51
|
+
* @param body The JSON body.
|
|
52
|
+
* @param consoleOrigin The console origin of the request.
|
|
53
|
+
* @returns The response.
|
|
54
|
+
*/
|
|
55
|
+
export declare function adminJsonResponse(status: number, body: unknown, consoleOrigin: string): Response;
|
|
56
|
+
/**
|
|
57
|
+
* A plain-text console answer (missing asset, console not built).
|
|
58
|
+
* @param status HTTP status.
|
|
59
|
+
* @param text The text.
|
|
60
|
+
* @returns The response.
|
|
61
|
+
*/
|
|
62
|
+
export declare function adminTextResponse(status: number, text: string): Response;
|
|
63
|
+
/**
|
|
64
|
+
* A static file answer.
|
|
65
|
+
* @param bytes The file.
|
|
66
|
+
* @param contentType Its content type.
|
|
67
|
+
* @param cacheControl Its cache-control value.
|
|
68
|
+
* @returns The response.
|
|
69
|
+
*/
|
|
70
|
+
export declare function staticFileResponse(bytes: Uint8Array<ArrayBuffer>, contentType: string, cacheControl: string): Response;
|
|
71
|
+
/**
|
|
72
|
+
* A permanent redirect (GET /game-server/admin → /game-server/admin/).
|
|
73
|
+
* @param location The target path.
|
|
74
|
+
* @returns The 308 response.
|
|
75
|
+
*/
|
|
76
|
+
export declare function redirectResponse(location: string): Response;
|
|
77
|
+
/**
|
|
78
|
+
* The name of the session cookie for a request (R9).
|
|
79
|
+
* @param secure True for a secure request (TLS, or HTTPS at a trusted proxy).
|
|
80
|
+
* @returns `__Host-bgs-admin` or `bgs-admin`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function sessionCookieName(secure: boolean): string;
|
|
83
|
+
/**
|
|
84
|
+
* The Set-Cookie value of a console session (D10).
|
|
85
|
+
* @param value The cookie value (a random session id).
|
|
86
|
+
* @param secure True for a secure request: adds Secure and uses the __Host- name.
|
|
87
|
+
* @param maxAgeSeconds How long the browser keeps it, in seconds.
|
|
88
|
+
* @returns The Set-Cookie value.
|
|
89
|
+
*/
|
|
90
|
+
export declare function buildSessionCookie(value: string, secure: boolean, maxAgeSeconds: number): string;
|
|
91
|
+
/**
|
|
92
|
+
* The Set-Cookie value that removes the session cookie (sign-out).
|
|
93
|
+
* @param secure True for a secure request.
|
|
94
|
+
* @returns The Set-Cookie value.
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildClearingCookie(secure: boolean): string;
|
|
97
|
+
/**
|
|
98
|
+
* The console's own origin, from the Host header and the D9 scheme rule.
|
|
99
|
+
* @param headers The request headers.
|
|
100
|
+
* @param secure True for a secure request.
|
|
101
|
+
* @returns scheme://host.
|
|
102
|
+
*/
|
|
103
|
+
export declare function consoleOriginOf(headers: Headers, secure: boolean): string;
|