readium / webpub-manifest

📜 A JSON based Web Publication Manifest format used at the core of the Readium project
BSD 3-Clause "New" or "Revised" License
91 stars 23 forks source link

encrypted compression "none" vs "store" #22

Open danielweck opened 5 years ago

danielweck commented 5 years ago

https://github.com/readium/webpub-manifest/blob/master/extensions/epub.md#encrypted

The current Readium2 TypeScript / NodeJS implementation uses "none", not "store". Update: Kotlin, Swift and Go too.

danielweck commented 5 years ago

Typescript:

https://github.com/readium/r2-shared-js/blob/41eb2bf265d0145ef17a6affd159f2e79ea6d7ed/src/parser/epub.ts#L1488-L1492

if (prop.Compression.Method === "8") {
    encrypted.Compression = "deflate";
} else {
    encrypted.Compression = "none";
}
danielweck commented 5 years ago

Go:

https://github.com/readium/r2-streamer-go/blob/e4bf2ff6f829c2e6a87d62d83e4edf7bb876859c/parser/epub.go#L631-L635

if prop.Compression.Method == "8" {
    encrypted.Compression = "deflate"
} else {
    encrypted.Compression = "none"
}
danielweck commented 5 years ago

Kotlin:

https://github.com/readium/r2-streamer-kotlin/blob/097db8477680b434360283efc032e509c6a485af/r2-streamer/src/main/java/org/readium/r2/streamer/parser/epub/EncryptionParser.kt#L32

encryption.compression = if (method == "8") "deflate" else "none"
danielweck commented 5 years ago

Swift:

https://github.com/readium/r2-streamer-swift/blob/de36714b6137ff73c7f2b46700363771322fbfba/Sources/parser/EncryptionParser.swift#L84

encryption.compression = (method == "8" ? "deflate" : "none")
HadrienGardeur commented 5 years ago

OK, I'm fine using none as well, it just needs to be documented.

How far do we want to go though in the JSON Schema? Should we limit this value to an enum with only deflate and none?

danielweck commented 5 years ago

I think this is safe for now. http://www.idpf.org/epub/31/spec/epub-ocf.html#sec-enc-compression

Value is either "0" (no compression) or "8" (Deflate algorithm).

HadrienGardeur commented 5 years ago

It's safe for EPUB but we might need to support other packaging formats in the future.