Merge remote-tracking branch 'duckie/main' into merge-duckie-main-2026-05-06

# Conflicts:
#	packages/communication/src/messages/parser/room/unit/RoomUnitInfoParser.ts
#	packages/communication/src/messages/parser/user/data/UserProfileParser.ts
#	packages/events/src/session/RoomSessionUserFigureUpdateEvent.ts
#	packages/session/src/handler/RoomUsersHandler.ts
This commit is contained in:
Lorenzune
2026-05-06 04:23:13 +02:00
24 changed files with 493 additions and 813 deletions
@@ -5,7 +5,7 @@ import { GetTickerTime, NitroLogger } from '@nitrots/utils';
import { NitroMessages } from './NitroMessages';
import { SocketConnection } from './SocketConnection';
import { AuthenticatedEvent, ClientHelloMessageComposer, ClientPingEvent, InfoRetrieveMessageComposer, PongMessageComposer, SSOTicketMessageComposer, UniqueIDMessageComposer } from './messages';
import { ClientJS } from 'clientjs';
import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
export class CommunicationManager implements ICommunicationManager
{
@@ -19,84 +19,34 @@ export class CommunicationManager implements ICommunicationManager
private _socketErrorCallback: () => void = null;
private _socketReconnectedCallback: () => void = null;
private _machineId: string = null;
private _machineIdPromise: Promise<string> = null;
private _initResolved: boolean = false;
private getGpu(): string {
const e = document.createElement('canvas');
let t, s, i, r;
try {
if (
((t = e.getContext('webgl') || e.getContext('experimental-webgl')), (s = t.getExtension('WEBGL_debug_renderer_info')), null === t || null === s))
return '';
} catch (n) {
return '';
}
return ((i = t.getParameter(s.UNMASKED_VENDOR_WEBGL)), (r = t.getParameter(s.UNMASKED_RENDERER_WEBGL)), i + '|' + r);
}
private getMathResult(): string {
let e, t;
(e = '<mathroutines>Error</mathroutines>'), (t = '');
try {
return (
(t ='<mathroutines>' + (Math.exp(10) + 1 / Math.exp(10)) / 2 + '|' + Math.tan(-1e300) + '</mathroutines>'), t);
} catch (s) {
return '<mathroutines>Error</mathroutines>';
}
}
private getCanvas(): any {
const e = document.createElement('canvas'), t = e.getContext('2d'), userAgent = navigator.userAgent, screenInfo = '${window.screen.width}x${window.screen.height}', currentDate = new Date().toString(), s = 'ThiosIsVerrySeCuRe02938883721moreStuff! | ${userAgent} | ${screenInfo} | ${currentDate}';
t.textBaseline = 'top';
t.font = "16px 'Arial'";
t.textBaseline = 'alphabetic';
t.rotate(0.05);
t.fillStyle = '#f60';
t.fillRect(125, 1, 62, 20);
t.fillStyle = '#069';
t.fillText(s, 2, 15);
t.fillStyle = 'rgba(102, 200, 0, 0.7)';
t.fillText(s, 4, 17);
t.shadowBlur = 10;
t.shadowColor = 'blue';
t.fillRect(-20, 10, 234, 5);
const i = e.toDataURL();
e.width = 0;
e.height = 0;
let r = 0;
if (i.length === 0) return 'nothing!';
for (let n = 0; n < i.length; n++) {
r = (r << 5) - r + i.charCodeAt(n);
r &= r;
}
return r;
}
private generateMachineID(): string {
const fp = new ClientJS();
const uniqueId = fp.getCustomFingerprint(
fp.getAvailableResolution(),
fp.getOS(),
fp.getCPU(),
fp.getColorDepth(),
this.getGpu(),
fp.getSilverlightVersion(),
fp.getOSVersion(),
this.getMathResult(),
fp.getCanvasPrint(),
this.getCanvas()
);
return uniqueId == null ? 'FAILED' : `IID-${uniqueId}`;
}
private sendHandshake(): void
private async generateMachineID(): Promise<string>
{
if(!this._machineId) this._machineId = this.generateMachineID();
try
{
const result = await new Thumbmark().get();
return result.thumbmark ? `IID-${result.thumbmark}` : 'FAILED';
}
catch(error)
{
NitroLogger.warn('[CommunicationManager] Failed to generate machine ID', error);
return 'FAILED';
}
}
private async sendHandshake(): Promise<void>
{
if(!this._machineIdPromise) this._machineIdPromise = this.generateMachineID();
const machineId = await this._machineIdPromise;
this._connection.send(new ClientHelloMessageComposer(null, null, null, null));
this._connection.send(new SSOTicketMessageComposer(GetConfiguration().getValue('sso.ticket', null), GetTickerTime()));
this._connection.send(new UniqueIDMessageComposer(this._machineId, '', ''));
this._connection.send(new UniqueIDMessageComposer(machineId, '', ''));
}
constructor()
@@ -120,7 +70,7 @@ export class CommunicationManager implements ICommunicationManager
if(GetConfiguration().getValue<boolean>('system.pong.manually', false)) this.startPong();
this.sendHandshake();
void this.sendHandshake();
};
GetEventDispatcher().addEventListener(NitroEventType.SOCKET_RECONNECTED, this._socketReconnectedCallback);
@@ -131,7 +81,7 @@ export class CommunicationManager implements ICommunicationManager
{
if(GetConfiguration().getValue<boolean>('system.pong.manually', false)) this.startPong();
this.sendHandshake();
void this.sendHandshake();
};
GetEventDispatcher().addEventListener(NitroEventType.SOCKET_OPENED, this._socketOpenedCallback);
@@ -4,9 +4,9 @@ export class RoomUnitBackgroundComposer implements IMessageComposer<ConstructorP
{
private _data: ConstructorParameters<typeof RoomUnitBackgroundComposer>;
constructor(backgroundImage: number, backgroundStand: number, backgroundOverlay: number)
constructor(backgroundImage: number, backgroundStand: number, backgroundOverlay: number, backgroundCard: number = 0)
{
this._data = [ backgroundImage, backgroundStand, backgroundOverlay ];
this._data = [ backgroundImage, backgroundStand, backgroundOverlay, backgroundCard ];
}
public getMessageArray()
@@ -10,6 +10,7 @@ export class RoomUnitInfoParser implements IMessageParser
private _backgroundId: number;
private _standId: number;
private _overlayId: number;
private _cardBackgroundId: number;
private _nickIcon: string;
private _prefixText: string;
private _prefixColor: string;
@@ -28,6 +29,7 @@ export class RoomUnitInfoParser implements IMessageParser
this._backgroundId = 0;
this._standId = 0;
this._overlayId = 0;
this._cardBackgroundId = 0;
this._nickIcon = '';
this._prefixText = '';
this._prefixColor = '';
@@ -51,6 +53,7 @@ export class RoomUnitInfoParser implements IMessageParser
this._backgroundId = wrapper.readInt();
this._standId = wrapper.readInt();
this._overlayId = wrapper.readInt();
this._cardBackgroundId = (wrapper.bytesAvailable ? wrapper.readInt() : 0);
this._nickIcon = (wrapper.bytesAvailable ? wrapper.readString() : '');
this._prefixText = (wrapper.bytesAvailable ? wrapper.readString() : '');
this._prefixColor = (wrapper.bytesAvailable ? wrapper.readString() : '');
@@ -102,6 +105,11 @@ export class RoomUnitInfoParser implements IMessageParser
return this._overlayId;
}
public get cardBackgroundId(): number
{
return this._cardBackgroundId;
}
public get nickIcon(): string
{
return this._nickIcon;
@@ -37,6 +37,7 @@ export class RoomUnitParser implements IMessageParser
const background = wrapper.readInt();
const stand = wrapper.readInt();
const overlay = wrapper.readInt();
const cardBackground = wrapper.readInt();
let figure = wrapper.readString();
const roomIndex = wrapper.readInt();
const x = wrapper.readInt();
@@ -53,6 +54,7 @@ export class RoomUnitParser implements IMessageParser
user.background = background;
user.stand = stand;
user.overlay = overlay;
user.cardBackground = cardBackground;
user.x = x;
user.y = y;
user.z = z;
@@ -24,6 +24,7 @@ export class UserMessageData
private _background: number = 0;
private _stand: number = 0;
private _overlay: number = 0;
private _cardBackground: number = 0;
private _webID: number = 0;
private _groupID: number = 0;
private _groupStatus: number = 0;
@@ -221,6 +222,16 @@ export class UserMessageData
this._overlay = k;
}
public get cardBackground(): number
{
return this._cardBackground;
}
public set cardBackground(k: number)
{
this._cardBackground = k;
}
public get webID(): number
{
return this._webID;
@@ -19,6 +19,7 @@ export class UserProfileParser implements IMessageParser
private _backgroundId: number;
private _standId: number;
private _overlayId: number;
private _cardBackgroundId: number;
private _nickIcon: string;
private _prefixText: string;
private _prefixColor: string;
@@ -45,6 +46,7 @@ export class UserProfileParser implements IMessageParser
this._backgroundId = 0;
this._standId = 0;
this._overlayId = 0;
this._cardBackgroundId = 0;
this._nickIcon = '';
this._prefixText = '';
this._prefixColor = '';
@@ -86,6 +88,8 @@ export class UserProfileParser implements IMessageParser
this._standId = wrapper.readInt();
this._overlayId = wrapper.readInt();
this._cardBackgroundId = (wrapper.bytesAvailable ? wrapper.readInt() : 0);
if(wrapper.bytesAvailable)
{
this._nickIcon = wrapper.readString();
@@ -185,6 +189,11 @@ export class UserProfileParser implements IMessageParser
return this._overlayId;
}
public get cardBackgroundId(): number
{
return this._cardBackgroundId;
}
public get nickIcon(): string
{
return this._nickIcon;