Skip to content

login: Migrate to Native #106

Open
highesttt wants to merge 11 commits into
mainfrom
highest/plat-37693
Open

login: Migrate to Native #106
highesttt wants to merge 11 commits into
mainfrom
highest/plat-37693

Conversation

@highesttt

@highesttt highesttt commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Changelog

  • Overhauled login -> native login w/ hidden webview to get castle tokens instead of webview

Checklist

@highesttt
highesttt requested a review from tulir July 1, 2026 18:37
Comment thread .gitignore Outdated
Comment thread pkg/twittermeow/client.go Outdated
Comment thread pkg/twittermeow/headers.go Outdated
Comment on lines +11 to +14
const ChromeVersion = "149"
const UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + ChromeVersion + ".0.0.0 Safari/537.36"
const SecCHUserAgent = `"Google Chrome";v="` + ChromeVersion + `", "Chromium";v="` + ChromeVersion + `", "Not)A;Brand";v="24"`
const OSName = "Windows"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are wrong and probably need to be reverted. The TLS library hasn't been updated for Chrome 148+ yet, 141 is still equivalent to 120. The order in sec-ch headers is random and doesn't need to be changed unless implementing proper randomization like how chrome does it

Comment thread pkg/twittermeow/methods/html.go Outdated
Comment thread pkg/connector/login.go Outdated
Comment thread pkg/twittermeow/castle_token.go Outdated
} else if seconds > 268435455 {
seconds = 268435455
}
timeBytes := []byte{byte(seconds >> 24), byte(seconds >> 16), byte(seconds >> 8), byte(seconds)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
timeBytes := []byte{byte(seconds >> 24), byte(seconds >> 16), byte(seconds >> 8), byte(seconds)}
timeBytes := binary.BigEndian.AppendUint32(nil, uint32(seconds))

Comment thread pkg/twittermeow/castle_token.go Outdated
seconds = 268435455
}
timeBytes := []byte{byte(seconds >> 24), byte(seconds >> 16), byte(seconds >> 8), byte(seconds)}
msBytes := []byte{byte((timestampMillis % 1000) >> 8), byte(timestampMillis % 1000)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msBytes := []byte{byte((timestampMillis % 1000) >> 8), byte(timestampMillis % 1000)}
msBytes := binary.BigEndian.AppendUint16(nil, timestampMillis % 1000)

Comment on lines +676 to +700
func jetfuelTimezone() string {
if timezone := strings.TrimSpace(os.Getenv("TWITTER_JETFUEL_TIMEZONE")); timezone != "" {
return timezone
}
if local := time.Local.String(); strings.Contains(local, "/") {
return local
}
_, offset := time.Now().Zone()
switch offset {
case -10 * 60 * 60:
return "Pacific/Honolulu"
case -9 * 60 * 60:
return "America/Anchorage"
case -8 * 60 * 60:
return "America/Los_Angeles"
case -7 * 60 * 60:
return "America/Denver"
case -6 * 60 * 60, -5 * 60 * 60:
return "America/Chicago"
case -4 * 60 * 60:
return "America/New_York"
default:
return "UTC"
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these really supposed to be hardcoded?

Comment thread pkg/twittermeow/castle_web_token.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in this file looks extremely fragile

Comment thread pkg/twittermeow/castle_web_token_test.go Outdated
@highesttt highesttt changed the title Highest/plat 37693 Migrate leftover legacy chat flows to xchat + Native Login Jul 15, 2026
@highesttt
highesttt force-pushed the highest/plat-37693 branch from 0971495 to ec225d0 Compare July 16, 2026 15:58
@highesttt highesttt changed the title Migrate leftover legacy chat flows to xchat + Native Login Migrate to Native Login Jul 16, 2026
@highesttt highesttt changed the title Migrate to Native Login login: Migrate to Native Jul 16, 2026
Comment thread pkg/connector/login.go Outdated
contextURL, _ := json.Marshal(castleTokenContextURL)
identifierJSON, _ := json.Marshal(identifier)
return fmt.Sprintf(`(async () => {
const scriptURL = %s;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go into a separate file that's embedded with go:embed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants