
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@iiif/parser
Advanced tools
npm i @iiif/parser
This is a parser and set of low-level utilities for the following IIIF Specifications:
These include:
[!NOTE] A new version of the IIIF Presentation API is being developed (v4) which handles 3D content. This parser will support this version soon. You can read about the additions here
The features of this library are focussed on encoding the structure of all types of IIIF and providing utilities for extracting data from the IIIF or converting it into another format that is easier to develop with. The aim of the parser is to maximize the IIIF compatibility of other tools built on top of it.
import { Traverse } from '@iiif/parser';
// Or for presentation 2 resources
// import { Traverse } from '@iiif/parser/presentation-2';
const ids = [];
const extractCanvasLabels = new Traverse({
canvas: [(canvas) => {
ids.push(canvas.id); // string
}],
});
extractCanvasLabels.traverseUnknown(loadSomeManifest());
console.log(ids); // all canvas ids.
The intention for IIIF Presentation 2 is to upgrade it to 3 and then work with that. The tooling will always offer and upgrade to the latest version and tools on top of that.
import { Traverse, convertPresentation2 } from '@iiif/parser/presentation-2';
convertPresentation2(p2); // to latest IIIF version
const logAnnotations = new Traverse({
// Every type is a key on this record, with an array of functions to call
annotation: [
anno => {
console.log(anno['@id']);
// Optionally return to replace the resource.
}
]
});
logAnnotations.traverseManifest(someInputManifest); // Logs all annotation IDs.
// Also an "all" traversal.
const logAllIds = Traverse.all(resource => console.log(resource['@id']));
logAllIds.traverseUnknown(someInput);
The available types to traverse (v3) are:
export type TraversalMap = {
collection?: Array<Traversal<Collection>>;
manifest?: Array<Traversal<Manifest>>;
canvas?: Array<Traversal<Canvas>>;
annotationCollection?: Array<Traversal<AnnotationCollection>>;
annotationPage?: Array<Traversal<AnnotationPage>>;
annotation?: Array<Traversal<Annotation>>;
contentResource?: Array<Traversal<ContentResource>>;
choice?: Array<Traversal<ChoiceTarget | ChoiceBody>>;
range?: Array<Traversal<Range>>;
service?: Array<Traversal<Service>>;
agent?: Array<Traversal<ResourceProvider>>;
specificResource?: Array<Traversal<SpecificResource>>;
geoJson?: Array<Traversal<import('geojson').GeoJSON>>;
};
The Image 3 parser is adapted from an Image Server implementation, and supports:
isLevel0(service)
supports(service, { extraQualities: ['grey'] })
helper which accepts a service and partial service to compareimageServiceSupportsRequest()
helper that can validate IIIF image requests before you make themregion
, size
, quality
etc. and then creating a IIIF Image request URL.canonicalServiceUrl()
, getId()
, getType()
and isImageService()
for compatibility and validationimport { parseImageServiceRequest, imageServiceRequestInfo } from '@iiif/parser/image-3';
import { ImageService } from '@iiif/presentation-3';
const parsed = parseImageServiceRequest(
'https://munch.emuseum.com/apis/iiif/image/v2/17261/full/max/0/default.jpg',
// Optionally provide a path, so the identifier can be extracted
'apis/iiif/image/v2'
);
// {
// "format": "jpg",
// "identifier": "17261",
// "originalPath": "/17261/full/max/0/default.jpg",
// "prefix": "apis/iiif/image/v2",
// "quality": "default",
// "region": {
// "full": true,
// },
// "rotation": {
// "angle": 0,
// },
// "scheme": "https",
// "server": "munch.emuseum.com",
// "size": {
// "confined": false,
// "max": true,
// "serialiseAsFull": false,
// "upscaled": false,
// },
// "type": "image",
// }
// Can be changed.
parsed.rotation.angle = 90;
const imageUrl = imageServiceRequestToString(parsed);
// https://munch.emuseum.com/apis/iiif/image/v2/17261/full/max/90/default.jpg
const infoJson = imageServiceRequestInfo(parsed);
// https://munch.emuseum.com/apis/iiif/image/v2/17261/info.json
const imageService: ImageService = await fetch(infoJson).then(r => r.json());
// Likely true - as its supported by level0, level1 and level2
const supportsSizes = supports(imageService, {
extraFeatures: ['sizeByWhListed']
});
Upgrades IIIF JSON to the latest IIIF Presentation version (current: 3).
import { upgrade } from '@iiif/parser/upgrader';
upgrade(presentation2Manifest); // Presentation 3 Manifest or Collection
FAQs
IIIF Presentation 2 and 3 parsing utilities
The npm package @iiif/parser receives a total of 1,125 weekly downloads. As such, @iiif/parser popularity was classified as popular.
We found that @iiif/parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.