baltica 0.1.3 → 0.1.5
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
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))
|
|
@@ -187,7 +192,6 @@ class Client extends libs_1.Emitter {
|
|
|
187
192
|
return;
|
|
188
193
|
const serialized = packet instanceof protocol_1.DataPacket ? packet.serialize() : packet;
|
|
189
194
|
const compressed = this.packetCompressor.compress(serialized, this.options.compressionMethod);
|
|
190
|
-
console.log(compressed);
|
|
191
195
|
const frame = new raknet_1.Frame();
|
|
192
196
|
frame.orderChannel = 0;
|
|
193
197
|
frame.payload = compressed;
|
|
@@ -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;
|