@colyseus/core 0.18.12 → 0.18.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/core",
3
- "version": "0.18.12",
3
+ "version": "0.18.13",
4
4
  "description": "Multiplayer Framework for Node.js.",
5
5
  "type": "module",
6
6
  "input": "./src/index.ts",
@@ -51,9 +51,9 @@
51
51
  "debug": "^4.3.4",
52
52
  "msgpackr": "^2.0.1",
53
53
  "nanoid": "^3.3.11",
54
+ "@colyseus/greeting-banner": "^4.0.2",
54
55
  "@colyseus/shared-types": "^0.18.2",
55
- "@colyseus/better-call": "^1.3.1",
56
- "@colyseus/greeting-banner": "^4.0.2"
56
+ "@colyseus/better-call": "^1.3.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@colyseus/schema": "^5.0.8",
@@ -68,9 +68,9 @@
68
68
  "@pm2/io": "^6.1.0",
69
69
  "express": "^4.16.0 || ^5.0.0",
70
70
  "zod": "^4.1.12",
71
+ "@colyseus/better-call": "^1.3.1",
71
72
  "@colyseus/auth": "^0.18.2",
72
- "@colyseus/ws-transport": "^0.18.2",
73
- "@colyseus/better-call": "^1.3.1"
73
+ "@colyseus/ws-transport": "^0.18.2"
74
74
  },
75
75
  "peerDependenciesMeta": {
76
76
  "@colyseus/auth": {
package/src/Room.ts CHANGED
@@ -1790,15 +1790,22 @@ export class Room<T extends RoomOptions = RoomOptions> {
1790
1790
  try {
1791
1791
  if (authData) {
1792
1792
  client.auth = authData;
1793
+ }
1794
+
1795
+ // only an own static onAuth() skips instance/plugin onAuth, not @colyseus/auth's default
1796
+ const authedStatically = authData && (this.constructor as typeof Room).onAuth !== Room.onAuth;
1793
1797
 
1794
- } else if (this.onAuth !== Room.prototype.onAuth) {
1798
+ if (!authedStatically && this.onAuth !== Room.prototype.onAuth) {
1795
1799
  try {
1796
- client.auth = await this.onAuth(client, joinOptions, authContext);
1800
+ const result = await this.onAuth(client, joinOptions, authContext);
1797
1801
 
1798
- if (!client.auth) {
1802
+ if (!result) {
1799
1803
  throw new ServerError(ErrorCode.AUTH_FAILED, 'onAuth failed');
1800
1804
  }
1801
1805
 
1806
+ // `true` adds nothing: keep the payload the default static onAuth decoded
1807
+ client.auth = (result === true && authData) || result;
1808
+
1802
1809
  } catch (e) {
1803
1810
  // remove seat reservation
1804
1811
  delete this._reservedSeats[sessionId];