Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

r2-lcp-js

readium5.3kBSD-3-Clause1.0.44TypeScript support: included

Readium 2 LCP bits for NodeJS (TypeScript)

readium, readium2, LCP, EPUB, TypeScript, JavaScript, ES5, ES6, ECMAScript 2015, ECMAScript 6, ES7, ECMAScript 2016, ECMAScript 7, ES8, ECMAScript 2017, ECMAScript 8

readme

NodeJS / TypeScript Readium-2 "LCP" components

NodeJS implementation (written in TypeScript) of LCP modules for the Readium2 architecture ( https://github.com/readium/architecture/ ).

License

Build status

NPM David

Changelog

Prerequisites

1) https://nodejs.org NodeJS >= 8, NPM >= 5 (check with command line node --version and npm --version) 2) OPTIONAL: https://yarnpkg.com Yarn >= 1.0 (check with command line yarn --version)

GitHub repository

https://github.com/readium/r2-lcp-js

There is no github.io site for this project (no gh-pages branch).

NPM package

https://www.npmjs.com/package/r2-lcp-js

Command line install:

npm install r2-lcp-js OR yarn add r2-lcp-js

...or manually add in your package.json:

  "dependencies": {
    "r2-lcp-js": "latest"
  }

The JavaScript code distributed in the NPM package is usable as-is (no transpilation required), as it is automatically-generated from the TypeScript source.

Several ECMAScript flavours are provided out-of-the-box: ES5, ES6-2015, ES7-2016, ES8-2017:

https://unpkg.com/r2-lcp-js/dist/

