Skip to content

Commit

Permalink
Fix regression with LCP passphrases (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu authored Jan 21, 2025
1 parent b603df6 commit 50c2a5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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

0 comments on commit 50c2a5b

Please sign in to comment.