@nypl/web-reader 4.3.1 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -15
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -51,7 +51,6 @@ const ReaderPage = ({ manifestUrl }) => {
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
- [More React examples](/example/index.tsx) - Includes examples that render EPUB2 & EPUB3 based webpubs, remote hosted webpubs, and PDFs
|
|
54
|
-
- [Encrypted example](/example/axisnow-encrypted.tsx) - How to pass an content decryptor to the web-reader to render encrypted content
|
|
55
54
|
- [usePDFReader hook example](/example/use-pdf-reader.tsx) - Useful for instances when you know you're only going to be using the web-reader to open PDFs
|
|
56
55
|
- [useHTMLReader hook example](/example/use-html-reader.tsx) - Useful for cases when you know you're only going to be using the web-reader to read EPUBs
|
|
57
56
|
- [Real-world example: Open eBooks Web](https://github.com/NYPL/ereading-clients/blob/staging/apps/oew/src/components/theme-ui/WebReader.tsx) - NYPL application for children to read books on the web. This demonstrates how encrypted AxisNow content is passed to the web-reader.
|
|
@@ -255,16 +254,6 @@ The web reader does support DRM via two possible routes:
|
|
|
255
254
|
1. The default Readium suggested method is to have a server-side "streamer" between the content server and the application. This server would fetch the encrypted DRM content, decrypt it, and then serve the decrypted assets individually to the client alongside a webpub manifest pointing to these decrypted assets. One example of such a streamer is [readium/r2-streamer-js](https://github.com/readium/r2-streamer-js).
|
|
256
255
|
1. If decryption cannot be performed in a streamer, the web-reader can support client-side decryption of licensed content. This is done by passing a `getContent` function to either the `<WebReader>` component or the `useWebReader` hook. It has the type signature `(resourceUrl: string) => Promise<string>`, and can thus be used to fetch and decrypt (or otherwise manipulate) content before it is passed to the iframe for rendering.
|
|
257
256
|
|
|
258
|
-
The `AxisNow Encrypted EPUB` example shows how this is done using the private NYPL AxisNow decryptor. The AxisNow scheme is a specific DRM technique not publicly available and the repo and code for the decryptor cannot be shared. Thus this example will not work for the public, but you can read the example code to see how we use the private `Decryptor` package to:
|
|
259
|
-
|
|
260
|
-
- Create a Web Worker using [Comlink](https://github.com/GoogleChromeLabs/comlink) that will perform the fetching and decryption. This should help keep the main thread free while those heavy tasks are performed.
|
|
261
|
-
- Fetch content from the network
|
|
262
|
-
- Decrypt the HTML content
|
|
263
|
-
- Search for embedded CSS and image assets
|
|
264
|
-
- Fetch those assets and decrypt them
|
|
265
|
-
- Re-embed the decrypted CSS and image assets as Object URLs into the decrypted HTML document
|
|
266
|
-
- Return the HTML string with fully decrypted reources for the web-reader to render in the iframe
|
|
267
|
-
|
|
268
257
|
## Getting Started
|
|
269
258
|
|
|
270
259
|
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [Publishing to NPM](#publishing-to-npm) for notes on how to publish a new version to NPM.
|
|
@@ -273,8 +262,6 @@ These instructions will get you a copy of the project up and running on your loc
|
|
|
273
262
|
|
|
274
263
|
1. Before getting started, be sure to run `npm install`.
|
|
275
264
|
|
|
276
|
-
If you are internal to NYPL you can be added to the private `@nypl-simplified-packages/axisnow-access-control-web` package, which is required in order to open the AxisNow Encrypted EPUB example. If you decide to install this package, you'll also need to generate a Personal Access Token in GitHub with `read` permissions and run `GH_PACKAGE_AUTH_TOKEN=<your-token-here> npm install`.
|
|
277
|
-
|
|
278
265
|
2. In order to open any of the PDF examples in the Example App, you'll need to allow urls in a `WebpubManifest` to be proxied. This is done by passing a `proxyUrl` to the `<WebReader>` component. In order to do that, you must have a proxy running somewhere.
|
|
279
266
|
|
|
280
267
|
We have set up a small express-based CORS proxy that can be run for local development.
|
|
@@ -283,8 +270,6 @@ We have set up a small express-based CORS proxy that can be run for local develo
|
|
|
283
270
|
- Pass the proxy url to the example app by setting the following env var in a `.env` file at the root of the project: `CORS_PROXY_URL="http://localhost:3001/?requestUrl="`.
|
|
284
271
|
- In a separate terminal session, start the example app: `npm run example`.
|
|
285
272
|
|
|
286
|
-
3. In order to open the AxisNow Encrypted EPUB example (`/html/axisnow-encrypted`), you will need to have `process.env.VAULT_UUID` and `process.env.ISBN` set in your `.env` file. Read [example/README.txt](/example/README.txt) for more info.
|
|
287
|
-
|
|
288
273
|
### Running the Example App
|
|
289
274
|
|
|
290
275
|
To run the example app for local development:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nypl/web-reader",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "https://github.com/NYPL-Simplified/web-reader",
|
|
6
6
|
"homepage": "https://github.com/NYPL-Simplified/web-reader",
|
|
@@ -133,9 +133,6 @@
|
|
|
133
133
|
"react-pdf": "^5.3.2",
|
|
134
134
|
"react-resize-observer": "^1.1.1"
|
|
135
135
|
},
|
|
136
|
-
"optionalDependencies": {
|
|
137
|
-
"@nypl-simplified-packages/axisnow-access-control-web": "^1.4.2"
|
|
138
|
-
},
|
|
139
136
|
"lint-staged": {
|
|
140
137
|
"*.{ts,tsx,js,jsx}": "eslint --cache --fix",
|
|
141
138
|
"*.{ts,tsx,js,json,css,md}": "prettier --write --ignore-path .eslintignore"
|