baltica 0.0.10 → 0.0.12
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/dist/bridge/bridge-options.d.ts +0 -9
- package/dist/bridge/bridge-player.d.ts +1 -1
- package/dist/bridge/bridge.js +6 -6
- package/dist/bridge/index.d.ts +3 -0
- package/dist/{network/packets → bridge}/index.js +3 -9
- package/dist/client/client-data.js +13 -1
- package/dist/client/client-options.d.ts +16 -23
- package/dist/client/client-options.js +24 -15
- package/dist/client/client.js +4 -6
- package/dist/client/types/payload.d.ts +0 -1
- package/dist/client/types/payload.js +0 -1
- package/dist/client/types/skin/Skin.json +42 -28
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/network/auth.d.ts +2 -1
- package/dist/network/auth.js +17 -2
- package/dist/server/player.d.ts +1 -0
- package/dist/server/player.js +51 -38
- package/dist/server/server-options.d.ts +1 -4
- package/dist/server/server-options.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +11 -11
- package/dist/network/packets/add-painting.d.ts +0 -9
- package/dist/network/packets/add-painting.js +0 -41
- package/dist/network/packets/client-cache-status.d.ts +0 -8
- package/dist/network/packets/client-cache-status.js +0 -37
- package/dist/network/packets/index.d.ts +0 -9
- package/dist/network/packets/level-chunk-packet.d.ts +0 -16
- package/dist/network/packets/level-chunk-packet.js +0 -67
- package/dist/network/packets/motion-predict-hints.d.ts +0 -6
- package/dist/network/packets/motion-predict-hints.js +0 -33
- package/dist/network/packets/set-default-gamemode.d.ts +0 -4
- package/dist/network/packets/set-default-gamemode.js +0 -25
- package/dist/network/packets/set-last-hurt-by.d.ts +0 -4
- package/dist/network/packets/set-last-hurt-by.js +0 -25
- package/dist/network/packets/update-block-sync.d.ts +0 -9
- package/dist/network/packets/update-block-sync.js +0 -45
- package/dist/network/packets/update-player-game-type.d.ts +0 -6
- package/dist/network/packets/update-player-game-type.js +0 -33
- package/dist/network/packets/update-subchunk-blocks.d.ts +0 -25
- package/dist/network/packets/update-subchunk-blocks.js +0 -83
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type * as Protocol from "@serenityjs/protocol";
|
|
2
2
|
import type { PacketNames } from "../client";
|
|
3
|
-
import type { ClientCacheStatusPacket } from "../network/packets/client-cache-status";
|
|
4
3
|
import { type ServerOptions } from "../server/server-options";
|
|
5
4
|
export type BridgePlayerEvents = {
|
|
6
5
|
[K in PacketNames as `clientbound-${K}`]: [
|
|
@@ -18,14 +17,6 @@ export type BridgePlayerEvents = {
|
|
|
18
17
|
modified: boolean;
|
|
19
18
|
}
|
|
20
19
|
];
|
|
21
|
-
} & {
|
|
22
|
-
"serverbound-ClientCacheStatusPacket": [
|
|
23
|
-
packet: ClientCacheStatusPacket,
|
|
24
|
-
eventStatus: {
|
|
25
|
-
cancelled: boolean;
|
|
26
|
-
modified: boolean;
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
20
|
};
|
|
30
21
|
export type BridgeOptions = ServerOptions & {
|
|
31
22
|
destination: {
|
package/dist/bridge/bridge.js
CHANGED
|
@@ -41,7 +41,6 @@ const raknet_1 = require("@sanctumterra/raknet");
|
|
|
41
41
|
const protocol_1 = require("@serenityjs/protocol");
|
|
42
42
|
const Protocol = __importStar(require("@serenityjs/protocol"));
|
|
43
43
|
const client_1 = require("../client");
|
|
44
|
-
const level_chunk_packet_1 = require("../network/packets/level-chunk-packet");
|
|
45
44
|
const server_1 = require("../server");
|
|
46
45
|
const bridge_options_1 = require("./bridge-options");
|
|
47
46
|
const bridge_player_1 = require("./bridge-player");
|
|
@@ -60,9 +59,9 @@ class Bridge extends server_1.Server {
|
|
|
60
59
|
initializePacketCache() {
|
|
61
60
|
const CLIENT_CACHE_STATUS_ID = 129;
|
|
62
61
|
this.packetClassCache.set(CLIENT_CACHE_STATUS_ID, protocol_1.ClientCacheStatusPacket);
|
|
63
|
-
const levelChunkId =
|
|
62
|
+
const levelChunkId = Protocol.LevelChunkPacket.id;
|
|
64
63
|
if (levelChunkId !== undefined) {
|
|
65
|
-
this.packetClassCache.set(levelChunkId,
|
|
64
|
+
this.packetClassCache.set(levelChunkId, Protocol.LevelChunkPacket);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
getPacketClass(id, PacketClass) {
|
|
@@ -88,7 +87,7 @@ class Bridge extends server_1.Server {
|
|
|
88
87
|
}
|
|
89
88
|
if (packetName === "LevelChunkPacket" && !player.postStartGame) {
|
|
90
89
|
try {
|
|
91
|
-
player.levelChunkQueue.push(new
|
|
90
|
+
player.levelChunkQueue.push(new Protocol.LevelChunkPacket(buffer).deserialize());
|
|
92
91
|
}
|
|
93
92
|
catch (e) {
|
|
94
93
|
raknet_1.Logger.error("Failed to deserialize LevelChunkPacket for queueing", e);
|
|
@@ -200,8 +199,8 @@ class Bridge extends server_1.Server {
|
|
|
200
199
|
const frame = new raknet_1.Frame();
|
|
201
200
|
frame.orderChannel = 0;
|
|
202
201
|
frame.payload = rakDisconnect.serialize();
|
|
203
|
-
player.client
|
|
204
|
-
player.client
|
|
202
|
+
player.client?.raknet?.sendFrame(frame, raknet_1.Priority.Immediate);
|
|
203
|
+
player.client?.send(disconnect);
|
|
205
204
|
}
|
|
206
205
|
});
|
|
207
206
|
}
|
|
@@ -223,6 +222,7 @@ class Bridge extends server_1.Server {
|
|
|
223
222
|
onLogin(player) {
|
|
224
223
|
console.log("Creating Client");
|
|
225
224
|
const payload = player.player.data.payload;
|
|
225
|
+
console.log(this.options);
|
|
226
226
|
const client = new client_1.Client({
|
|
227
227
|
host: this.options.destination.host,
|
|
228
228
|
port: this.options.destination.port,
|
|
@@ -14,12 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./update-subchunk-blocks"), exports);
|
|
21
|
-
__exportStar(require("./level-chunk-packet"), exports);
|
|
22
|
-
__exportStar(require("./client-cache-status"), exports);
|
|
23
|
-
__exportStar(require("./set-default-gamemode"), exports);
|
|
24
|
-
__exportStar(require("./update-player-game-type"), exports);
|
|
25
|
-
__exportStar(require("./update-block-sync"), exports);
|
|
17
|
+
__exportStar(require("./bridge"), exports);
|
|
18
|
+
__exportStar(require("./bridge-player"), exports);
|
|
19
|
+
__exportStar(require("./bridge-options"), exports);
|
|
@@ -41,6 +41,7 @@ const jose = __importStar(require("jose"));
|
|
|
41
41
|
const node_crypto_1 = require("node:crypto");
|
|
42
42
|
const login_data_1 = require("./types/login-data");
|
|
43
43
|
const raknet_1 = require("@sanctumterra/raknet");
|
|
44
|
+
const client_options_1 = require("./client-options");
|
|
44
45
|
const PUBLIC_KEY = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAECRXueJeTDqNRRgJi/vlRufByu/2G0i2Ebt6YMar5QX/R0DIIyrJMcUpruK4QveTfJSTp3Shlq4Gk34cD/4GUWwkv0DVuzeuB+tXija7HBxii03NHDbPAD0AKnLr2wdAp";
|
|
45
46
|
const algorithm = "ES384";
|
|
46
47
|
const curve = "secp384r1";
|
|
@@ -56,7 +57,18 @@ class ClientData {
|
|
|
56
57
|
const loginPacket = new protocol_1.LoginPacket();
|
|
57
58
|
const chain = [this.loginData.clientIdentityChain, ...this.accessToken];
|
|
58
59
|
const userChain = this.loginData.clientUserChain;
|
|
59
|
-
|
|
60
|
+
let encodedChain = "";
|
|
61
|
+
if ((0, client_options_1.versionHigherThan)(this.client.options.version, "1.21.80")) {
|
|
62
|
+
const certificate = JSON.stringify({ chain });
|
|
63
|
+
encodedChain = JSON.stringify({
|
|
64
|
+
AuthenticationType: 2,
|
|
65
|
+
Certificate: certificate,
|
|
66
|
+
Token: "",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
encodedChain = JSON.stringify({ chain });
|
|
71
|
+
}
|
|
60
72
|
loginPacket.protocol = this.client.protocol;
|
|
61
73
|
loginPacket.tokens = new protocol_1.LoginTokens(userChain, encodedChain);
|
|
62
74
|
return loginPacket;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { CompressionMethod, InputMode } from "@serenityjs/protocol";
|
|
2
2
|
import type * as Protocol from "@serenityjs/protocol";
|
|
3
|
-
import type { ClientCacheStatusPacket } from "../network/packets/client-cache-status";
|
|
4
3
|
import type { Advertisement } from "@sanctumterra/raknet";
|
|
5
|
-
import { AddPaintingPacket, UpdateSubchunkBlocksPacket, MotionPredictHintsPacket, SetLastHurtByPacket, SetDefaultGamemodePacket, UpdatePlayerGameTypePacket, UpdateBlockSyncPacket } from "../network/packets";
|
|
6
|
-
import { LevelChunkPacket } from "../network/packets/level-chunk-packet";
|
|
7
4
|
import type { SkinData } from "./types/payload";
|
|
8
5
|
export declare enum ProtocolList {
|
|
9
6
|
"1.21.50" = 766,
|
|
10
7
|
"1.21.60" = 776,
|
|
11
8
|
"1.21.70" = 786,
|
|
12
|
-
"1.21.80" = 800
|
|
9
|
+
"1.21.80" = 800,
|
|
10
|
+
"1.21.90" = 818
|
|
13
11
|
}
|
|
14
12
|
export declare enum DeviceOS {
|
|
15
13
|
Undefined = 0,
|
|
@@ -29,6 +27,20 @@ export declare enum DeviceOS {
|
|
|
29
27
|
WindowsPhone = 14,
|
|
30
28
|
Linux = 15
|
|
31
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks if client version is higher than the specified version
|
|
32
|
+
* @param clientVersion The client version to check
|
|
33
|
+
* @param targetVersion The version to compare against
|
|
34
|
+
* @returns True if client version is higher than targetVersion
|
|
35
|
+
*/
|
|
36
|
+
export declare function versionHigherThan(clientVersion: keyof typeof ProtocolList, targetVersion: keyof typeof ProtocolList): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if client version is lower than the specified version
|
|
39
|
+
* @param clientVersion The client version to check
|
|
40
|
+
* @param targetVersion The version to compare against
|
|
41
|
+
* @returns True if client version is lower than targetVersion
|
|
42
|
+
*/
|
|
43
|
+
export declare function versionLowerThan(clientVersion: keyof typeof ProtocolList, targetVersion: keyof typeof ProtocolList): boolean;
|
|
32
44
|
type LoginPacketOptions = {
|
|
33
45
|
DeviceModel: string;
|
|
34
46
|
CurrentInputMode: InputMode;
|
|
@@ -63,27 +75,8 @@ type ClientEvents = {
|
|
|
63
75
|
[K in PacketNames]: [packet: InstanceType<(typeof Protocol)[K]>];
|
|
64
76
|
} & {
|
|
65
77
|
session: [];
|
|
66
|
-
ClientCacheStatusPacket: [
|
|
67
|
-
packet: InstanceType<typeof ClientCacheStatusPacket>
|
|
68
|
-
];
|
|
69
|
-
UpdateSubchunkBlocksPacket: [
|
|
70
|
-
packet: InstanceType<typeof UpdateSubchunkBlocksPacket>
|
|
71
|
-
];
|
|
72
|
-
MotionPredictHintsPacket: [
|
|
73
|
-
packet: InstanceType<typeof MotionPredictHintsPacket>
|
|
74
|
-
];
|
|
75
|
-
SetLastHurtByPacket: [packet: InstanceType<typeof SetLastHurtByPacket>];
|
|
76
|
-
SetDefaultGamemodePacket: [
|
|
77
|
-
packet: InstanceType<typeof SetDefaultGamemodePacket>
|
|
78
|
-
];
|
|
79
|
-
UpdatePlayerGameTypePacket: [
|
|
80
|
-
packet: InstanceType<typeof UpdatePlayerGameTypePacket>
|
|
81
|
-
];
|
|
82
|
-
UpdateBlockSyncPacket: [packet: InstanceType<typeof UpdateBlockSyncPacket>];
|
|
83
78
|
} & {
|
|
84
79
|
packet: [packet: InstanceType<(typeof Protocol)[PacketNames]>];
|
|
85
80
|
connect: [packet: Advertisement];
|
|
86
81
|
};
|
|
87
82
|
export { type ClientOptions, defaultClientOptions, type ClientEvents, type PacketNames, };
|
|
88
|
-
export type ExtraPacketType = typeof LevelChunkPacket | typeof AddPaintingPacket | typeof UpdateSubchunkBlocksPacket | typeof MotionPredictHintsPacket | typeof SetLastHurtByPacket | typeof SetDefaultGamemodePacket | typeof UpdatePlayerGameTypePacket | typeof UpdateBlockSyncPacket;
|
|
89
|
-
export declare const ExtraPackets: Record<number, ExtraPacketType>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.defaultClientOptions = exports.DeviceOS = exports.ProtocolList = void 0;
|
|
4
|
+
exports.versionHigherThan = versionHigherThan;
|
|
5
|
+
exports.versionLowerThan = versionLowerThan;
|
|
4
6
|
const protocol_1 = require("@serenityjs/protocol");
|
|
5
|
-
const packets_1 = require("../network/packets");
|
|
6
|
-
const level_chunk_packet_1 = require("../network/packets/level-chunk-packet");
|
|
7
7
|
var ProtocolList;
|
|
8
8
|
(function (ProtocolList) {
|
|
9
9
|
ProtocolList[ProtocolList["1.21.50"] = 766] = "1.21.50";
|
|
10
10
|
ProtocolList[ProtocolList["1.21.60"] = 776] = "1.21.60";
|
|
11
11
|
ProtocolList[ProtocolList["1.21.70"] = 786] = "1.21.70";
|
|
12
12
|
ProtocolList[ProtocolList["1.21.80"] = 800] = "1.21.80";
|
|
13
|
+
ProtocolList[ProtocolList["1.21.90"] = 818] = "1.21.90";
|
|
13
14
|
})(ProtocolList || (exports.ProtocolList = ProtocolList = {}));
|
|
14
15
|
var DeviceOS;
|
|
15
16
|
(function (DeviceOS) {
|
|
@@ -30,6 +31,24 @@ var DeviceOS;
|
|
|
30
31
|
DeviceOS[DeviceOS["WindowsPhone"] = 14] = "WindowsPhone";
|
|
31
32
|
DeviceOS[DeviceOS["Linux"] = 15] = "Linux";
|
|
32
33
|
})(DeviceOS || (exports.DeviceOS = DeviceOS = {}));
|
|
34
|
+
/**
|
|
35
|
+
* Checks if client version is higher than the specified version
|
|
36
|
+
* @param clientVersion The client version to check
|
|
37
|
+
* @param targetVersion The version to compare against
|
|
38
|
+
* @returns True if client version is higher than targetVersion
|
|
39
|
+
*/
|
|
40
|
+
function versionHigherThan(clientVersion, targetVersion) {
|
|
41
|
+
return ProtocolList[clientVersion] > ProtocolList[targetVersion];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if client version is lower than the specified version
|
|
45
|
+
* @param clientVersion The client version to check
|
|
46
|
+
* @param targetVersion The version to compare against
|
|
47
|
+
* @returns True if client version is lower than targetVersion
|
|
48
|
+
*/
|
|
49
|
+
function versionLowerThan(clientVersion, targetVersion) {
|
|
50
|
+
return ProtocolList[clientVersion] < ProtocolList[targetVersion];
|
|
51
|
+
}
|
|
33
52
|
const defaultClientOptions = {
|
|
34
53
|
host: "127.0.0.1",
|
|
35
54
|
port: 19132,
|
|
@@ -37,7 +56,7 @@ const defaultClientOptions = {
|
|
|
37
56
|
compressionMethod: protocol_1.CompressionMethod.Zlib,
|
|
38
57
|
compressionLevel: 7,
|
|
39
58
|
deviceOS: DeviceOS.NintendoSwitch,
|
|
40
|
-
version: "1.21.
|
|
59
|
+
version: "1.21.90",
|
|
41
60
|
username: "SanctumTerra",
|
|
42
61
|
tokensFolder: "tokens",
|
|
43
62
|
viewDistance: 10,
|
|
@@ -45,7 +64,7 @@ const defaultClientOptions = {
|
|
|
45
64
|
offline: false,
|
|
46
65
|
worker: false,
|
|
47
66
|
loginOptions: {
|
|
48
|
-
DeviceModel: "
|
|
67
|
+
DeviceModel: "Bean Bag Chair",
|
|
49
68
|
CurrentInputMode: protocol_1.InputMode.GamePad,
|
|
50
69
|
DefaultInputMode: protocol_1.InputMode.GamePad,
|
|
51
70
|
},
|
|
@@ -56,13 +75,3 @@ const defaultClientOptions = {
|
|
|
56
75
|
graphicsMode: 0,
|
|
57
76
|
};
|
|
58
77
|
exports.defaultClientOptions = defaultClientOptions;
|
|
59
|
-
exports.ExtraPackets = {
|
|
60
|
-
[58]: level_chunk_packet_1.LevelChunkPacket,
|
|
61
|
-
[22]: packets_1.AddPaintingPacket,
|
|
62
|
-
[172]: packets_1.UpdateSubchunkBlocksPacket,
|
|
63
|
-
[157]: packets_1.MotionPredictHintsPacket,
|
|
64
|
-
[96]: packets_1.SetLastHurtByPacket,
|
|
65
|
-
[105]: packets_1.SetDefaultGamemodePacket,
|
|
66
|
-
[151]: packets_1.UpdatePlayerGameTypePacket,
|
|
67
|
-
[110]: packets_1.UpdateBlockSyncPacket,
|
|
68
|
-
};
|
package/dist/client/client.js
CHANGED
|
@@ -7,7 +7,6 @@ const raknet_1 = require("@sanctumterra/raknet");
|
|
|
7
7
|
const protocol_1 = require("@serenityjs/protocol");
|
|
8
8
|
const emitter_1 = require("../libs/emitter");
|
|
9
9
|
const network_1 = require("../network");
|
|
10
|
-
const client_cache_status_1 = require("../network/packets/client-cache-status");
|
|
11
10
|
const packet_encryptor_1 = require("../network/packet-encryptor");
|
|
12
11
|
const client_data_1 = require("./client-data");
|
|
13
12
|
const client_options_1 = require("./client-options");
|
|
@@ -123,11 +122,8 @@ class Client extends emitter_1.Emitter {
|
|
|
123
122
|
/** Already decompressed packets */
|
|
124
123
|
processPacket(buffer) {
|
|
125
124
|
const id = (0, protocol_1.getPacketId)(buffer);
|
|
126
|
-
|
|
125
|
+
const PacketClass = protocol_1.Packets[id];
|
|
127
126
|
try {
|
|
128
|
-
if (id in client_options_1.ExtraPackets) {
|
|
129
|
-
PacketClass = client_options_1.ExtraPackets[id];
|
|
130
|
-
}
|
|
131
127
|
if (!PacketClass || !PacketClass.name) {
|
|
132
128
|
raknet_1.Logger.warn(`Unknown Game packet ${id}`);
|
|
133
129
|
return;
|
|
@@ -227,7 +223,9 @@ class Client extends emitter_1.Emitter {
|
|
|
227
223
|
response.response = protocol_1.ResourcePackResponse.Completed;
|
|
228
224
|
this.send(response);
|
|
229
225
|
if (packet instanceof protocol_1.ResourcePacksInfoPacket) {
|
|
230
|
-
|
|
226
|
+
const packet = new protocol_1.ClientCacheStatusPacket();
|
|
227
|
+
packet.enabled = false;
|
|
228
|
+
this.send(packet);
|
|
231
229
|
}
|
|
232
230
|
}
|
|
233
231
|
startEncryption(iv) {
|
|
@@ -82,7 +82,6 @@ const createDefaultPayload = (client) => {
|
|
|
82
82
|
SkinImageWidth: skin.skinData.SkinImageWidth,
|
|
83
83
|
SkinResourcePatch: skin.skinData.SkinResourcePatch,
|
|
84
84
|
ThirdPartyName: username,
|
|
85
|
-
ThirdPartyNameOnly: false,
|
|
86
85
|
TrustedSkin: skin.skinData.TrustedSkin,
|
|
87
86
|
UIProfile: client.options.uiProfile,
|
|
88
87
|
GraphicsMode: client.options.graphicsMode,
|