Skip to content

About

Mirador 4 plugin for visualizing physicochemical analysis data

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Mirador XY Viewer

CI codecov npm version License Mirador IIIF

A Mirador 4 plugin for visualizing physicochemical analysis data in IIIF format. Developed by the Centre de Recherche sur la Conservation (CRC) for museum and heritage applications requiring spectral data visualization (XRF, Raman, FTIR, UV-Vis, etc.).

  • Document physicochemical analyses on artworks or heritage objects
  • Associate spectral data (XRF, Raman, FTIR, UV-Vis) with specific regions of high-resolution images
  • Need to visually compare different imaging modalities (visible light, UV, IR, X-ray)
  • Publish their analysis data following IIIF standards

Features

  • IIIF v2 & v3 Annotations: Reads both IIIF Presentation API 2.0/2.1 (sc:AnnotationList) and 3.0 (AnnotationPage) annotation lists — v2 is normalized internally to v3, so all features below work identically for either version
  • Spectrum Visualization: Load and display CSV/TSV spectral data with Plotly
  • Manifest Links: Open related IIIF manifests in new windows
  • Image Comparison: Side-by-side comparison with synchronized zoom/pan
  • Point Annotations: Automatic conversion of analysis points to visible markers
  • Metadata Filters: Filter annotations by metadata values
  • Selection Highlight: Pulse animation to locate selected annotations on the image (technique, date, operator, etc.)

IIIF API compatibility

The plugin reads its data from Mirador's store and only post-processes annotation responses, so it composes cleanly with the rest of the IIIF stack:

IIIF API Status Notes
Presentation 2.x / 3.0 ✅ Full v2 (sc:AnnotationList) is normalized internally to v3
Image 2.x / 3.0 ✅ Full Served by Mirador/OpenSeadragon; the plugin never calls it directly
Content Search 1.0 / 2.0 ✅ Untouched The annotation post-processor is gated to annotation responses only — search hits/pagination are preserved. See Enabling IIIF Content Search for setup and caveats.
Authorization Flow 1.0 / 2.0 ⚠️ Opt-in Manifest/image auth is handled by Mirador. Access-controlled datasets need configureDatasetRequests
Content State 1.0 ✅ No conflict Handled by Mirador; the plugin does not interfere
Change Discovery 1.0 — Out of scope Server-side discovery; not a viewer concern

Protected datasets (IIIF Auth)

Dataset/spectrum files are fetched by the plugin itself. By default the request uses credentials: 'omit' and no auth headers (the safe, CORS-friendly default for open data). To fetch access-controlled datasets, register a request provider once at setup — cookie- or token-based:

import { configureDatasetRequests } from 'mirador-xyviewer';

// Same-origin cookie auth:
configureDatasetRequests(() => ({ credentials: 'include' }));

// Bearer token (e.g. resolved from your auth store):
configureDatasetRequests((url) => {
  const token = selectTokenForUrl(url);
  return token ? { headers: { Authorization: `Bearer ${token}` } } : undefined;
});

Cross-origin requests with credentials: 'include' additionally require the server to send Access-Control-Allow-Credentials: true and an explicit Access-Control-Allow-Origin. See the IIIF Annotations guide for details.

Reusing Mirador's IIIF Auth session (recommended)

Full guide: docs/IIIF-AUTH.md — trust model, cross-origin, API, troubleshooting.

If your protected datasets live on the same origin as protected images, you don't need to plumb tokens by hand. Mirador 4 already runs the IIIF Auth 1.0 flow for images; wireMiradorDatasetAuth reuses that stored token so a single login unlocks images and same-host datasets — no second sign-in.

import { wireMiradorDatasetAuth } from 'mirador-xyviewer/mirador-auth';

const { store } = Mirador.viewer(config, [scientificAnnotationPlugin]);

// Once at setup. trustedOrigins is OPTIONAL — omit it for the host-driven default (reuse a
// token only on its own issuing origin), or pass an allowlist to enable cross-origin / cookies.
wireMiradorDatasetAuth(store, { trustedOrigins: ['https://data.lab.example'] }); // optional

This registers a configureDatasetRequests provider that attaches the matching Mirador token as Authorization: Bearer … on dataset fetches. The lower-level configureDatasetRequests above remains available as an escape hatch (e.g. a non-Mirador auth store); wireMiradorDatasetAuth takes exclusive ownership of that slot, so use one or the other.

