Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions minimal/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<html>
<head>
<meta http-equiv="content-security-policy" content="frame-src 'none'">
</head>
<body>
<h1>Host Page</h1>

<h2>Credential Display</h2>
<iframe id="renderer" sandbox="allow-scripts allow-modals" srcdoc=""></iframe>

<script>
// the *partial* verifiable credential filtered by `renderProperty`
const credential = {
'@context': [
'https://www.w3.org/ns/credentials/v2',
'https://www.w3.org/ns/credentials/examples/v2'
],
type: ['VerifiableCredential', 'NameCredential'],
issuer: {
id: 'did:example:1234',
name: 'The Issuer',
},
credentialSubject: {
name: 'Example Name',
}
};

// template value extracted from the original VC
const template = `
<div>
<style>
body { font-family: Arial, sans-serif; }
h1 { color: darkblue; }
</style>

<h1 id="credentialSubject-name"></h1>
<p>Issued by: <span id="issuer-name"></span></p>

<script>
console.log('running template render script');

// display credential as JSON as an example renderer; anything
// could be done here instead, including mustache/other-style
// template processing to generate the HTML for display
const credential = JSON.parse(document.querySelector(
'head > script[name="credential"]').innerHTML);

document.querySelector('#credentialSubject-name').innerText =
credential.credentialSubject.name;
document.querySelector('#issuer-name').innerText =
credential.issuer.name;
<\/script>
</div>
`;

// Setup the iframe shim code--required for security sandboxing
renderer.srcdoc = `
<html>
<head>
<meta http-equiv="content-security-policy" content="default-src 'none' data: 'unsafe-inline'">
<script name="credential" type="application/vc">${JSON.stringify(credential)}<\/script>
</head>
<body>${template}</body>
</html>
`;
</script>
</body>
</html>