baltica 0.1.2 → 0.1.3

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.
@@ -1,7 +1,8 @@
1
1
  import { type StartGamePacket, DataPacket } from "@serenityjs/protocol";
2
- import { type Profile, Emitter, PacketCompressor, PacketEncryptor } from "../";
3
- import { ClientData, type ClientEvents, type ClientOptions, WorkerClient } from "./";
4
2
  import { type Advertisement, Client as RaknetClient, Status } from "@sanctumterra/raknet";
3
+ import { Emitter, PacketCompressor, PacketEncryptor, type Profile } from "../libs";
4
+ import { ClientData, type ClientEvents, type ClientOptions } from "./types";
5
+ import { WorkerClient } from "./worker";
5
6
  export declare class Client extends Emitter<ClientEvents> {
6
7
  /** Client Options that change decisions duh. */
7
8
  options: ClientOptions;
@@ -2,14 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
4
  const protocol_1 = require("@serenityjs/protocol");
5
- const __1 = require("../");
6
- const _1 = require("./");
7
5
  const raknet_1 = require("@sanctumterra/raknet");
8
6
  const node_crypto_1 = require("node:crypto");
9
- class Client extends __1.Emitter {
7
+ const libs_1 = require("../libs");
8
+ const types_1 = require("./types");
9
+ const worker_1 = require("./worker");
10
+ const types_2 = require("../types");
11
+ class Client extends libs_1.Emitter {
10
12
  constructor(options) {
11
13
  super();
12
- this.options = { ..._1.defaultClientOptions, ...options };
14
+ this.options = { ...types_1.defaultClientOptions, ...options };
13
15
  /** this is unecessary since auth will set it anyway but i am adding just incase. */
14
16
  this.username = this.options.username;
15
17
  /** Bool values */
@@ -21,7 +23,7 @@ class Client extends __1.Emitter {
21
23
  this.status = raknet_1.Status.Disconnected;
22
24
  /** worker or not. */
23
25
  this.raknet = this.options.worker
24
- ? new _1.WorkerClient({
26
+ ? new worker_1.WorkerClient({
25
27
  address: this.options.address,
26
28
  port: this.options.port,
27
29
  })
@@ -30,24 +32,24 @@ class Client extends __1.Emitter {
30
32
  port: this.options.port,
31
33
  });
32
34
  /** Create ClientData to store and handle auth data */
33
- this.data = new _1.ClientData(this);
35
+ this.data = new types_1.ClientData(this);
34
36
  const time = Date.now();
35
37
  /** Session event gets mojang (minecraft) auth session */
36
38
  /** NOTE! This takes like 30-100ms for offline mode which kinda feels slow but not really */
37
39
  this.once("session", () => {
38
40
  this.sessionReady = true;
39
41
  });
40
- this.options.offline ? (0, __1.createOfflineSession)(this) : (0, __1.authenticate)(this);
42
+ this.options.offline ? (0, libs_1.createOfflineSession)(this) : (0, libs_1.authenticate)(this);
41
43
  }
42
44
  /** Connect to the server and start sending/receiving packets. */
43
45
  async connect() {
44
46
  const advertisement = await this.raknet.connect();
45
47
  this.status = raknet_1.Status.Connecting;
46
- this.packetCompressor = new __1.PacketCompressor(this);
48
+ this.packetCompressor = new libs_1.PacketCompressor(this);
47
49
  this.handleGamePackets();
48
50
  this.raknet.on("encapsulated", this.handleEncapsulated.bind(this));
49
51
  const request = new protocol_1.RequestNetworkSettingsPacket();
50
- request.protocol = __1.ProtocolList[__1.CurrentVersionConst];
52
+ request.protocol = types_2.ProtocolList[types_2.CurrentVersionConst];
51
53
  this.send(request);
52
54
  return new Promise((resolve, rejevt) => {
53
55
  this.once("SetLocalPlayerAsInitializedPacket", (packet) => {
@@ -114,7 +116,7 @@ class Client extends __1.Emitter {
114
116
  type: "spki",
115
117
  format: "der",
116
118
  });
117
- this.data.sharedSecret = _1.ClientData.createSharedSecret(this.data.loginData.ecdhKeyPair.privateKey, pubKeyDer);
119
+ this.data.sharedSecret = types_1.ClientData.createSharedSecret(this.data.loginData.ecdhKeyPair.privateKey, pubKeyDer);
118
120
  const secretHash = (0, node_crypto_1.createHash)("sha256")
119
121
  .update(new Uint8Array(Buffer.from(salt, "base64")))
120
122
  .update(new Uint8Array(this.data.sharedSecret))
@@ -171,7 +173,7 @@ class Client extends __1.Emitter {
171
173
  });
172
174
  }
173
175
  startEncryption(iv) {
174
- this.packetEncryptor = new __1.PacketEncryptor(this, iv);
176
+ this.packetEncryptor = new libs_1.PacketEncryptor(this, iv);
175
177
  this._encryptionEnabled = true;
176
178
  }
177
179
  async waitForSessionReady() {
@@ -185,6 +187,7 @@ class Client extends __1.Emitter {
185
187
  return;
186
188
  const serialized = packet instanceof protocol_1.DataPacket ? packet.serialize() : packet;
187
189
  const compressed = this.packetCompressor.compress(serialized, this.options.compressionMethod);
190
+ console.log(compressed);
188
191
  const frame = new raknet_1.Frame();
189
192
  frame.orderChannel = 0;
190
193
  frame.payload = compressed;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "baltica",
3
3
  "description": "A MCBE Utility Library",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "minecraft": "1.21.93",
6
6
  "type": "commonjs",
7
7
  "main": "dist/index.js",
@@ -26,16 +26,22 @@
26
26
  "@serenityjs/binarystream": "2.7.3",
27
27
  "@serenityjs/core": "0.8.6-beta-20250704151230",
28
28
  "@serenityjs/protocol": "0.8.6-beta-20250704151230",
29
+ "@twilio/webrtc": "^4.6.0",
30
+ "@types/webrtc": "^0.0.46",
29
31
  "axios": "^1.10.0",
30
32
  "elliptic": "^6.6.1",
31
33
  "jose": "^5.10.0",
34
+ "json-bigint": "^1.0.0",
35
+ "node-nethernet": "github:LucienHH/node-nethernet#protocol",
32
36
  "prismarine-auth": "^2.7.0",
33
- "uuid-1345": "^1.0.2"
37
+ "uuid-1345": "^1.0.2",
38
+ "ws": "^8.18.3"
34
39
  },
35
40
  "devDependencies": {
36
41
  "@biomejs/biome": "1.9.4",
37
42
  "@types/elliptic": "^6.4.18",
38
- "@types/node": "^22.16.0",
43
+ "@types/json-bigint": "^1.0.4",
44
+ "@types/node": "^22.16.5",
39
45
  "@types/uuid-1345": "^0.99.25",
40
46
  "typescript": "^5.8.3"
41
47
  }