baltica 0.1.24 → 0.1.26

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/README.md CHANGED
@@ -32,6 +32,7 @@ Complete rewrite, from the ground up! Here's what makes it awesome:
32
32
 
33
33
  `0.1.13` → Minecraft Bedrock `1.21.113`
34
34
 
35
+ `0.1.26` → Minecraft Bedrock `1.21.130` & `1.21.132`
35
36
 
36
37
  *Note: We dropped multi-version support because honestly, it was more trouble than it was worth. One version, done right.*
37
38
 
@@ -231,9 +231,10 @@ async function getMicrosoftAccessToken(email, password, proxiedFetch) {
231
231
  });
232
232
  // Check for access token in redirect
233
233
  let location = loginResp.headers.get("location") || "";
234
+ const allCookies = `${cookies}; ${extractCookies(loginResp.headers)}`;
234
235
  // Follow redirects manually to find the access token
235
236
  let attempts = 0;
236
- while (attempts < 5 && !location.includes("access_token=")) {
237
+ while (attempts < 10 && !location.includes("access_token=")) {
237
238
  if (!location) {
238
239
  // Check if we got an error page
239
240
  const responseText = await loginResp.text();
@@ -245,12 +246,28 @@ async function getMicrosoftAccessToken(email, password, proxiedFetch) {
245
246
  responseText.includes("idA_PWD_SwitchToCredPicker")) {
246
247
  throw new Error("2FA is enabled on this account. Direct login requires 2FA to be disabled.");
247
248
  }
249
+ if (responseText.includes("identity/confirm")) {
250
+ throw new Error("Microsoft requires identity confirmation. Please log in via browser first.");
251
+ }
252
+ if (responseText.includes("recover?") ||
253
+ responseText.includes("account.live.com/recover")) {
254
+ throw new Error("Microsoft requires account recovery. Please verify your account via browser.");
255
+ }
248
256
  // Try to extract access token from response body (some flows embed it)
249
257
  const tokenMatch = responseText.match(/access_token=([^&"']+)/);
250
258
  if (tokenMatch) {
251
259
  return decodeURIComponent(tokenMatch[1]);
252
260
  }
253
- throw new Error("Failed to get redirect URL from login response");
261
+ // Check for urlPost redirect in response (sometimes login returns another form)
262
+ const urlPostMatch = responseText.match(/urlPost:\s*'([^']+)'/);
263
+ if (urlPostMatch) {
264
+ location = urlPostMatch[1];
265
+ attempts++;
266
+ continue;
267
+ }
268
+ throw new Error("Failed to get redirect URL from login response. " +
269
+ "This can happen due to rate limiting, CAPTCHA, or security challenges. " +
270
+ "Try again in a few minutes or log in via browser first.");
254
271
  }
255
272
  if (location.includes("access_token=")) {
256
273
  break;
@@ -258,11 +275,20 @@ async function getMicrosoftAccessToken(email, password, proxiedFetch) {
258
275
  const redirectResp = await proxiedFetch(location, {
259
276
  headers: {
260
277
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
261
- Cookie: cookies,
278
+ Cookie: allCookies,
262
279
  },
263
280
  redirect: "manual",
264
281
  });
265
- location = redirectResp.headers.get("location") || "";
282
+ // Check response body for token if no redirect
283
+ const newLocation = redirectResp.headers.get("location") || "";
284
+ if (!newLocation && !newLocation.includes("access_token=")) {
285
+ const body = await redirectResp.text();
286
+ const tokenMatch = body.match(/access_token=([^&"']+)/);
287
+ if (tokenMatch) {
288
+ return decodeURIComponent(tokenMatch[1]);
289
+ }
290
+ }
291
+ location = newLocation;
266
292
  attempts++;
267
293
  }
268
294
  // Extract access token from URL fragment
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "baltica",
3
3
  "description": "Library for Minecraft Bedrock Edition community developers.",
4
- "version": "0.1.24",
4
+ "version": "0.1.26",
5
5
  "minecraft": "1.21.130",
6
6
  "main": "dist/index.js",
7
7
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  }
22
22
  ],
23
23
  "dependencies": {
24
- "@sanctumterra/raknet": "^1.4.11",
24
+ "@sanctumterra/raknet": "latest",
25
25
  "@serenityjs/binarystream": "^3.0.10",
26
26
  "@serenityjs/protocol": "^0.8.17",
27
27
  "fetch-socks": "^1.3.2",
28
28
  "jose": "^5.10.0",
29
29
  "prismarine-auth": "^2.7.0",
30
- "undici": "^7.18.2",
30
+ "undici": "^7.19.0",
31
31
  "uuid-1345": "^1.0.2"
32
32
  },
33
33
  "devDependencies": {