Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add a SwiftUI LCP authentication dialog#607

Merged
mickael-menu merged 5 commits intodevelopfrom
lcp-swiftui
Jun 10, 2025
Merged

Add a SwiftUI LCP authentication dialog#607
mickael-menu merged 5 commits intodevelopfrom
lcp-swiftui

Conversation

Copy link
Member

mickael-menu commented Jun 10, 2025

Added

LCP

  • A brand new LCP authentication dialog for SwiftUI applications.

Using the SwiftUI LCP Authentication dialog

If your application is built using SwiftUI, you cannot use LCPAuthenticationDialog because it requires a UIKit view controller as its host. Instead, use an LCPObservableAuthentication combined with our SwiftUI LCPDialog presented as a sheet.

@main
struct MyApp: App {
private let lcpService: LCPService
private let publicationOpener: PublicationOpener

@StateObject private var lcpAuthentication: LCPObservableAuthentication

init() {
// Create an `LCPObservableAuthentication` which will be used
// to initialize the `LCPContentProtection`.
//
// With SwiftUI, it must be stored in a `@StateObject` property
// to observe the authentication requests.
let lcpAuthentication = LCPObservableAuthentication()
_lcpAuthentication = StateObject(wrappedValue: lcpAuthentication)

lcpService = LCPService(...)

publicationOpener = PublicationOpener(
...,
contentProtections: [
lcpService.contentProtection(with: lcpAuthentication)
]
)
}

var body: some Scene {
WindowGroup {
ContentView()
// You can present an `LCPDialog` when the `LCPObservableAuthentication`
// `request` property is updated.
.sheet(item: $lcpAuthentication.request) {
LCPDialog(request: $0)
}
}
}
}
}

mickael-menu requested a review from Copilot June 10, 2025 12:50
mickael-menu had a problem deploying to LCP June 10, 2025 12:50 -- with GitHub Actions Error
mickael-menu had a problem deploying to LCP June 10, 2025 12:50 -- with GitHub Actions Error

This comment was marked as off-topic.

mickael-menu requested a review from Copilot June 10, 2025 12:51
Copilot AI reviewed Jun 10, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a SwiftUI-compatible LCP authentication dialog and updates related documentation and code to support the new authentication flow. Key changes include:

  • New documentation instructions for insecure HTTP requests and SwiftUI authentication usage.
  • Introduction of SwiftUI components: LCPObservableAuthentication and LCPDialog.
  • Updated APIs and localized strings to support the new dialog.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/Guides/Readium LCP.md Added insecure HTTP request instructions and SwiftUI authentication usage guide.
Sources/LCP/Toolkit/ReadiumLCPLocalizedString.swift Introduced a helper for localized string keys.
Sources/LCP/Resources/en.lproj/Localizable.strings Updated localized strings for the new dialog and removed legacy duplicates.
Sources/LCP/License/Model/Components/Link.swift Changed access level to public for certain members.
Sources/LCP/Authentications/LCPObservableAuthentication.swift Added a new observable authentication implementation for SwiftUI.
Sources/LCP/Authentications/LCPDialog.swift Added a new SwiftUI dialog view for LCP authentication.
CHANGELOG.md Documented the new SwiftUI LCP authentication dialog feature.
Comments suppressed due to low confidence (1)

docs/Guides/Readium LCP.md:158

  • Consider adding a brief note on the security implications of allowing insecure HTTP requests to help developers understand the associated risks.
### Allow insecure HTTP requests

mickael-menu temporarily deployed to LCP June 10, 2025 12:51 -- with GitHub Actions Inactive
mickael-menu temporarily deployed to LCP June 10, 2025 12:51 -- with GitHub Actions Inactive
mickael-menu had a problem deploying to LCP June 10, 2025 12:53 -- with GitHub Actions Error
mickael-menu had a problem deploying to LCP June 10, 2025 12:53 -- with GitHub Actions Error
mickael-menu force-pushed the lcp-swiftui branch from e7637b5 to 2451114 Compare June 10, 2025 14:04
mickael-menu temporarily deployed to LCP June 10, 2025 14:04 -- with GitHub Actions Inactive
mickael-menu temporarily deployed to LCP June 10, 2025 14:04 -- with GitHub Actions Inactive
mickael-menu merged commit 32e6308 into develop Jun 10, 2025
5 checks passed
mickael-menu deleted the lcp-swiftui branch June 10, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants