@ughuuu/game_server 1.0.1026 → 1.0.1029

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 (149) hide show
  1. package/README.md +1 -1
  2. package/dist/ApiClient.js +1 -1
  3. package/dist/api/AchievementsApi.js +3 -3
  4. package/dist/api/AdminAchievementsApi.js +5 -5
  5. package/dist/api/AdminChatApi.js +9 -9
  6. package/dist/api/AdminGroupsApi.js +5 -5
  7. package/dist/api/AdminKVApi.js +13 -13
  8. package/dist/api/AdminLeaderboardsApi.js +21 -21
  9. package/dist/api/AdminLobbiesApi.js +5 -5
  10. package/dist/api/AdminNotificationsApi.js +7 -7
  11. package/dist/api/AdminSessionsApi.js +5 -5
  12. package/dist/api/AdminUsersApi.js +5 -5
  13. package/dist/api/AuthenticationApi.js +1 -1
  14. package/dist/api/ChatApi.js +11 -11
  15. package/dist/api/FriendsApi.js +11 -11
  16. package/dist/api/GroupsApi.js +41 -41
  17. package/dist/api/HealthApi.js +1 -1
  18. package/dist/api/HooksApi.js +1 -1
  19. package/dist/api/KVApi.js +5 -5
  20. package/dist/api/LeaderboardsApi.js +11 -11
  21. package/dist/api/LobbiesApi.js +5 -5
  22. package/dist/api/NotificationsApi.js +1 -1
  23. package/dist/api/PartiesApi.js +3 -3
  24. package/dist/api/PaymentsApi.js +1 -1
  25. package/dist/api/UsersApi.js +3 -3
  26. package/dist/model/AcceptPartyInvite200Response.js +13 -5
  27. package/dist/model/AcceptPartyInvite200ResponseMembersInner.js +7 -3
  28. package/dist/model/AcceptPartyInviteRequest.js +8 -4
  29. package/dist/model/AdminCreateAchievementRequest.js +1 -1
  30. package/dist/model/AdminCreateLeaderboard200Response.js +1 -1
  31. package/dist/model/AdminCreateLeaderboard200ResponseData.js +7 -3
  32. package/dist/model/AdminCreateLeaderboardRequest.js +1 -1
  33. package/dist/model/AdminCreateNotificationRequest.js +15 -7
  34. package/dist/model/AdminDeleteChatConversation200Response.js +1 -1
  35. package/dist/model/AdminGrantAchievementRequest.js +8 -4
  36. package/dist/model/AdminIncrementAchievementRequest.js +8 -4
  37. package/dist/model/AdminListAchievements200Response.js +1 -1
  38. package/dist/model/AdminListAchievements200ResponseDataInner.js +7 -3
  39. package/dist/model/AdminListChatMessages200Response.js +1 -1
  40. package/dist/model/AdminListChatMessages200ResponseDataInner.js +19 -7
  41. package/dist/model/AdminListGroups200Response.js +1 -1
  42. package/dist/model/AdminListKvEntries200Response.js +1 -1
  43. package/dist/model/AdminListLobbies200Response.js +1 -1
  44. package/dist/model/AdminListLobbies200ResponseDataInner.js +13 -5
  45. package/dist/model/AdminListNotifications200Response.js +1 -1
  46. package/dist/model/AdminListNotifications200ResponseDataInner.js +19 -7
  47. package/dist/model/AdminListSessions200Response.js +1 -1
  48. package/dist/model/AdminListSessions200ResponseDataInner.js +13 -5
  49. package/dist/model/AdminRevokeAchievementRequest.js +15 -7
  50. package/dist/model/AdminSubmitLeaderboardScoreRequest.js +7 -3
  51. package/dist/model/AdminUpdateAchievementRequest.js +1 -1
  52. package/dist/model/AdminUpdateGroup200Response.js +13 -5
  53. package/dist/model/AdminUpdateGroupRequest.js +1 -1
  54. package/dist/model/AdminUpdateKvEntryRequest.js +13 -5
  55. package/dist/model/AdminUpdateLeaderboardRecord200Response.js +1 -1
  56. package/dist/model/AdminUpdateLeaderboardRecord200ResponseData.js +19 -7
  57. package/dist/model/AdminUpdateLeaderboardRecordRequest.js +1 -1
  58. package/dist/model/AdminUpdateLeaderboardRequest.js +1 -1
  59. package/dist/model/AdminUpdateLobby200Response.js +1 -1
  60. package/dist/model/AdminUpdateUser200Response.js +1 -1
  61. package/dist/model/AdminUpdateUser200ResponseData.js +13 -5
  62. package/dist/model/AdminUpdateUserRequest.js +1 -1
  63. package/dist/model/AdminUpsertKv200Response.js +1 -1
  64. package/dist/model/AdminUpsertKv200ResponseData.js +19 -7
  65. package/dist/model/AdminUpsertKvRequest.js +13 -5
  66. package/dist/model/ApproveJoinRequest200Response.js +19 -7
  67. package/dist/model/CallHook200Response.js +1 -1
  68. package/dist/model/CallHookRequest.js +1 -1
  69. package/dist/model/CancelJoinRequest200Response.js +19 -7
  70. package/dist/model/ChatUnreadCount200Response.js +1 -1
  71. package/dist/model/CreateGroupRequest.js +1 -1
  72. package/dist/model/CreateLobbyRequest.js +1 -1
  73. package/dist/model/CreatePartyRequest.js +1 -1
  74. package/dist/model/DeclineGroupInvite200Response.js +1 -1
  75. package/dist/model/DeleteNotificationsRequest.js +1 -1
  76. package/dist/model/DeviceLoginRequest.js +1 -1
  77. package/dist/model/ErrorResponse.js +1 -1
  78. package/dist/model/GetCurrentUser200Response.js +19 -7
  79. package/dist/model/GetCurrentUser200ResponseLinkedProviders.js +1 -1
  80. package/dist/model/GetKv200Response.js +1 -1
  81. package/dist/model/GetLobby200Response.js +1 -1
  82. package/dist/model/GetMyRecord200Response.js +1 -1
  83. package/dist/model/GetMyRecord200ResponseData.js +8 -4
  84. package/dist/model/HealthResponse.js +1 -1
  85. package/dist/model/InviteToPartyRequest.js +8 -4
  86. package/dist/model/ListBlockedFriends200Response.js +1 -1
  87. package/dist/model/ListBlockedFriends200ResponseDataInner.js +7 -3
  88. package/dist/model/ListBlockedFriends200ResponseDataInnerRequester.js +7 -3
  89. package/dist/model/ListChatMessages200Response.js +1 -1
  90. package/dist/model/ListChatMessages200ResponseDataInner.js +19 -7
  91. package/dist/model/ListFriendRequests200Response.js +1 -1
  92. package/dist/model/ListFriendRequests200ResponseIncomingInner.js +7 -3
  93. package/dist/model/ListFriendRequests200ResponseIncomingInnerRequester.js +7 -3
  94. package/dist/model/ListFriendRequests200ResponseMeta.js +1 -1
  95. package/dist/model/ListFriends200Response.js +1 -1
  96. package/dist/model/ListFriends200ResponseDataInner.js +13 -5
  97. package/dist/model/ListFriends200ResponseMeta.js +1 -1
  98. package/dist/model/ListGroupMembers200Response.js +1 -1
  99. package/dist/model/ListJoinRequests200Response.js +1 -1
  100. package/dist/model/ListLeaderboardRecords200Response.js +1 -1
  101. package/dist/model/ListLeaderboards200Response.js +1 -1
  102. package/dist/model/ListLobbies200Response.js +1 -1
  103. package/dist/model/ListLobbies200ResponseDataInner.js +13 -5
  104. package/dist/model/ListMyGroups200Response.js +1 -1
  105. package/dist/model/ListMyGroups200ResponseDataInner.js +13 -5
  106. package/dist/model/ListPartyInvitations200ResponseInner.js +25 -9
  107. package/dist/model/ListRecordsAroundUser200Response.js +1 -1
  108. package/dist/model/ListSentInvitations200Response.js +1 -1
  109. package/dist/model/ListSentInvitations200ResponseDataInner.js +25 -9
  110. package/dist/model/LoginRequest.js +1 -1
  111. package/dist/model/MarkChatReadRequest.js +15 -7
  112. package/dist/model/MyAchievements200Response.js +1 -1
  113. package/dist/model/MyAchievements200ResponseDataInner.js +7 -3
  114. package/dist/model/NotifyGroup200Response.js +1 -1
  115. package/dist/model/NotifyGroupRequest.js +1 -1
  116. package/dist/model/OAuthSessionData.js +7 -3
  117. package/dist/model/OAuthSessionDataDetails.js +1 -1
  118. package/dist/model/OAuthSessionStatus.js +1 -1
  119. package/dist/model/OauthApiCallback200Response.js +1 -1
  120. package/dist/model/OauthApiCallbackRequest.js +1 -1
  121. package/dist/model/OauthCallbackApiAppleIosRequest.js +1 -1
  122. package/dist/model/OauthGoogleIdTokenRequest.js +1 -1
  123. package/dist/model/OauthRequest200Response.js +1 -1
  124. package/dist/model/OauthSessionStatus404Response.js +1 -1
  125. package/dist/model/PartyCreateLobbyRequest.js +1 -1
  126. package/dist/model/PartyJoinLobbyRequest.js +1 -1
  127. package/dist/model/PaymentsEntitlements401Response.js +1 -1
  128. package/dist/model/PaymentsSteamCheckoutRequest.js +7 -3
  129. package/dist/model/PaymentsSteamFinalizeRequest.js +1 -1
  130. package/dist/model/PaymentsStripeCheckoutRequest.js +7 -3
  131. package/dist/model/QuickJoinRequest.js +1 -1
  132. package/dist/model/RefreshToken200Response.js +1 -1
  133. package/dist/model/RefreshToken200ResponseData.js +7 -3
  134. package/dist/model/RefreshTokenRequest.js +1 -1
  135. package/dist/model/ResolveLeaderboardSlugs200Response.js +1 -1
  136. package/dist/model/ResolveLeaderboardSlugs200ResponseDataValue.js +7 -3
  137. package/dist/model/ResolveLeaderboardSlugsRequest.js +1 -1
  138. package/dist/model/SearchUsers200Response.js +1 -1
  139. package/dist/model/SearchUsers200ResponseDataInner.js +19 -7
  140. package/dist/model/SendChatMessageRequest.js +8 -4
  141. package/dist/model/SendNotificationRequest.js +8 -4
  142. package/dist/model/UpdateChatMessageRequest.js +1 -1
  143. package/dist/model/UpdateCurrentUserDisplayName400Response.js +1 -1
  144. package/dist/model/UpdateCurrentUserDisplayNameRequest.js +1 -1
  145. package/dist/model/UpdateCurrentUserPasswordRequest.js +1 -1
  146. package/dist/model/UpdateGroupRequest.js +1 -1
  147. package/dist/model/UpdateLobbyRequest.js +1 -1
  148. package/dist/model/UpdatePartyRequest.js +1 -1
  149. package/package.json +1 -1
