futurepress / epub.js

Enhanced eBooks in the browser.
http://futurepress.org
Other
6.5k stars 1.11k forks source link

How to open password protected ePub file? #1352

Open praveen-jangre opened 1 year ago

praveen-jangre commented 1 year ago

I am working on the ePub rendering engine. To achieve file/content protection, we have done file protection with a password.

Could you please help me open these password-protected files which are stored in the server as well as local storage?

Thank you in advance.

johnfactotum commented 1 year ago

It's not clear how you're password protecting the file, but in any case it wouldn't be something that's supported by Epub.js (unless you're encrypting the whole file after zipping, in which case just reverse that before feeding it to Epub.js).

The most proper way to do DRM would involve using encryption.xml, which Epub.js does not support (it doesn't even deobfuscate fonts). If you use something like that, you'd need to decrypt it yourself and serve the EPUB unpacked to Epub.js (i.e. opening it as a directory or .opf or .json).

praveen-jangre commented 4 months ago

@johnfactotum Thank you for your response.

As you know, ePub files are zip-compressed files. Passwords have been added to these zip-compressed files so that only people with the correct passwords can open the files.

Could you help me how I can load these password-protected ePub files using epub.js?

johnfactotum commented 3 months ago

Epub.js uses JSZip, which doesn't support password protected zip files. So you're best option would be to use another Zip library and unpack it before opening it with Epub.js (i.e. serving the EPUB as a directory or .opf or .json).