:construction: Work in Progress! :construction:
A universal JS library for parsing and editing epubs in both Node.js (v8.x +) and the browser.
Note: Support for signatures requires Node v10+ for the Crypto API used by the node WebCrypto pollyfill.
.epub
archive files and expanded epub diretories.Note: Epubkit relies on BrowserFS v2.0.0-beta for browser support of node fs. Cryptographic signing and hashing for signatures.xml relies on XMLDSIG and a WebCrypto pollyfill for Node.
npm install git+https://github.com/new-cairo-sky/epubkit.git
import Epubkit from "epubkit";
const epubkit = new Epubkit();
await epubkit.load("/path/to/epub-dir");
// get the opf metadata as an object
const metadata = epubkit.opf.metadata;
Tests are made with jest. The server must be running for browser-based tests. Jest Puppeteer is configured with JSDom to enable DOM support during browser testing with es6 imports; see: https://github.com/zaqqaz/jest-environment-puppeteer-jsdom. Also see the package.json Jest config for details.
npm start
npm test
or
npm test -- [test-file-name].test.js
The testing server can be viewed at http://localhost:3000/
All xml attributes are normalized to lower case. Although XML should be case-sensitive, in practice, attributes cases are not consistently implemented. See, for example: https://stackoverflow.com/questions/2477653/the-case-of-id-attribute-when-signing-an-element-in-a-xml-file. Furthermore, the case style of attributes is not consistent across w3c specs - epub xml attr tend to be kebab-case, while Signature xml tends to PascalCase.