@@ -19,7 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
19
19
  * Game Server API
20
20
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
21
21
  *
22
- * The version of the OpenAPI document: 1.0.1026
22
+ * The version of the OpenAPI document: 1.0.1029
23
23
  *
24
24
  *
25
25
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -47,7 +47,7 @@ var AdminLobbiesApi = exports["default"] = /*#__PURE__*/function () {
47
47
 
48
48
  /**
49
49
  * Delete lobby by id (admin)
50
- * @param {Number} id
50
+ * @param {String} id
51
51
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
52
52
  */
53
53
  return _createClass(AdminLobbiesApi, [{
@@ -73,7 +73,7 @@ var AdminLobbiesApi = exports["default"] = /*#__PURE__*/function () {
73
73
 
74
74
  /**
75
75
  * Delete lobby by id (admin)
76
- * @param {Number} id
76
+ * @param {String} id
77
77
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
78
78
  */
79
79
  }, {
@@ -145,7 +145,7 @@ var AdminLobbiesApi = exports["default"] = /*#__PURE__*/function () {
145
145
 
146
146
  /**
147
147
  * Update lobby by id (admin)
148
- * @param {Number} id
148
+ * @param {String} id
149
149
  * @param {Object} opts Optional parameters
150
150
  * @param {module:model/UpdateLobbyRequest} [updateLobbyRequest] Lobby patch
151
151
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpdateLobby200Response} and HTTP response
@@ -174,7 +174,7 @@ var AdminLobbiesApi = exports["default"] = /*#__PURE__*/function () {
174
174
 
175
175
  /**
176
176
  * Update lobby by id (admin)
177
- * @param {Number} id
177
+ * @param {String} id
178
178
  * @param {Object} opts Optional parameters
179
179
  * @param {module:model/UpdateLobbyRequest} opts.updateLobbyRequest Lobby patch
180
180
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpdateLobby200Response}
@@ -19,7 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
19
19
  * Game Server API
20
20
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
21
21
  *
22
- * The version of the OpenAPI document: 1.0.1026
22
+ * The version of the OpenAPI document: 1.0.1029
23
23
  *
24
24
  *
25
25
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -86,7 +86,7 @@ var AdminNotificationsApi = exports["default"] = /*#__PURE__*/function () {
86
86
  /**
87
87
  * Delete a notification (admin)
88
88
  * Delete a notification by ID (no ownership check).
89
- * @param {Number} id Notification ID
89
+ * @param {String} id Notification ID
90
90
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
91
91
  */
92
92
  }, {
@@ -113,7 +113,7 @@ var AdminNotificationsApi = exports["default"] = /*#__PURE__*/function () {
113
113
  /**
114
114
  * Delete a notification (admin)
115
115
  * Delete a notification by ID (no ownership check).
116
- * @param {Number} id Notification ID
116
+ * @param {String} id Notification ID
117
117
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
118
118
  */
119
119
  }, {
@@ -128,8 +128,8 @@ var AdminNotificationsApi = exports["default"] = /*#__PURE__*/function () {
128
128
  * List all notifications (admin)
129
129
  * Return all notifications across all users. Supports filtering by recipient user_id, sender_id, and title.
130
130
  * @param {Object} opts Optional parameters
131
- * @param {Number} [userId] Filter by recipient user ID
132
- * @param {Number} [senderId] Filter by sender user ID
131
+ * @param {String} [userId] Filter by recipient user ID
132
+ * @param {String} [senderId] Filter by sender user ID
133
133
  * @param {String} [title] Filter by title (partial match)
134
134
  * @param {Number} [page] Page number (1-based)
135
135
  * @param {Number} [pageSize] Page size
@@ -161,8 +161,8 @@ var AdminNotificationsApi = exports["default"] = /*#__PURE__*/function () {
161
161
  * List all notifications (admin)
162
162
  * Return all notifications across all users. Supports filtering by recipient user_id, sender_id, and title.
163
163
  * @param {Object} opts Optional parameters
164
- * @param {Number} opts.userId Filter by recipient user ID
165
- * @param {Number} opts.senderId Filter by sender user ID
164
+ * @param {String} opts.userId Filter by recipient user ID
165
+ * @param {String} opts.senderId Filter by sender user ID
166
166
  * @param {String} opts.title Filter by title (partial match)
167
167
  * @param {Number} opts.page Page number (1-based)
168
168
  * @param {Number} opts.pageSize Page size
@@ -17,7 +17,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  * Game Server API
18
18
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
19
19
  *
20
- * The version of the OpenAPI document: 1.0.1026
20
+ * The version of the OpenAPI document: 1.0.1029
21
21
  *
22
22
  *
23
23
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -45,7 +45,7 @@ var AdminSessionsApi = exports["default"] = /*#__PURE__*/function () {
45
45
 
46
46
  /**
47
47
  * Delete session token by id (admin)
48
- * @param {Number} id
48
+ * @param {String} id
49
49
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
50
50
  */
51
51
  return _createClass(AdminSessionsApi, [{
@@ -71,7 +71,7 @@ var AdminSessionsApi = exports["default"] = /*#__PURE__*/function () {
71
71
 
72
72
  /**
73
73
  * Delete session token by id (admin)
74
- * @param {Number} id
74
+ * @param {String} id
75
75
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
76
76
  */
77
77
  }, {
@@ -84,7 +84,7 @@ var AdminSessionsApi = exports["default"] = /*#__PURE__*/function () {
84
84
 
85
85
  /**
86
86
  * Delete all session tokens for a user (admin)
87
- * @param {Number} id
87
+ * @param {String} id
88
88
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
89
89
  */
90
90
  }, {
@@ -110,7 +110,7 @@ var AdminSessionsApi = exports["default"] = /*#__PURE__*/function () {
110
110
 
111
111
  /**
112
112
  * Delete all session tokens for a user (admin)
113
- * @param {Number} id
113
+ * @param {String} id
114
114
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
115
115
  */
116
116
  }, {
@@ -18,7 +18,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
18
18
  * Game Server API
19
19
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
20
20
  *
21
- * The version of the OpenAPI document: 1.0.1026
21
+ * The version of the OpenAPI document: 1.0.1029
22
22
  *
23
23
  *
24
24
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -46,7 +46,7 @@ var AdminUsersApi = exports["default"] = /*#__PURE__*/function () {
46
46
 
47
47
  /**
48
48
  * Delete user (admin)
49
- * @param {Number} id
49
+ * @param {String} id
50
50
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
51
51
  */
52
52
  return _createClass(AdminUsersApi, [{
@@ -72,7 +72,7 @@ var AdminUsersApi = exports["default"] = /*#__PURE__*/function () {
72
72
 
73
73
  /**
74
74
  * Delete user (admin)
75
- * @param {Number} id
75
+ * @param {String} id
76
76
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
77
77
  */
78
78
  }, {
@@ -85,7 +85,7 @@ var AdminUsersApi = exports["default"] = /*#__PURE__*/function () {
85
85
 
86
86
  /**
87
87
  * Update user (admin)
88
- * @param {Number} id
88
+ * @param {String} id
89
89
  * @param {Object} opts Optional parameters
90
90
  * @param {module:model/AdminUpdateUserRequest} [adminUpdateUserRequest] User patch
91
91
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpdateUser200Response} and HTTP response
@@ -114,7 +114,7 @@ var AdminUsersApi = exports["default"] = /*#__PURE__*/function () {
114
114
 
115
115
  /**
116
116
  * Update user (admin)
117
- * @param {Number} id
117
+ * @param {String} id
118
118
  * @param {Object} opts Optional parameters
119
119
  * @param {module:model/AdminUpdateUserRequest} opts.adminUpdateUserRequest User patch
120
120
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpdateUser200Response}
@@ -28,7 +28,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
28
28
  * Game Server API
29
29
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
30
30
  *
31
- * The version of the OpenAPI document: 1.0.1026
31
+ * The version of the OpenAPI document: 1.0.1029
32
32
  *
33
33
  *
34
34
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -21,7 +21,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
21
21
  * Game Server API
22
22
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
23
23
  *
24
- * The version of the OpenAPI document: 1.0.1026
24
+ * The version of the OpenAPI document: 1.0.1029
25
25
  *
26
26
  *
27
27
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -51,7 +51,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
51
51
  * Get unread message count
52
52
  * Get the number of unread messages for the current user in a chat conversation.
53
53
  * @param {module:model/String} chatType
54
- * @param {Number} chatRefId
54
+ * @param {String} chatRefId
55
55
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ChatUnreadCount200Response} and HTTP response
56
56
  */
57
57
  return _createClass(ChatApi, [{
@@ -84,7 +84,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
84
84
  * Get unread message count
85
85
  * Get the number of unread messages for the current user in a chat conversation.
86
86
  * @param {module:model/String} chatType
87
- * @param {Number} chatRefId
87
+ * @param {String} chatRefId
88
88
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ChatUnreadCount200Response}
89
89
  */
90
90
  }, {
@@ -98,7 +98,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
98
98
  /**
99
99
  * Delete your own chat message
100
100
  * Permanently delete a message you sent. Only the sender can delete their own message.
101
- * @param {Number} id Message ID
101
+ * @param {String} id Message ID
102
102
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
103
103
  */
104
104
  }, {
@@ -125,7 +125,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
125
125
  /**
126
126
  * Delete your own chat message
127
127
  * Permanently delete a message you sent. Only the sender can delete their own message.
128
- * @param {Number} id Message ID
128
+ * @param {String} id Message ID
129
129
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
130
130
  */
131
131
  }, {
@@ -139,7 +139,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
139
139
  /**
140
140
  * Get a single chat message
141
141
  * Retrieve a single chat message by ID. Useful for refreshing a message after an update notification.
142
- * @param {Number} id Message ID
142
+ * @param {String} id Message ID
143
143
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListChatMessages200ResponseDataInner} and HTTP response
144
144
  */
145
145
  }, {
@@ -166,7 +166,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
166
166
  /**
167
167
  * Get a single chat message
168
168
  * Retrieve a single chat message by ID. Useful for refreshing a message after an update notification.
169
- * @param {Number} id Message ID
169
+ * @param {String} id Message ID
170
170
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListChatMessages200ResponseDataInner}
171
171
  */
172
172
  }, {
@@ -181,7 +181,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
181
181
  * List chat messages
182
182
  * List messages for a lobby, group, party, or friend conversation. Paginated, newest first.
183
183
  * @param {module:model/String} chatType Type of chat
184
- * @param {Number} chatRefId Reference ID (lobby_id, group_id, party_id, or friend user_id)
184
+ * @param {String} chatRefId Reference ID (lobby_id, group_id, party_id, or friend user_id)
185
185
  * @param {Object} opts Optional parameters
186
186
  * @param {Number} [page = 1)] Page number
187
187
  * @param {Number} [pageSize = 25)] Items per page (max 100)
@@ -220,7 +220,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
220
220
  * List chat messages
221
221
  * List messages for a lobby, group, party, or friend conversation. Paginated, newest first.
222
222
  * @param {module:model/String} chatType Type of chat
223
- * @param {Number} chatRefId Reference ID (lobby_id, group_id, party_id, or friend user_id)
223
+ * @param {String} chatRefId Reference ID (lobby_id, group_id, party_id, or friend user_id)
224
224
  * @param {Object} opts Optional parameters
225
225
  * @param {Number} opts.page Page number (default to 1)
226
226
  * @param {Number} opts.pageSize Items per page (max 100) (default to 25)
@@ -313,7 +313,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
313
313
  /**
314
314
  * Update your own chat message
315
315
  * Edit the content or metadata of a message you sent. Only the sender can update their own message.
316
- * @param {Number} id Message ID
316
+ * @param {String} id Message ID
317
317
  * @param {Object} opts Optional parameters
318
318
  * @param {module:model/UpdateChatMessageRequest} [updateChatMessageRequest] Message update
319
319
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListChatMessages200ResponseDataInner} and HTTP response
@@ -343,7 +343,7 @@ var ChatApi = exports["default"] = /*#__PURE__*/function () {
343
343
  /**
344
344
  * Update your own chat message
345
345
  * Edit the content or metadata of a message you sent. Only the sender can update their own message.
346
- * @param {Number} id Message ID
346
+ * @param {String} id Message ID
347
347
  * @param {Object} opts Optional parameters
348
348
  * @param {module:model/UpdateChatMessageRequest} opts.updateChatMessageRequest Message update
349
349
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListChatMessages200ResponseDataInner}
@@ -21,7 +21,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
21
21
  * Game Server API
22
22
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
23
23
  *
24
- * The version of the OpenAPI document: 1.0.1026
24
+ * The version of the OpenAPI document: 1.0.1029
25
25
  *
26
26
  *
27
27
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -49,7 +49,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
49
49
 
50
50
  /**
51
51
  * Accept a friend request
52
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
52
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
53
53
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
54
54
  */
55
55
  return _createClass(FriendsApi, [{
@@ -75,7 +75,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
75
75
 
76
76
  /**
77
77
  * Accept a friend request
78
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
78
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
79
79
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
80
80
  */
81
81
  }, {
@@ -88,7 +88,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
88
88
 
89
89
  /**
90
90
  * Block a friend request / user
91
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
91
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
92
92
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
93
93
  */
94
94
  }, {
@@ -114,7 +114,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
114
114
 
115
115
  /**
116
116
  * Block a friend request / user
117
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
117
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
118
118
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
119
119
  */
120
120
  }, {
@@ -286,7 +286,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
286
286
 
287
287
  /**
288
288
  * Reject a friend request
289
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
289
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
290
290
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
291
291
  */
292
292
  }, {
@@ -312,7 +312,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
312
312
 
313
313
  /**
314
314
  * Reject a friend request
315
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
315
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
316
316
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
317
317
  */
318
318
  }, {
@@ -325,7 +325,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
325
325
 
326
326
  /**
327
327
  * Remove/cancel a friendship or request
328
- * @param {Number} id
328
+ * @param {String} id
329
329
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
330
330
  */
331
331
  }, {
@@ -351,7 +351,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
351
351
 
352
352
  /**
353
353
  * Remove/cancel a friendship or request
354
- * @param {Number} id
354
+ * @param {String} id
355
355
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
356
356
  */
357
357
  }, {
@@ -364,7 +364,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
364
364
 
365
365
  /**
366
366
  * Unblock a previously-blocked friendship
367
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
367
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
368
368
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
369
369
  */
370
370
  }, {
@@ -390,7 +390,7 @@ var FriendsApi = exports["default"] = /*#__PURE__*/function () {
390
390
 
391
391
  /**
392
392
  * Unblock a previously-blocked friendship
393
- * @param {Number} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
393
+ * @param {String} id Friendship record id (friendship_id) - the id of the friendship row, not a user id
394
394
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
395
395
  */
396
396
  }, {