Repository navigation
Conversation
FirebaseAuth queries with kSecMatchLimit = 2 and expects an array of attribute dictionaries. PlayChain only recognised kSecMatchLimitAll, so it returned a single dictionary with errSecSuccess and Firebase failed with ERROR_KEYCHAIN_ERROR (17995) on every launch, forcing users to sign in again.
Member
|
Can you move the |
The match-limit check does not use instance state and is only called from copyMatching, so it belongs on PlayKeychain. Behavior is unchanged. Co-authored-by: jokerlin <jokerlin@users.noreply.github.com>
cursor
Bot
force-pushed
the
fix/playchain-numeric-matchlimit-upstream
branch
from
October 16, 2026 07:14
acb0b91 to
2c6be54
Compare
This was referenced Oct 16, 2026
Closed
Author
|
@TheMoonThatRises Thank you for the review. |
…tem queries copyAllMatches only built arrays of data or attribute dictionaries. With a numeric or kSecMatchLimitAll limit: - a query with no kSecReturn* key now only reports status, as the single-item path already did, instead of returning an array; - a kSecReturnRef query now returns an array of SecKey references built by copyReference, instead of attribute dictionaries. Disable file_length for PlayedApple.swift, as PlayAction.swift does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Apps that use FirebaseAuth (e.g. Brown Dust 2,
com.neowizgames.game.browndust2ios) ask the user to sign in again on every launch when PlayChain is enabled.FirebaseAuth reads the saved user with
kSecMatchLimit = 2(a CFNumber) pluskSecReturnDataandkSecReturnAttributes, and expects a CFArray of attribute dictionaries (AuthKeychainServices.getItem).PlayKeychain.copyMatchingonly treatskSecMatchLimitAllas a multi-item query. For a numeric limit it returns a single dictionary witherrSecSuccess. Firebase'sas? [[String: Any]]cast fails and it throws:Because the read fails, Firebase also writes a fresh item on each sign-in, so duplicate
genprows pile up in the PlayChain db.Fix
kSecMatchLimitAllor a CFNumber limit > 1 now returns a CFArray, truncated to the limit.The truncated list goes through the existing
copyAllMatches, which already keepsv_DatawhenkSecReturnDatais set.PlayKeychain(multiMatchLimit), socopyMatchingstays within SwiftLint limits.kSecMatchLimitAll) now also handle existence checks (nokSecReturn*key: status only) andkSecReturnRef(array ofSecKey).PlayedApple.swiftdisablesfile_length, asPlayAction.swiftdoes.The
hook_setCurrentSubscription:signature change moved to #244.Testing
--strict: no violations inPlayedApple.swift.kSecMatchLimitAll→ all, NSNumber 2 → 2, NSNumber 1 /kSecMatchLimitOne/ nil → single-item path, result casts to[[String: Any]]withv_Datawhenr_Datais set.kSecReturnRefhandling) ported to the MaaTools fork that my PlayCover build uses (fix(PlayChain): return CFArray for numeric kSecMatchLimit (fixes FirebaseAuth re-login) hguandl/PlayTools#10), on macOS with PlayCover 3.1.0.maa.10 and Brown Dust 2 v2.36.7 / v2.37.13: before the patch every relaunch showed the sign-in screen with the error above. With the patched PlayTools, after one sign-in the game relaunches straight to the title screen with the UID shown, and the Firebase error no longer appears.