For split content/auth domains — content on one host, the IIIF auth/token service on another (e.g. spectra on data.lab, login on auth.museum) — trust both origins:

wireMiradorDatasetAuth(store, {
  trustedOrigins: ['https://data.lab.example', 'https://auth.example'],
});

Trust model. trustedOrigins is optional: omit it for the host-driven default (a token is reused only for the exact origin that issued it), pass an allowlist to enable cross-origin reuse / cookies, or pass [] as a deny-all kill-switch. A token is attached only when (a) the origin is permitted by that mode, (b) the transport is https (plaintext http refused except loopback), and (c) a Mirador token service is matched — either the one the resource declares in its IIIF auth service (spec-correct, works cross-origin when both origins are trusted), or any token service sharing the content origin (host-inheritance; avoid on multi-tenant hosts).

A second layer — an SSRF blocklist — refuses non-public hosts (private/reserved/loopback/ link-local IPs, internal names like localhost/.internal) before any credential or login. Loopback is blocked by default, so for local dev opt in with blocklist: { allow: ['loopback', 'localhost'] }.

Split content/auth domains — including two subdomains of one institution (content on manuspectrum.mnhn.fr, SSO on sso.mnhn.fr) — need both origins trusted: the content origin to permit the fetch, and the declared token-service origin to permit reusing that token (an anti-exfiltration gate). A subdomain host itself is never blocked, and the strict default is fail-safe — it never leaks a token; at worst a cross-subdomain dataset needs the second origin listed. If only the content origin is trusted, the declared path is skipped and the dataset falls back to the protected-record notice.

Starting a login (image-less / cross-host datasets)

wireMiradorDatasetAuth also registers a sign-in handler, so the "Sign in" button on a protected dataset starts the IIIF Auth 1.0 flow when the resource declares its auth service — including datasets with no image on the same host. It opens the access window, retrieves the token into Mirador's store, and the panel auto-retries. Resources that declare no auth service — or whose declared origin isn't the resource's own (host-driven) / isn't trusted (explicit mode) — fall back to the manual "Open resource" → "Try again" path.

The login window opens directly from your click, so popup blockers allow it. A login is only driven to a secure, non-internal auth/token origin that is either explicitly trusted or — host-driven — the resource's own origin (same gate as token reuse), and the token service's reply is origin-checked. Pass loginDriver to override the built-in flow (e.g. in tests). See the IIIF Auth integration guide for the trust model, cross-origin setup, API reference, and troubleshooting.

Quick Start

npm install mirador mirador-xyviewer plotly.js react-plotly.js
import Mirador from 'mirador';
import {
  scientificAnnotationPlugin,
  imageComparisonPlugin,
  metadataFiltersPlugin,
  selectionHighlightPlugin,
  annotationPostprocessor
} from 'mirador-xyviewer';

Mirador.viewer({
  id: 'mirador-container',
  windows: [{ manifestId: 'https://example.org/manifest.json' }],
  annotations: {
    filteredMotivations: [
      'oa:commenting', 'oa:tagging', 'sc:painting',
      'commenting', 'tagging', 'supplementing'
    ],
  },
  requests: {
    postprocessors: [annotationPostprocessor],
  },
}, [
  scientificAnnotationPlugin,   // Spectrum visualization, manifest links
  imageComparisonPlugin,        // Image comparison (optional)
  metadataFiltersPlugin,        // Metadata filters (optional)
  selectionHighlightPlugin      // Selection highlight pulse (optional)
]);

Documentation

Guide Description
IIIF Annotations How to structure annotations for physicochemical data
Spectral Data Format CSV/TSV format specification
Mirador Configuration Full configuration options
Metadata Filters Filter annotations by metadata
Developer Guide Architecture and extension

Demo

Note: The local demo data is currently unavailable as the database has not been deployed yet. The demo manifest references external IIIF resources that require the backend infrastructure to be set up.

For this demonstration, we are using the ManuSpectrum application, built on the Arches platform. Please note that ManuSpectrum is still under development and has not yet been deployed.

npm run dev:demo

Development

npm install          # Install dependencies
npm run dev:demo     # Start dev server
npm run build        # Build for production
npm run typecheck    # Type checking
npm run lint         # Lint

License

Apache License 2.0 - see LICENSE

Author

Maxime Humeau - Centre de Recherche sur la Conservation (CRC)

Related Projects

About

Mirador 4 plugin for visualizing physicochemical analysis data

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages