Repository navigation
feat: add iiif-image and public-fetch packages - #986
Merged
Merged
Conversation
- Add @lde/iiif-image: find a manifest’s first painted image service in Presentation 2 or 3, and read info.json into version, level, limits and sizes - Add @lde/public-fetch: fetch URLs from other people’s data without reaching internal addresses, checking every redirect and bounding the body read - Document both on the docs site and list them in the package tables
- Refuse manifest URLs and redirect targets that are not public addresses - Read at most 20 MiB of a manifest body BREAKING CHANGE: ManifestValidationReason gains refused-url and too-large, so code that handles every reason must handle these two.
- iiif-image: replace firstImageService and hasCanvases with an imageServices iterator that throws for a document it cannot read as a manifest - iiif-image: give each size the URL of its JPEG rendition, replacing imageUrl, and drop version, level, server limits and size sources from ImageService - public-fetch: bound the body of the Response fetchPublic returns, replacing readJson, and read nothing until the caller does - public-fetch: stop exporting isPublicWebUrl, the option and limit constants, and the fields on its errors - iiif-validator: read manifests with response.json()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the protocol-generic half of netwerk-digitaal-erfgoed/stack#55 into LDE, so that
@ndes/iiif-imageskeeps only its SCHEMA-AP-NDE binding.@lde/iiif-imageimageServices(manifest): the image service URL of each painted image, in Presentation 2 or 3, in painting order. Destructure the first for a cover image. It walks the plain JSON, so a manifest with"annotations": [null]– which Deventit Atlantis writes and normalising parsers reject – still yields its services. It throws for a document without canvases, such as an error page served as JSON, because a caller that stores results must not record that as “no image”.readImageService(url, info): aninfo.jsonas{ url, width, height, sizes }, where each size carries the URL of its JPEG rendition in the canonical form of the service’s Image API version.Tested against four real manifests: Gouda Tijdmachine, Limb, LDmaX and FEHAC.
@lde/public-fetchfetchPublic(url, options)isfetchfor URLs from someone else’s data, run from inside a private network:http(s)URLs, every address that is not public unicast (including the IPv6 forms that carry an IPv4 address), single-label hosts and.localhost,.local,.internaland.svcnames, with or without a trailing dot;fetchdoes;Responsewhose body fails past 20 MiB, whateverContent-Lengthsays, and is not read until the caller reads it.It does not limit request rates: that stays with
@lde/host-limiterand@lde/resolver.@lde/iiif-validator(breaking)It now fetches through
@lde/public-fetch, soManifestValidationReasongainsrefused-urlandtoo-large.Not in this PR
distribution-probehas its own byte-limited body reader. Moving it ontofetchPublicis a separate change.ndeiiif.adlibhosting.comlists 83 for 1335 ÷ 16, which rounding gives and rounding up would not.After merging
@lde/iiif-imageand@lde/public-fetchare new on npm, so each needs the manual first publish before the release workflow can take over.