w3c-ccg / vc-render-method

Rendering methods for Verifiable Credentials
https://w3c-ccg.github.io/vc-render-method/
Other
2 stars 2 forks source link

`renderMethod` data modeling #1

Open davidlehn opened 1 year ago

davidlehn commented 1 year ago

The current (2023-04-28) example looks like this:

  "renderMethod": [{
    "id": "https://example.edu/credentials/BachelorDegree.svg",
    "type": "SvgRenderingTemplate2023",
    "name": "Portrait Mode",
    "css3MediaQuery": "@media (orientation: portrait)",
    "digestMultibase": "zQmAPdhyxzznFCwYxAp2dRerWC85Wg6wFl9G270iEu5h6JqW"
  }]

I think the data modeling here needs some work.

I'd propose a few things:

I'm not sure what the vision is here how the user agents will work. Some issues:

With the above, and some extra methods just to show the concept:

  "renderMethod": [{
    "type": "SvgTemplateRenderMethod2023",
    "name": "Graphical Display",
    "contentType": "image/svg+xml",
    "css3MediaQuery": "@media (orientation: portrait)",
    "svgTemplate": {
      "href": "https://example.edu/credentials/BachelorDegree.svg",
      "digestMultibase": "zxSVGdhyxzznFCwYxAp2dRerWC85Wg6wFl9G270iEu5h6JqW"
    }
  }, {
    "type": "HtmlTemplateRenderMethod2023",
    "name": "HTML Display",
    "contentType": "text/html",
    "htmlTemplate": {
      "href": "https://example.edu/credentials/BachelorDegree.html",
      "digestMultibase": "zxHTMLhyxzznFCwYxAp2dRerWC85Wg6wFl9G270iEu5h6JqW"
    }
  }, {
    "type": "WebComponentRenderMethod2023",
    "name": "Web Component Display",
    "contentType": "text/html",
    "htmlTemplate": {
      "href": "https://example.edu/credentials/BachelorDegree.html",
      "digestMultibase": "zxWCPdhyxzznFCwYxAp2dRerWC85Wg6wFl9G270iEu5h6JqW"
    }
  }, {
    "type": "PlainTextRenderMethod2023",
    "name": "Plain Text Display",
    "contentType": "text/plain",
    "textTemplate": {
      "href": "https://example.edu/credentials/BachelorDegree.txt",
      "digestMultibase": "zxplainyxzznFCwYxAp2dRerWC85Wg6wFl9G270iEu5h6JqW"
    }
  }]

If you moved that off to another URL it might collapse to a cachable static file so the VC only as a reference:

  "renderMethod": "https://example.edu/credentials/BachelorDegreeRenderMethod20230428.json"
lemoustachiste commented 5 months ago

Hi,

I just wanted to share what we do with Blockcerts as we've been doing a visual layer since the inception (before VCs where VCs).

From the beginning, the display property as it's called (displayHtml in the earlier versions) was only a HTML string (with inline CSS and base64 encoded images).

In our V3 we have opened support for more than just HTML and we can render images (gif, jpeg, png, bmp) and pdf documents, provided those binary files are base64 encoded).

The property schema is consultable here https://github.com/blockchain-certificates/cert-schema/blob/master/cert_schema/3.1/displaySchema.json

but basically we have:

{
  ... // VC root
  display: {
    content: "<p>Hello World</p>",
    contentMediaType: "text/html",
  }
}

or with a binary file:

{
  ... // VC root
  display: {
    "contentMediaType": "image/png",
    "contentEncoding": "base64",
    "content": "iVBORw0KGgoAAAANSUhEUg..."
  }
}

Then we have a renderer web component which builds the HTML as needed depending on the media type: https://github.com/blockchain-certificates/blockcerts-verifier/blob/master/src/selectors/certificate.ts#L193

I generally agree with the proposal, I like how encapsulated it can be and I like the distant hosting with a digest (I think it is easier than using hashlinks).

However I believe it should allow for self contained data, at the expense of having larger credentials but with the added benefits: