bonktools 2.3.0 → 3.0.0

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.
@@ -0,0 +1,64 @@
1
+ const BonkBot = require("./bonkbot.js");
2
+
3
+ let bot = BonkBot.createBot({
4
+ account: {
5
+ username: "me",
6
+ password: "K3FmWyDhqCz4kycj",
7
+ guest: false,
8
+ },
9
+ // skin: "{skin_object_here}"
10
+ });
11
+
12
+ bot.events.on("ready", async () => {
13
+ console.log("Bot is ready");
14
+ console.log(bot);
15
+
16
+ // let fromurl = await bot.getAddressFromLink("https://bonk.io/710561")
17
+ // let fromroomname = await bot.getAddressFromRoomName("test")
18
+ let addr = await bot.createRoom(bot);
19
+
20
+ bot.setAddress(addr);
21
+ bot.connect();
22
+ });
23
+
24
+ bot.events.on("connect", () => {
25
+ console.log("Bot connected to room!");
26
+
27
+ bot.events.on("packet", async (packet) => {
28
+ bot.autoHandlePacket(packet);
29
+ // ignore spammy packets
30
+ if (packet.type == "timesync") return;
31
+ if (packet.type == "ping") return;
32
+ console.log(packet);
33
+ });
34
+
35
+ bot.events.on("banned", async () => {
36
+ console.log("Bot was banned from the room!");
37
+ });
38
+
39
+ bot.events.on("disconnected", async () => {
40
+ console.log("Bot disconnected from the room!");
41
+ });
42
+
43
+ bot.events.on("chatmessage", async (playerchatevent) => {
44
+ let pce = playerchatevent;
45
+ console.log(`${pce.username}: ${pce.message}`);
46
+
47
+ // commands!
48
+ if (pce.message == "!ping") {
49
+ bot.chat("Pong!");
50
+ }
51
+ });
52
+
53
+ bot.events.on("join", async (playerjoinevent) => {
54
+ let joiningPlayer = bot.getPlayerByID(playerjoinevent.id);
55
+ console.log(`${joiningPlayer.username} joined the room!`);
56
+ });
57
+
58
+ bot.events.on("leave", async (playerleaveevent) => {
59
+ let leavingPlayer = bot.getPlayerByID(playerleaveevent.id);
60
+ console.log(`${leavingPlayer.username} left the room!`);
61
+ });
62
+ });
63
+
64
+ bot.init();
package/package.json CHANGED
@@ -1,20 +1,18 @@
1
1
  {
2
2
  "name": "bonktools",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "Advanced Bonk.io bot library with physics simulation and game state management",
5
5
  "main": "src/index.js",
6
- "files": [
7
- "index.js",
8
- "lib",
9
- "README.md",
10
- "LICENSE"
11
- ],
12
6
  "scripts": {
13
7
  "test": "echo \"Error: no test specified\" && exit 1",
14
8
  "download-cert": "node scripts/download-cert.js",
15
9
  "preinstall": "node scripts/download-cert.js || true",
16
10
  "simple-bot": "node examples/simple-bot.js",
17
- "host-bot": "node examples/host-bot.js"
11
+ "host-bot": "node examples/host-bot.js",
12
+ "publish_1": "npm version patch",
13
+ "publish_2": "npm version minor",
14
+ "publish_3": "npm version major",
15
+ "publish_4": "npm publish"
18
16
  },
19
17
  "keywords": [
20
18
  "bonk.io",
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Download Sectigo certificate chain for bonk.io servers
4
+ * This script builds a complete certificate chain for bonk.io servers
5
+ */
6
+
7
+ const { execSync } = require('child_process');
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const OUTPUT_FILE = path.join(__dirname, '..', 'bonk_fullchain.pem');
12
+ const BONK_SERVER = 'b2ny1.bonk.io';
13
+
14
+ /**
15
+ * Download intermediate certificate from Sectigo
16
+ */
17
+ function downloadIntermediateCert() {
18
+ try {
19
+ console.log('Downloading intermediate certificate from Sectigo...');
20
+
21
+ // Use HTTP (not HTTPS) to avoid certificate issues
22
+ const intermediateUrl = 'http://crt.sectigo.com/SectigoPublicServerAuthenticationCADVR36.crt';
23
+
24
+ // Download and convert DER to PEM
25
+ const command = `curl -s "${intermediateUrl}" | openssl x509 -inform DER -outform PEM`;
26
+
27
+ const intermediatePem = execSync(command, {
28
+ encoding: 'utf8',
29
+ maxBuffer: 10 * 1024 * 1024
30
+ });
31
+
32
+ if (!intermediatePem || !intermediatePem.includes('BEGIN CERTIFICATE')) {
33
+ throw new Error('Failed to download intermediate certificate');
34
+ }
35
+
36
+ return intermediatePem;
37
+ } catch (error) {
38
+ console.warn('Warning: Could not download intermediate certificate:', error.message);
39
+ return null;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Download root certificate
45
+ */
46
+ function downloadRootCert() {
47
+ try {
48
+ console.log('Downloading root certificate...');
49
+
50
+ // USERTrust RSA Certification Authority (root)
51
+ const rootUrl = 'http://crt.usertrust.com/USERTrustRSACertificationAuthority.crt';
52
+
53
+ // Download and convert DER to PEM
54
+ const command = `curl -s "${rootUrl}" | openssl x509 -inform DER -outform PEM`;
55
+
56
+ const rootPem = execSync(command, {
57
+ encoding: 'utf8',
58
+ maxBuffer: 10 * 1024 * 1024
59
+ });
60
+
61
+ if (!rootPem || !rootPem.includes('BEGIN CERTIFICATE')) {
62
+ throw new Error('Failed to download root certificate');
63
+ }
64
+
65
+ return rootPem;
66
+ } catch (error) {
67
+ console.warn('Warning: Could not download root certificate:', error.message);
68
+ return null;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Main function to download and save certificate chain
74
+ */
75
+ function main() {
76
+ console.log('Building Sectigo certificate chain for bonk.io...');
77
+
78
+ try {
79
+ const certs = [];
80
+ let certCount = 0;
81
+
82
+ // Download intermediate certificate
83
+ const intermediate = downloadIntermediateCert();
84
+ if (intermediate) {
85
+ certs.push(intermediate);
86
+ certCount++;
87
+ }
88
+
89
+ // Download root certificate
90
+ const root = downloadRootCert();
91
+ if (root) {
92
+ certs.push(root);
93
+ certCount++;
94
+ }
95
+
96
+ if (certs.length === 0) {
97
+ throw new Error('Failed to download any certificates');
98
+ }
99
+
100
+ // Combine certificates (intermediate first, then root)
101
+ const fullChain = certs.join('\n');
102
+
103
+ // Save to file
104
+ fs.writeFileSync(OUTPUT_FILE, fullChain, 'utf8');
105
+
106
+ console.log(`✓ Downloaded ${certCount} certificate(s)`);
107
+ console.log(`✓ Certificate chain saved to: ${OUTPUT_FILE}`);
108
+ console.log('✓ You can now run your bot with: npm run host-bot or npm run simple-bot');
109
+ } catch (error) {
110
+ console.error('Error downloading certificates:', error.message);
111
+ console.error('\nNote: This script requires curl and openssl to be installed on your system.');
112
+ process.exit(1);
113
+ }
114
+ }
115
+
116
+ // Run if called directly
117
+ if (require.main === module) {
118
+ main();
119
+ }
120
+
121
+ module.exports = { main };