Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression with LCP passphrases #542

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ All notable changes to this project will be documented in this file. Take a look

* The `close()` and `Closeable` APIs are now deprecated. Resources are automatically released upon `deinit`, which aligns better with Swift.

### Fixed

#### LCP

* Fixed a regression that caused some LCP passphrases to no longer match the protected publication.


## [3.0.0-beta.2]

Expand Down
17 changes: 13 additions & 4 deletions Sources/Adapters/LCPSQLite/SQLiteLCPPassphraseRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ public class LCPSQLitePassphraseRepository: LCPPassphraseRepository, Loggable {

public func passphrasesMatching(userID: User.ID?, provider: LicenseDocument.Provider) async throws -> [LCPPassphraseHash] {
try logAndRethrow {
try db.prepare(transactions.select(passphrase)
.filter(self.userId == userID && self.provider == provider)
)
.compactMap { try $0.get(passphrase) }
var passphrases =
try db.prepare(transactions.select(passphrase)
.filter(self.userId == userID && self.provider == provider)
)
.compactMap { try $0.get(passphrase) }

// The legacy SQLite database did not save all the new
// (passphrase, userID, provider) tuples. So we need to fall back
// on checking all the saved passphrases for a match.
passphrases += try db.prepare(transactions.select(passphrase))
.compactMap { try $0.get(passphrase) }

return passphrases
}
}

Expand Down