Source: ViewEdit

Pin one variant from an app

When your app already knows which publisher and mark it wants to display, pin that exact variant directly. You fetch straight from the publisher’s manifest—there is no catalog in the middle, and no need to traverse includes for related products.

Pin during a build step

Create a pin.json file that records the publisher’s origin, the document URL, the role and colorway you want, the variant id and tag, and the expected lowercase hex sha256 digest:

{
  "origin": "https://ada.example",
  "document": "https://ada.example/.well-known/identity.json",
  "role": "mark",
  "colorway": "full",
  "variant": "mark",
  "tag": "1",
  "sha256": "<64 lowercase hex characters>"
}

From a local checkout of dev-centr/identity, run the reference CLI:

node reference/cli.mjs --pin pin.json --out build

The identity-pin CLI fetches the JSON manifest over HTTPS, resolves the pinned variant, downloads the asset, and rejects the response if the SHA-256 digest does not match. It never reads the publisher’s HTML. Even if the HTTP request redirects to another origin, your pin retains the original origin and document URL, and the downloaded bytes still must match sha256.

Resolve and verify at runtime

Websites, desktop apps, and backend services use the same resolution logic through the reference resolver (@dev-centr/identity, located in reference/ inside the repository and not yet published to npm):

import { resolveTyped, sha256Hex } from "@dev-centr/identity";

const doc = await fetch(pin.document).then((res) => res.json());
const resolved = resolveTyped(doc, {
  role: pin.role,
  colorway: pin.colorway,
  variantId: pin.variant,
  tag: pin.tag,
  sha256: pin.sha256,
  origin: pin.origin,
  document: pin.document,
});

resolved.variants is scoped to the single slot you selected, so letting a user switch between alternates stays within that role and colorway. resolved.pin returns the normalized pin record (origin, document, variant, tag, and sha256).

Always verify the downloaded file bytes with sha256Hex before rendering or caching them. Mobile apps follow the exact same pin contract, though generated mobile bindings are out of scope for this repository—they are intended to come from a separate converter built against the spec and schema.

For the full fallback and validation algorithm, see Identity document.