<html>
<head>
<title>FedCM MDocs Test Page</title>
</head>
<script>
async function request(fields) {
const mdoc = await navigator.identity.get({
digital: {
providers: [{
protocol: "openid4vp",
request: JSON.stringify({
presentation_definition: {
id: "mDL-request-demo",
input_descriptors: [{
id: "org.iso.18013.5.1.mDL",
constraints: {
fields: fields
}
}]
}
})
}]
}
});
const token = mdoc.data;
document.getElementById("log").textContent += `${token}`;
}
async function requestAgeOnly() {
const fields = [{
path: [
"$['org.iso.18013.5.1']['age_over_21']"
]
}];
request(fields);
}
async function requestAgeAndName() {
const fields = [{
path: [
"$['org.iso.18013.5.1']['age_over_21']"
]
}, {
path: [
"$['org.iso.18013.5.1']['given_name']"
]
}];
request(fields);
}
</script>
<body>
<button id="request_age_only_button" onclick="requestAgeOnly()">Request Age Only</button>
<button id="request_age_and_name_button" onclick="requestAgeAndName()">Request Age and Name</button>
<textarea id="log"></textarea>
</body>
</html>