baltica 0.1.4 → 0.1.6
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/client/client.d.ts +1 -1
- package/dist/client/client.js +15 -10
- package/dist/client/types/client-events.d.ts +3 -1
- package/dist/client/types/client-options.d.ts +3 -1
- package/dist/client/types/client-options.js +2 -0
- package/dist/types/global.d.ts +3 -2
- package/dist/types/global.js +2 -1
- package/package.json +5 -15
package/dist/client/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type StartGamePacket, DataPacket } from "@serenityjs/protocol";
|
|
2
1
|
import { type Advertisement, Client as RaknetClient, Status } from "@sanctumterra/raknet";
|
|
2
|
+
import { DataPacket, type StartGamePacket } from "@serenityjs/protocol";
|
|
3
3
|
import { Emitter, PacketCompressor, PacketEncryptor, type Profile } from "../libs";
|
|
4
4
|
import { ClientData, type ClientEvents, type ClientOptions } from "./types";
|
|
5
5
|
import { WorkerClient } from "./worker";
|
package/dist/client/client.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Client = void 0;
|
|
4
|
-
const protocol_1 = require("@serenityjs/protocol");
|
|
5
4
|
const raknet_1 = require("@sanctumterra/raknet");
|
|
5
|
+
const protocol_1 = require("@serenityjs/protocol");
|
|
6
6
|
const node_crypto_1 = require("node:crypto");
|
|
7
7
|
const libs_1 = require("../libs");
|
|
8
|
-
const types_1 = require("
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const types_2 = require("./types");
|
|
9
10
|
const worker_1 = require("./worker");
|
|
10
|
-
const types_2 = require("../types");
|
|
11
11
|
class Client extends libs_1.Emitter {
|
|
12
12
|
constructor(options) {
|
|
13
13
|
super();
|
|
14
|
-
this.options = { ...
|
|
14
|
+
this.options = { ...types_2.defaultClientOptions, ...options };
|
|
15
15
|
/** this is unecessary since auth will set it anyway but i am adding just incase. */
|
|
16
16
|
this.username = this.options.username;
|
|
17
17
|
/** Bool values */
|
|
@@ -32,7 +32,7 @@ class Client extends libs_1.Emitter {
|
|
|
32
32
|
port: this.options.port,
|
|
33
33
|
});
|
|
34
34
|
/** Create ClientData to store and handle auth data */
|
|
35
|
-
this.data = new
|
|
35
|
+
this.data = new types_2.ClientData(this);
|
|
36
36
|
const time = Date.now();
|
|
37
37
|
/** Session event gets mojang (minecraft) auth session */
|
|
38
38
|
/** NOTE! This takes like 30-100ms for offline mode which kinda feels slow but not really */
|
|
@@ -49,7 +49,7 @@ class Client extends libs_1.Emitter {
|
|
|
49
49
|
this.handleGamePackets();
|
|
50
50
|
this.raknet.on("encapsulated", this.handleEncapsulated.bind(this));
|
|
51
51
|
const request = new protocol_1.RequestNetworkSettingsPacket();
|
|
52
|
-
request.protocol =
|
|
52
|
+
request.protocol = types_1.ProtocolList[types_1.CurrentVersionConst];
|
|
53
53
|
this.send(request);
|
|
54
54
|
return new Promise((resolve, rejevt) => {
|
|
55
55
|
this.once("SetLocalPlayerAsInitializedPacket", (packet) => {
|
|
@@ -76,7 +76,12 @@ class Client extends libs_1.Emitter {
|
|
|
76
76
|
const PacketClass = protocol_1.Packets[id];
|
|
77
77
|
try {
|
|
78
78
|
if (!PacketClass || !PacketClass.name) {
|
|
79
|
-
|
|
79
|
+
if (this.options.emitUnknownPackets) {
|
|
80
|
+
this.emit(`${id}`, buffer);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
raknet_1.Logger.warn(`Unknown Game packet ${id}`);
|
|
84
|
+
}
|
|
80
85
|
return;
|
|
81
86
|
}
|
|
82
87
|
const hasSpecificListener = this.hasListeners(PacketClass.name);
|
|
@@ -116,7 +121,7 @@ class Client extends libs_1.Emitter {
|
|
|
116
121
|
type: "spki",
|
|
117
122
|
format: "der",
|
|
118
123
|
});
|
|
119
|
-
this.data.sharedSecret =
|
|
124
|
+
this.data.sharedSecret = types_2.ClientData.createSharedSecret(this.data.loginData.ecdhKeyPair.privateKey, pubKeyDer);
|
|
120
125
|
const secretHash = (0, node_crypto_1.createHash)("sha256")
|
|
121
126
|
.update(new Uint8Array(Buffer.from(salt, "base64")))
|
|
122
127
|
.update(new Uint8Array(this.data.sharedSecret))
|
|
@@ -131,7 +136,7 @@ class Client extends libs_1.Emitter {
|
|
|
131
136
|
if (this.cancelPastLogin)
|
|
132
137
|
return;
|
|
133
138
|
const response = new protocol_1.ResourcePackClientResponsePacket();
|
|
134
|
-
response.packs = packet.packs.map((p) => p.uuid);
|
|
139
|
+
response.packs = packet.packs.map((p) => new protocol_1.RequestedResourcePack(p.uuid, p.version));
|
|
135
140
|
response.response = protocol_1.ResourcePackResponse.HaveAllPacks;
|
|
136
141
|
this.send(response);
|
|
137
142
|
if (packet instanceof protocol_1.ResourcePacksInfoPacket) {
|
|
@@ -142,7 +147,7 @@ class Client extends libs_1.Emitter {
|
|
|
142
147
|
});
|
|
143
148
|
this.once("ResourcePackStackPacket", (packet) => {
|
|
144
149
|
const response = new protocol_1.ResourcePackClientResponsePacket();
|
|
145
|
-
response.packs = packet.texturePacks.map((p) => p.
|
|
150
|
+
response.packs = packet.texturePacks.map((p) => new protocol_1.RequestedResourcePack(p.uuid, p.version));
|
|
146
151
|
response.response = protocol_1.ResourcePackResponse.Completed;
|
|
147
152
|
this.send(response);
|
|
148
153
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type * as Protocol from "@serenityjs/protocol";
|
|
2
1
|
import type { Advertisement } from "@sanctumterra/raknet";
|
|
2
|
+
import type * as Protocol from "@serenityjs/protocol";
|
|
3
3
|
import type { PacketNames } from "../../types";
|
|
4
4
|
type ClientEvents = {
|
|
5
5
|
[K in PacketNames]: [packet: InstanceType<(typeof Protocol)[K]>];
|
|
@@ -8,5 +8,7 @@ type ClientEvents = {
|
|
|
8
8
|
} & {
|
|
9
9
|
packet: [packet: InstanceType<(typeof Protocol)[PacketNames]>];
|
|
10
10
|
connect: [packet: Advertisement];
|
|
11
|
+
} & {
|
|
12
|
+
[K in `${number}`]: [buffer: Buffer];
|
|
11
13
|
};
|
|
12
14
|
export type { ClientEvents, PacketNames };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CompressionMethod, InputMode } from "@serenityjs/protocol";
|
|
2
|
-
import type { SkinData } from "./payload";
|
|
3
2
|
import { DeviceOS } from "../../types";
|
|
3
|
+
import type { SkinData } from "./payload";
|
|
4
4
|
type LoginPacketOptions = {
|
|
5
5
|
/** Device Model (Can be any string) */
|
|
6
6
|
deviceModel: string;
|
|
@@ -42,6 +42,8 @@ export type ClientOptions = {
|
|
|
42
42
|
compressionThreshold: number;
|
|
43
43
|
/** Compression Method for the compressor to use. */
|
|
44
44
|
compressionMethod: CompressionMethod;
|
|
45
|
+
/** Whether to emit unknown packets as buffer */
|
|
46
|
+
emitUnknownPackets: boolean;
|
|
45
47
|
};
|
|
46
48
|
/** Default Client Options */
|
|
47
49
|
export declare const defaultClientOptions: ClientOptions;
|
package/dist/types/global.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare enum ProtocolList {
|
|
|
5
5
|
"1.21.70" = 786,
|
|
6
6
|
"1.21.80" = 800,
|
|
7
7
|
"1.21.90" = 818,
|
|
8
|
-
"1.21.93" = 819
|
|
8
|
+
"1.21.93" = 819,
|
|
9
|
+
"1.21.100" = 827
|
|
9
10
|
}
|
|
10
11
|
export declare enum DeviceOS {
|
|
11
12
|
Undefined = 0,
|
|
@@ -31,7 +32,7 @@ export type PacketNames = {
|
|
|
31
32
|
/**
|
|
32
33
|
* We do not have multi protocol as of now (Not yet planned either).
|
|
33
34
|
*/
|
|
34
|
-
export type CurrentVersion = "1.21.
|
|
35
|
+
export type CurrentVersion = "1.21.100";
|
|
35
36
|
export declare const CurrentVersionConst: CurrentVersion;
|
|
36
37
|
/**
|
|
37
38
|
* Checks if client version is higher than the specified version
|
package/dist/types/global.js
CHANGED
|
@@ -11,6 +11,7 @@ var ProtocolList;
|
|
|
11
11
|
ProtocolList[ProtocolList["1.21.80"] = 800] = "1.21.80";
|
|
12
12
|
ProtocolList[ProtocolList["1.21.90"] = 818] = "1.21.90";
|
|
13
13
|
ProtocolList[ProtocolList["1.21.93"] = 819] = "1.21.93";
|
|
14
|
+
ProtocolList[ProtocolList["1.21.100"] = 827] = "1.21.100";
|
|
14
15
|
})(ProtocolList || (exports.ProtocolList = ProtocolList = {}));
|
|
15
16
|
var DeviceOS;
|
|
16
17
|
(function (DeviceOS) {
|
|
@@ -31,7 +32,7 @@ var DeviceOS;
|
|
|
31
32
|
DeviceOS[DeviceOS["WindowsPhone"] = 14] = "WindowsPhone";
|
|
32
33
|
DeviceOS[DeviceOS["Linux"] = 15] = "Linux";
|
|
33
34
|
})(DeviceOS || (exports.DeviceOS = DeviceOS = {}));
|
|
34
|
-
exports.CurrentVersionConst = "1.21.
|
|
35
|
+
exports.CurrentVersionConst = "1.21.100";
|
|
35
36
|
/**
|
|
36
37
|
* Checks if client version is higher than the specified version
|
|
37
38
|
* @param version The client version to check
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baltica",
|
|
3
3
|
"description": "A MCBE Utility Library",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"minecraft": "1.21.
|
|
4
|
+
"version": "0.1.6",
|
|
5
|
+
"minecraft": "1.21.100",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"license": "MIT",
|
|
@@ -23,24 +23,14 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@sanctumterra/raknet": "^1.3.78",
|
|
26
|
-
"@serenityjs/binarystream": "
|
|
27
|
-
"@serenityjs/
|
|
28
|
-
"@serenityjs/protocol": "0.8.6-beta-20250704151230",
|
|
29
|
-
"@twilio/webrtc": "^4.6.0",
|
|
30
|
-
"@types/webrtc": "^0.0.46",
|
|
31
|
-
"axios": "^1.10.0",
|
|
32
|
-
"elliptic": "^6.6.1",
|
|
26
|
+
"@serenityjs/binarystream": "^3.0.10",
|
|
27
|
+
"@serenityjs/protocol": "^0.8.7",
|
|
33
28
|
"jose": "^5.10.0",
|
|
34
|
-
"json-bigint": "^1.0.0",
|
|
35
|
-
"node-nethernet": "github:LucienHH/node-nethernet#protocol",
|
|
36
29
|
"prismarine-auth": "^2.7.0",
|
|
37
|
-
"uuid-1345": "^1.0.2"
|
|
38
|
-
"ws": "^8.18.3"
|
|
30
|
+
"uuid-1345": "^1.0.2"
|
|
39
31
|
},
|
|
40
32
|
"devDependencies": {
|
|
41
33
|
"@biomejs/biome": "1.9.4",
|
|
42
|
-
"@types/elliptic": "^6.4.18",
|
|
43
|
-
"@types/json-bigint": "^1.0.4",
|
|
44
34
|
"@types/node": "^22.16.5",
|
|
45
35
|
"@types/uuid-1345": "^0.99.25",
|
|
46
36
|
"typescript": "^5.8.3"
|