@ridi/epub-parser
Advanced tools
Comparing version 0.2.0-alpha.6 to 0.2.0
@@ -12,2 +12,24 @@ # Changelog | ||
## [0.2.0 (2018-11-19)] | ||
### Added | ||
* Add `serializedAnchor` option. | ||
* Add `Author.fileAs` property. | ||
* Add encrypt and decrypt function. | ||
### Changed | ||
* Change `ignoreLinear` option default. (`true` => `false`) | ||
* Change `useStyleNamespace` option default. (`false` => `true`) | ||
* Change `readOptions` structure. | ||
* Remove `usingCssOptions` and `validateXml` option. | ||
* Rename `useStyleNamespace` to `parseStyle`. | ||
* Rename `SpineItem.spineIndex` to `SpineItem.index`. | ||
### Fixed | ||
* Fix an issue where ncx could not be found in opf, and `allowNcxFileMissing` was false, but no exception was thrown. | ||
* Fix an issue where `Book.spines` order does not match spine order of OPF. | ||
## [0.1.1 (2018-10-08)] | ||
@@ -24,9 +46,9 @@ | ||
* Add `overwrite` option. | ||
* Add `uesCssOptions` option. | ||
* Add `spine.uesCssOptions` option. | ||
### Changed | ||
* Remove `extractAdapter` option. | ||
* Remove `spine.extractAdapter` option. | ||
* Remove `createIntermediateDirectories` and `removePreviousFile` options. (replaced by `overwrite` option) | ||
* Change `removeAtrules` option default. | ||
* Change `css.removeAtrules` option default. | ||
* Improve parsing of epub version. | ||
@@ -50,3 +72,4 @@ * Simplifies return type of `readitem` or `readItems`. | ||
[Unreleased]: https://github.com/ridi/epub-parser/compare/0.1.1...HEAD | ||
[Unreleased]: https://github.com/ridi/epub-parser/compare/0.2.0...HEAD | ||
[0.2.0 (2018-11-19)]: https://github.com/ridi/epub-parser/compare/0.1.1...0.2.0 | ||
[0.1.1 (2018-10-08)]: https://github.com/ridi/epub-parser/compare/0.1.0...0.1.1 | ||
@@ -53,0 +76,0 @@ [0.1.0 (2018-09-12)]: https://github.com/ridi/epub-parser/compare/0.0.2...0.1.0 |
{ | ||
"name": "@ridi/epub-parser", | ||
"version": "0.2.0-alpha.6", | ||
"version": "0.2.0", | ||
"description": "Common EPUB2 data parser for Ridibooks services written in ES6", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -41,2 +41,4 @@ # @ridi/epub-parser | ||
Basic: | ||
```js | ||
@@ -55,2 +57,40 @@ import { EpubParser } from '@ridi/epub-parser'; | ||
with [Cryptor](https://github.com/ridi/epub-parser/blob/master/src/cryptor/Cryptor.js): | ||
```js | ||
import { CryptoProvider, Cryptor } from '@ridi/epub-parser'; | ||
// or const { CryptoProvider, Cryptor } = require('@ridi/epub-parser'); | ||
const { Status } = CryptoProvider; | ||
const { Modes, Padding } = Cryptor; | ||
class ContentCryptoProvider extends CryptoProvider { | ||
constructor(key) { | ||
super(); | ||
this.cryptor = new Cryptor(Modes.ECB, { key, padding: Padding.PKCS7 }); | ||
} | ||
// Encrypt all content when unzipping and decrypt it when read. | ||
run(data, filePath) { | ||
if (this.status === Status.UNZIP) { | ||
return this.encrypt(data); | ||
} else if (this.status === Status.READ) { | ||
return Buffer.from(this.decrypt(data)); | ||
} | ||
return data; | ||
} | ||
encrypt(data, filePath) { | ||
return this.cryptor.encrypt(data); | ||
} | ||
decrypt(data, filePath) { | ||
return this.cryptor.decrypt(data); | ||
} | ||
} | ||
const cryptoProvider = new ContentCryptoProvider(key); | ||
const parser = new EpubParser('./foo/bar.epub' or './unzippedPath', cryptoProvider); | ||
``` | ||
## API | ||
@@ -57,0 +97,0 @@ |
155454
556
21