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
90 changes: 72 additions & 18 deletions pages/mdl-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ const mdlProofRequest = {
limit_disclosure: 'required',
fields: [
{
path: ["$['org.iso.18013.5.1']['given_name']", 'given_name'],
intent_to_retain: false,
},
{
path: ["$['org.iso.18013.5.1']['age_over_18']", 'age_over_18'],
path: ["$['org.iso.18013.5.1']['family_name']", 'family_name'],
intent_to_retain: false,
},
],
Expand All @@ -44,10 +40,7 @@ const mdlProofRequest = {
},
};

const mdlDCQLQueryClaims = [
{ path: ['org.iso.18013.5.1', 'age_over_18'] },
{ path: ['org.iso.18013.5.1', 'given_name'] },
];
const mdlDCQLQueryClaims = [{ path: ['org.iso.18013.5.1', 'family_name'] }];

function OID4VPProofRequest({
title,
Expand Down Expand Up @@ -83,30 +76,89 @@ function OID4VPProofRequest({
});

async function handleCredsRequest() {
const REQUESTED_CRED_ID = 'cred1';
const REQUESTED_MDL_CRED_ID = 'mdl-request';
const REQUESTED_ID_PASS_CRED_ID = 'id_pass-request';

const credsApiRequest = {
protocol: 'openid4vp-v1-unsigned',
protocol: 'openid4vp',
request: {
response_type: 'vp_token',
nonce: proofRequest.nonce,
presentation_definition: proofRequest.request,
// presentation_definition: proofRequest.request,
client_metadata: {
client_id: 'bank-demo.truvera.io',
client_id_scheme: 'web-origin',
vp_formats_supported: {
mso_mdoc: { deviceauth_alg_values: [-7], issuerauth_alg_values: [-7] },
},
// vp_formats_supported: {
// mso_mdoc: { deviceauth_alg_values: [-7], issuerauth_alg_values: [-7] },
// },
},
dcql_query: {
credentials: [
{
claims: dcqlQueryClaims,
claims: [
{
path: [
'org.iso.18013.5.1',
'family_name'
],
intent_to_retain: false // set this to true if you are saving the value of the field
},
{
path: [
'org.iso.18013.5.1',
'given_name'
],
intent_to_retain: false
},
{
path: [
'org.iso.18013.5.1',
'age_over_18'
],
intent_to_retain: false
}
],
format: 'mso_mdoc',
id: REQUESTED_CRED_ID,
id: REQUESTED_MDL_CRED_ID,
meta: { doctype_value: 'org.iso.18013.5.1.mDL' },
},
{
claims: [
{
path: [
'org.iso.18013.5.1',
'family_name'
],
intent_to_retain: false // set this to true if you are saving the value of the field
},
{
path: [
'org.iso.18013.5.1',
'given_name'
],
intent_to_retain: false
},
{
path: [
'org.iso.18013.5.1',
'age_over_18'
],
intent_to_retain: false
}
],
format: 'mso_mdoc',
id: REQUESTED_ID_PASS_CRED_ID,
meta: { doctype_value: 'com.google.wallet.idcard.1' },
},
],
credential_sets: [
{
options: [
[REQUESTED_MDL_CRED_ID],
[REQUESTED_ID_PASS_CRED_ID]
]
}
]
},
response_mode: 'dc_api',
},
Expand Down Expand Up @@ -134,10 +186,12 @@ function OID4VPProofRequest({
if (credentialResponse.constructor.name === 'DigitalCredential') {
const data = credentialResponse.data;
const protocol = credentialResponse.protocol;
const vp_token =
data.vp_token[REQUESTED_MDL_CRED_ID] || data.vp_token[REQUESTED_ID_PASS_CRED_ID];
responseForServer = {
protocol,
data: {
vp_token: data.vp_token[REQUESTED_CRED_ID][0],
vp_token,
},
state: credsApiRequest.state,
};
Expand Down
Loading