Skip to content

Commit

Permalink
fix: fix joining to some popular servers (since dns was resovle was i…
Browse files Browse the repository at this point in the history
…ncorrectly used)

fix: fix some auth issues when starting the app locally
  • Loading branch information
zardoy committed Sep 7, 2024
1 parent cd9ead7 commit 9160ff3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/inventoryWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const onGameLoad = (onLoad) => {

bot.on('windowOpen', (win) => {
if (implementedContainersGuiMap[win.type]) {
// todo also render title!
openWindow(implementedContainersGuiMap[win.type])
} else if (options.unimplementedContainers) {
openWindow('ChestWin')
Expand Down Expand Up @@ -385,6 +384,11 @@ const openWindow = (type: string | undefined) => {

lastWindow = inv
const upWindowItems = () => {
if (!lastWindow && bot.currentWindow) {
// edge case: might happen due to high ping, inventory should be closed soon!
// openWindow(implementedContainersGuiMap[bot.currentWindow.type])
return
}
void Promise.resolve().then(() => upInventoryItems(type === undefined))
}
upWindowItems()
Expand Down
9 changes: 5 additions & 4 deletions src/microsoftAuthflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export default async ({ tokenCaches, proxyBaseUrl, setProgressText = (text) => {
}
}

function isPageSecure () {
return window.location.protocol === 'https:'
function isPageSecure (url = window.location.href) {
return !url.startsWith('http:')
}

// restore dates from strings
Expand Down Expand Up @@ -161,9 +161,10 @@ function pemToArrayBuffer (pem) {
}

const urlWithBase = (url: string, base: string) => {
if (!base.startsWith('http')) base = `https://${base}`
const defaultBase = isPageSecure() ? 'https' : 'http'
if (!base.startsWith('http')) base = `${defaultBase}://${base}`
const urlObj = new URL(url, base)
base = base.replace(/^https?:\/\//, '')
urlObj.host = base.includes(':') ? base : `${base}:${isPageSecure() ? '443' : '80'}`
urlObj.host = base.includes(':') ? base : `${base}:${isPageSecure(base) ? '443' : '80'}`
return urlObj
}
1 change: 1 addition & 0 deletions src/shims/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports.resolveSrv = function (hostname, callback) {
const willreturn = []
for (const object of response.Answer) {
const data = object.data.split(' ')
if (data[3] === undefined || data[2] === undefined) continue
willreturn.push({
priority: data[0],
weight: data[1],
Expand Down

0 comments on commit 9160ff3

Please sign in to comment.