Swiftpack.co -  readium/r2-lcp-swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
readium/r2-lcp-swift
Swift LCP module
.package(url: "https://github.com/readium/r2-lcp-swift.git", from: "2.0.0")

r2-lcp-swift

Swift wrapper module for LCP support

Changes and releases are documented in the Changelog

Adding the module to your iOS project

Note: requires Swift 4.2 (and Xcode 10.1).

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa. To install ReadiumLCP with Carthage:

  1. Make sure Carthage is installed and up-to-date.

  2. Update your app's Cartfile to include the following:

    github "readium/r2-lcp-swift" "develop"
    
    
  3. Run:

  4. Add the appropriate framework. ```

Integration in your project

After adding the r2-lcp-swift module to your project and the private R2LCPClient.framework provided by EDRLab, you can use LCP in your app by creating an instance of LCPService.

LCPService expects an implementation of LCPClient, which acts as a facade to R2LCPClient.framework. Copy and paste the following:

import R2LCPClient
import ReadiumLCP

let lcpService = LCPService(client: LCPClient())

/// Facade to the private R2LCPClient.framework.
class LCPClient: ReadiumLCP.LCPClient {

    func createContext(jsonLicense: String, hashedPassphrase: String, pemCrl: String) throws -> LCPClientContext {
        return try R2LCPClient.createContext(jsonLicense: jsonLicense, hashedPassphrase: hashedPassphrase, pemCrl: pemCrl)
    }

    func decrypt(data: Data, using context: LCPClientContext) -> Data? {
        return R2LCPClient.decrypt(data: data, using: context as! DRMContext)
    }

    func findOneValidPassphrase(jsonLicense: String, hashedPassphrases: [String]) -> String? {
        return R2LCPClient.findOneValidPassphrase(jsonLicense: jsonLicense, hashedPassphrases: hashedPassphrases)
    }

}

Dependencies in this module

  • R2Shared : Custom types shared by several readium-2 Swift modules.
  • ZIPFoundation : Effortless ZIP Handling in Swift
  • SQLite.swift : A type-safe, Swift-language layer over SQLite3.
  • CryptoSwift : CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift

GitHub

link
Stars: 3
Last commit: 4 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

2.0.0
2 weeks ago

Take a look at the migration guide

Deprecated

  • All APIs deprecated in previous versions are now unavailable.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API