Keep long Microsoft sign-in secrets in several keychain items

Credential Manager takes at most 2560 bytes per item. The secrets of a
Microsoft sign-in (the refresh token and the Minecraft token) are longer,
so saving them failed on Windows with "password encoded as UTF-16 is
longer than platform limit of 2560 chars" and the sign-in did not finish.

On macOS and Windows a secret is now split over the items `<uuid>`,
`<uuid>.1`, `<uuid>.2`... of at most 1000 UTF-8 bytes each (under 2560
bytes of UTF-16). Reads join the pieces, a write removes the leftovers
of a longer secret, and sign-out removes all of them. Existing single
items keep working.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
leifiyoo
2026-10-27 16:53:00 +01:00
parent 9972feb710
commit 8d2b298253
3 changed files with 117 additions and 12 deletions
+2 -1
View File
@@ -74,7 +74,8 @@ one is selected. "Sign out" deletes the account's secrets from the keychain.
- Secrets (the Microsoft refresh token, the Minecraft access token and its expiry) go to the OS
keychain, one item per account: Keychain on macOS, Credential Manager on Windows, the Secret
Service (GNOME Keyring, KWallet) on Linux. Service name `dev.playhorizon.launcher`, account = the
Minecraft UUID.
Minecraft UUID. Credential Manager takes at most 2560 bytes per item, which the secrets of a sign-in
exceed: on macOS and Windows a longer secret is split over the items `<uuid>`, `<uuid>.1`, `<uuid>.2`...
- `accounts.json` in the launcher's data folder keeps only public data: UUID, name, skin URL, which
account is selected. Never a token.
- No keychain available (a Linux box without a Secret Service, a locked keychain): sign-in still