Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Dec 27, 2024
1 parent 692b378 commit 7f2dd29
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 283 deletions.
9 changes: 3 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,8 @@ <h1>Wispcraft Injector</h1>
<script type="text/javascript">
${atob(getWispcraftBundle())}
<${"/"}script>
`
content =
content.slice(0, index) +
inject +
content.slice(index);
`;
content = content.slice(0, index) + inject + content.slice(index);
const blob = new Blob([content], {
type: "text/html; charset=utf-8",
});
Expand All @@ -224,7 +221,7 @@ <h1>Wispcraft Injector</h1>
<script id="wispcraft-bundled">
// wispcraft will be bundled and stored here
function getWispcraftBundle() {
WISPCRAFTSRCBUNDLE
WISPCRAFTSRCBUNDLE;
}
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const commonPlugins = () => [
let hash = JSON.stringify(
execSync("git rev-parse --short HEAD", {
encoding: "utf-8",
}).replace(/\r?\n|\r/g, ""),
}).replace(/\r?\n|\r/g, "")
);

return hash;
Expand Down
14 changes: 7 additions & 7 deletions src/1.8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class EaglerProxy {
epoxyOut: BytesWriter,
public serverAddress: string,
public serverPort: number,
public authStore: AuthStore,
public authStore: AuthStore
) {
this.net = epoxyOut;
this.eagler = eaglerOut;
Expand Down Expand Up @@ -185,7 +185,7 @@ export class EaglerProxy {
if (this.authStore.user) {
fakelogin.writeString(this.authStore.user.name);
fakelogin.writeBytes(
this.authStore.user.id.split("").map((x) => parseInt(x)),
this.authStore.user.id.split("").map((x) => parseInt(x))
);
} else {
fakelogin.writeString(this.offlineUsername);
Expand Down Expand Up @@ -295,7 +295,7 @@ export class EaglerProxy {

if (body.favicon) {
let image = await createImageBitmap(
await (await fetch(body.favicon)).blob(),
await (await fetch(body.favicon)).blob()
);
let canvas = new OffscreenCanvas(image.width, image.height);
let ctx = canvas.getContext("2d")!;
Expand All @@ -304,7 +304,7 @@ export class EaglerProxy {
0,
0,
canvas.width,
canvas.height,
canvas.height
).data;
this.eagler.write(new Buffer(new Uint8Array(pixels)));
}
Expand Down Expand Up @@ -362,21 +362,21 @@ export class EaglerProxy {
...new TextEncoder().encode(serverid),
...sharedSecret,
...publicKey.inner,
]),
])
);

const [modulus, exponent] = await loadKey(publicKey.inner);
let encrypedSecret = encryptRSA(sharedSecret, modulus, exponent);
let encryptedChallenge = encryptRSA(
verifyToken.inner,
modulus,
exponent,
exponent
);
console.log("joining with: ", this.authStore);
await joinServer(
this.authStore.yggToken,
digest,
this.authStore.user.id,
this.authStore.user.id
);

let response = new Packet(Serverbound.EncryptionResponse);
Expand Down
17 changes: 14 additions & 3 deletions src/connection/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,13 @@ export class Decryptor {
}
const start = performance.now();
controller.enqueue(new Buffer(this.aesCfb.decrypt(chunk.inner)));
console.log("Took " + (performance.now() - start) + " to transform chunk of size " + chunk.length + " (Decryption)");
console.log(
"Took " +
(performance.now() - start) +
" to transform chunk of size " +
chunk.length +
" (Decryption)"
);
},
});
}
Expand Down Expand Up @@ -456,9 +462,14 @@ export class Encryptor {
if (!this.aesCfb) return chunk;
const start = performance.now();
const retobj = new Buffer(this.aesCfb.encrypt(chunk.inner));
console.log("Took " + (performance.now() - start) + " to transform chunk of size " + chunk.length + " (Encryption)");
console.log(
"Took " +
(performance.now() - start) +
" to transform chunk of size " +
chunk.length +
" (Encryption)"
);
return retobj;

}
}

Expand Down
13 changes: 8 additions & 5 deletions src/connection/fakewebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class WispWS extends EventTarget {
}

close() {
if (this.readyState == WebSocket.CLOSING || this.readyState == WebSocket.CLOSED) {
if (
this.readyState == WebSocket.CLOSING ||
this.readyState == WebSocket.CLOSED
) {
return;
}
this.readyState = WebSocket.CLOSING;
Expand Down Expand Up @@ -101,7 +104,7 @@ class SettingsWS extends EventTarget {
motd: ["Sign in with Microsoft", "Configure Proxy URL"],
},
}),
}),
})
);
fetch(wispcraft)
.then((response) => response.blob())
Expand All @@ -112,7 +115,7 @@ class SettingsWS extends EventTarget {
ctx.drawImage(image, 0, 0);
let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
this.dispatchEvent(
new MessageEvent("message", { data: new Uint8Array(pixels) }),
new MessageEvent("message", { data: new Uint8Array(pixels) })
);
});
} else {
Expand All @@ -124,7 +127,7 @@ class SettingsWS extends EventTarget {
this.dispatchEvent(new CloseEvent("close"));
}
}
close() { }
close() {}
}

class AutoWS extends EventTarget {
Expand Down Expand Up @@ -215,7 +218,7 @@ class AutoWS extends EventTarget {
if (this.inner != null) {
try {
return this.inner.close();
} catch (e) { }
} catch (e) {}
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/connection/framer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export function bufferTransformer(): TransformStream<Uint8Array, Buffer> {
return new TransformStream({
transform(chunk, controller) {
controller.enqueue(new Buffer(chunk));
console.log("Got a packet of size " + chunk.length +" (bufferTransformer)");
console.log(
"Got a packet of size " + chunk.length + " (bufferTransformer)"
);
},
});
}
Expand All @@ -80,7 +82,6 @@ export function lengthTransformer(): TransformStream<Buffer> {
const start = performance.now();
currentPacket.extend(chunk);
while (true) {

if (currentSize === -1) {
let size: number;
try {
Expand All @@ -99,9 +100,10 @@ export function lengthTransformer(): TransformStream<Buffer> {
const pkt = currentPacket.take(currentSize);
controller.enqueue(pkt);
currentSize = -1;

}
console.log("Took " + (performance.now() - start) + " to lengthTransform packet");
console.log(
"Took " + (performance.now() - start) + " to lengthTransform packet"
);
},
});
}
Expand Down Expand Up @@ -131,7 +133,9 @@ export class Decompressor {
"Decompressor: server sent compressed packet below threshold"
);
}
console.log("Took " + (performance.now() - start) + " to decompress packet");
console.log(
"Took " + (performance.now() - start) + " to decompress packet"
);
},
});
}
Expand Down
19 changes: 11 additions & 8 deletions src/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Connection {

constructor(
uri: string,
private authStore: AuthStore,
private authStore: AuthStore
) {
const [processIn, eaglerIn] = link<Buffer>();
this.processIn = processIn.getReader();
Expand All @@ -80,7 +80,7 @@ export class Connection {
headers: {
Accept: "application/dns-json",
},
},
}
);
const dnsResponse = await dns.json();
if (dnsResponse.Answer?.length) {
Expand All @@ -91,7 +91,7 @@ export class Connection {
}
} catch {}
const conn = await connect_tcp(
connectUrl ? connectUrl.host : this.url.host,
connectUrl ? connectUrl.host : this.url.host
);
connectcallback();
const writer = bufferWriter(conn.write.getWriter());
Expand All @@ -108,7 +108,7 @@ export class Connection {
}).getWriter(),
this.url.hostname,
this.url.port ? parseInt(this.url.port) : 25565,
this.authStore,
this.authStore
);

// epoxy -> process -> (hopefully) eagler task
Expand All @@ -119,9 +119,10 @@ export class Connection {
.pipeThrough(bufferTransformer())
.pipeThrough(impl.decryptor.transform)
.pipeThrough(lengthTransformer())
.pipeThrough(impl.decompressor.transform).getReader(),
.pipeThrough(impl.decompressor.transform)
.getReader(),
100,
() => backlog++,
() => backlog++
).getReader();

// setInterval(() => console.log("epoxy backlog ", backlog), 1000);
Expand All @@ -143,7 +144,7 @@ export class Connection {
const reader = eagerlyPoll<Buffer>(
this.processIn,
100,
() => backlog++,
() => backlog++
).getReader();

// setInterval(() => console.log("eagler backlog ", backlog), 1000);
Expand All @@ -152,7 +153,9 @@ export class Connection {
const { done, value } = await reader.read();
if (done || !value) return;
await impl.eaglerRead(value);
console.log("Took " + (performance.now() - start) + " to eaglerRead packet");
console.log(
"Took " + (performance.now() - start) + " to eaglerRead packet"
);
backlog--;
}

Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ wispUrl =

if (localStorage["wispcraft_accounts"]) {
const accounts = JSON.parse(
localStorage["wispcraft_accounts"],
localStorage["wispcraft_accounts"]
) as TokenStore[];
const account = accounts.find(
(account) =>
account.username === localStorage["wispcraft_last_used_account"],
account.username === localStorage["wispcraft_last_used_account"]
);
if (account) {
(async () => {
Expand Down Expand Up @@ -85,4 +85,4 @@ Object.defineProperty(window, "eaglercraftXOpts", {
},
});

initWisp(wispUrl);
initWisp(wispUrl);
7 changes: 1 addition & 6 deletions src/skins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ async function funnyFetch(url: string): Promise<Tex> {

function makeImageData(width: number, height: number): ImageData {
const canvas = new OffscreenCanvas(width, height);
return canvas.getContext("2d")!.getImageData(
0,
0,
width,
height
);
return canvas.getContext("2d")!.getImageData(0, 0, width, height);
}

async function blobToImageData(blob: Blob): Promise<ImageData> {
Expand Down
Loading

0 comments on commit 7f2dd29

Please sign in to comment.