(alternatively, GitHub mirror with semantic-versioning release tags: https://github.com/edrlab/r2-lcp-js-dist/tree/develop/dist/ )

The JavaScript code is not bundled, and it uses require() statement for imports (NodeJS style).

More information about NodeJS compatibility:

http://node.green

Note that web-browser Javascript is currently not supported (only NodeJS runtimes).

The type definitions (aka "typings") are included as *.d.ts files in ./node_modules/r2-lcp-js/dist/**, so this package can be used directly in a TypeScript project.

Example usage:

// currently no index file
// import { * } from "r2-lcp-js";

// ES5 import (assuming node_modules/r2-lcp-js/):
import { downloadEPUBFromLCPL } from "r2-lcp-js/dist/es5/src/publication-download";

// ... or alternatively using a convenient path alias in the TypeScript config (+ WebPack etc.):
import { downloadEPUBFromLCPL } from "@r2-lcp-js/publication-download";

Dependencies

https://david-dm.org/readium/r2-lcp-js

A package-lock.json is provided (modern NPM replacement for npm-shrinkwrap.json).

A yarn.lock file is currently not provided at the root of the source tree.

Continuous Integration

TODO (unit tests?) https://travis-ci.org/readium/r2-lcp-js

Badge: [![Travis](https://travis-ci.org/readium/r2-lcp-js.svg?branch=develop)](https://travis-ci.org/readium/r2-lcp-js)

Version(s), Git revision(s)

NPM package (latest published):

https://unpkg.com/r2-lcp-js/dist/gitrev.json

Alternatively, GitHub mirror with semantic-versioning release tags:

https://raw.githack.com/edrlab/r2-lcp-js-dist/develop/dist/gitrev.json

Developer quick start

Command line steps (NPM, but similar with YARN):

1) cd r2-lcp-js 2) git status (please ensure there are no local changes, especially in package-lock.json and the dependency versions in package.json) 3) rm -rf node_modules (to start from a clean slate) 4) npm install, or alternatively npm ci (both commands initialize the node_modules tree of package dependencies, based on the strict package-lock.json definition) 5) npm run build:all (invoke the main build script: clean, lint, compile) 6) ls dist (that's the build output which gets published as NPM package)

Documentation

TODO

changelog

Next

Git diff:

Changes:

  • TODO

1.0.44

Build environment: NodeJS 22.14.0, NPM 11.4.2

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.43

Build environment: NodeJS 22.12.0, NPM 11.0.0

Changes:

  • NPM package updates
  • Updated Flox/Nix (dev)

Git revision info:

Git commit history:

Git diff:

1.0.42

Build environment: NodeJS 22.11.0, NPM 11.0.0

Changes:

  • NPM package updates
  • Support for Flox/Nix (dev)

Git revision info:

Git commit history:

Git diff:

1.0.41

Build environment: NodeJS 20.17.0, NPM 10.8.3

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.40

Build environment: NodeJS 20.12.2, NPM 10.7.0

Changes:

  • Fixed crash bug introduced by LCP2.x code, affected only LCP2 publications with non-encrypted resources (including obfuscated fonts) consumed by HTML documents during rendering (fetching). Did not affect non-encrypted cover image or navigation document which are not consumed by publication HTML documents (they do not pass through the streamer transformers)

Git revision info:

Git commit history:

Git diff:

1.0.39

Build environment: NodeJS 20.10.0, NPM 10.2.5

Changes:

  • NPM package updates
  • LCP profiles

Git revision info:

Git commit history:

Git diff:

1.0.38

Build environment: NodeJS 18.16.0, NPM 9.8.0

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.37

Build environment: NodeJS 18.14.2, NPM 9.5.1

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.36

Build environment: NodeJS 18.12.1, NPM 9.1.1

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.35

Build environment: NodeJS 16.13.1, NPM 8.3.0

Changes:

  • NPM package updates
  • safeguard against callbacks that do not capture async / await thrown errors (exceptions do not automatically transit up the call chain) avoids UnhandledPromiseRejectionWarning

Git revision info:

Git commit history:

Git diff:

1.0.34

Build environment: NodeJS 16.13.1, NPM 8.3.0

Changes:

  • NPM package updates and migration from TSLINT to ESLINT

Git revision info:

Git commit history:

Git diff:

1.0.33

Build environment: NodeJS 14.18.1, NPM 6.14.15

Changes:

  • NPM package updates
  • NodeJS v14 minimum requirement

Git revision info:

Git commit history:

Git diff:

1.0.32

Build environment: NodeJS 14.17.5, NPM 6.14.14

Changes:

  • NPM package updates
  • Shorter LCP/LSD HTTP request timeouts (default was 60s!)

Git revision info:

Git commit history:

Git diff:

1.0.31

Build environment: NodeJS 14.17.5, NPM 6.14.14

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.30

Build environment: NodeJS 14.16.1, NPM 6.14.13

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.29

Build environment: NodeJS 12.18.2, NPM 6.14.5

Changes:

  • NPM package updates
  • TypeScript const enum safeguard (isolated modules)

Git revision info:

Git commit history:

Git diff:

1.0.28

Build environment: NodeJS 12.18.1, NPM 6.14.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.27

Build environment: NodeJS 12.16.3, NPM 6.14.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.26

Build environment: NodeJS 12.16.1, NPM 6.14.4

Changes:

  • NPM package updates
  • Fixed CSON-2-JSON script
  • LCP transformer support() predicate fallback to simply the Algorithm field of link.Properties.Encryption (discriminator with IDPF and Adobe obfuscation)
  • Download of encrypted publication from LCP license, and subsequent injection of META-INF/license.lcpl (for EPUBs) now works for audiobooks too

Git revision info:

Git commit history:

Git diff:

1.0.25

Build environment: NodeJS 12.16.1, NPM 6.14.4

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.24

Build environment: NodeJS 12.15.0, NPM 6.13.7

Changes:

  • NPM package updates
  • JSON property naming: original-length vs. originalLength (backwards-compatible support for the legacy name)

Git revision info:

Git commit history:

Git diff:

1.0.23

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • Dummy create context function to test certificate revoke etc. before actually trying passphrases

Git revision info:

Git commit history:

Git diff:

1.0.22

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • Hotfix for previous release: function argument was missing to propagate optional LCP/LSD HTTP headers overrides

Git revision info:

Git commit history:

Git diff:

1.0.21

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • Hotfix for previous release: function argument was missing to propagate optional LCP/LSD HTTP headers overrides

Git revision info:

Git commit history:

Git diff:

1.0.20

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • Optional LCP/LSD HTTP headers overrides

Git revision info:

Git commit history:

Git diff:

1.0.19

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • NPM package updates
  • TAJSON now parses/generates arbitrary JSON properties with typed object

Git revision info:

Git commit history:

Git diff:

1.0.18

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • NPM package updates
  • Fixed LSD renew date in URI (ISO syntax)

Git revision info:

Git commit history:

Git diff:

1.0.17

Build environment: NodeJS 12.13.0, NPM 6.12.1

Changes:

  • Fixed JSON vs. TypeScript object LSD register response error

Git revision info:

Git commit history:

Git diff:

1.0.16

Build environment: NodeJS 12.13.0, NPM 6.12.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.15

Build environment: NodeJS 10.16.3, NPM 6.12.0

Changes:

  • HTTP request header Accept otherwise some LCP/LSD servers fail (status code 406)
  • NPM updates (including NodeJS v12 for Electron v6)

Git revision info:

Git commit history:

Git diff:

1.0.14

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.13

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates
  • TypeScript sort imports

Git revision info:

Git commit history:

Git diff:

1.0.12

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.11

Build environment: NodeJS 10.16.0, NPM 6.10.2

Changes:

  • NPM updates
  • Buffer.from() API to remove deprecation messages
  • Workaround for rare (impossible?) edge-case: resource is compressed/deflated before it is encrypted, but the "original length" metadata is not provided in encryption.xml (only the "compression" metadata == 8)

Git revision info:

Git commit history:

Git diff:

1.0.10

Build environment: NodeJS 10.16.0, NPM 6.9.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.9

Build environment: NodeJS 10.15.3, NPM 6.9.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.8

Build environment: NodeJS 8.15.1, NPM 6.4.1

Changes:

  • NPM updates
  • Introduced LSD TypeScript model (JSON de/serializable)
  • Workaround for LCP license server that responds HTTP 200 code for error JSON payload
  • JSON Schema references for LCP and LSD models

Git revision info:

Git commit history:

Git diff:

1.0.7

Build environment: NodeJS 8.15.1, NPM 6.4.1

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.6

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • NPM updates
  • Code comment references to latest JSON Schema
  • LCP / LSD debug console messages harmonized
  • LCP / LSD promise.reject (async/await try/catch) errors now HTTP status code (number type), or object payload with ProblemJSON, returned by server, or just plain string if cannot parse response body.

Git revision info:

Git commit history:

Git diff:

1.0.5

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • NPM updates
  • Minor code comment additions regarding Certificate Revocation List (CRL)

Git revision info:

Git commit history:

Git diff:

1.0.4

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • Updated documentation (minor)
  • Fixed a NodeJS v8+ regression bug: readable-stream end event was not raised (which is why LCP decryption with basic-test profile was broken at Heroku and Now.sh streamer deployments)
  • NPM 6.5.* has regression bugs for global package installs, so revert back to NPM 6.4.1 (which is officially shipped with the NodeJS installer).

Git revision info:

Git commit history:

Git diff:

1.0.3

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates
  • Added support for CRL Certificate Revocation List (not via certificate-embedded Distribution Points, instead using hard-coded URL for LCP ecosystem)
  • Added HTTP error details (console logging)

Git revision info:

Git commit history:

Git diff:

1.0.2

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (r2-xxx-js)

Git revision info:

Git commit history:

Git diff:

1.0.1

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (minor)
  • Replaced deprecated RawGit URLs
  • Removed unnecessary TypeScript import path aliases

Git revision info:

Git commit history:

Git diff:

1.0.0

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (minor)
  • README info
  • VisualStudio code tweaks (developer workflow)
  • Semantic versioning bump 1.. (3-digit style now, "-alphaX" suffix caused issues with NPM tooling: updates, lockfile, etc.)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.7

Build environment: NodeJS 8.12.0, NPM 6.4.1

Changes:

  • NPM updates (minor)
  • Git revision JSON info now includes NodeJS and NPM version (build environment)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.6

Changes:

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.5

Changes:

  • Removed TypeScript linter warning message (checks for no unused variables)
  • NPM updates related to the Node TypeScript typings
  • Dependency "ta-json" updates, and NPM integration GitHub semver reference
  • NPM r2-utils-js dep update
  • Fixed TypeScript regression bug (3.0.3 -> 3.1.1) related to LCP typings

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.4

Changes:

  • NPM updates (external dependencies)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.3

Changes:

  • correct version in package-lock.json

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.2

Changes (NPM updates):

  • @types/node
  • r2-utils-js

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.1

Changes:

  • initial NPM publish

Git revision info:

Git commit history:

Git diff:

  • initial NPM publish