fix(slackdesktop): pick the right macOS Safe Storage key
A machine that has run both Slack builds carries two login-keychain
items under the service "Slack Safe Storage", told apart only by their
account name ("Slack App Store Key" for the sandboxed build). Looking
one up by service alone returns an arbitrary match, so slk could try to
decrypt the standalone profile's cookie DB with the App Store key.
Enumerate the accounts with `security dump-keychain` (attributes only,
so it raises no authorization prompt), order them by whether the profile
being read is sandboxed, and hand every candidate to decryptCookieValue,
which now tries each until one yields a plausible cookie. The
service-only lookup stays as a fallback, so restricted environments
behave exactly as before.
Reject unprintable plaintext while here: PKCS#7 padding was the only
integrity check, and a wrong key satisfies it about one time in sixteen,
then returns binary garbage. net/http silently drops the invalid bytes
and Slack answers invalid_auth -- nowhere near the actual fault. J
Jérémy committed
72e40590eb2043060ff53b90f2be4412a151b409
Parent: cdc6eb1