Skip to content

Commit

Permalink
feat: Add all type of VCs #2779
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jul 15, 2024
1 parent 39f032a commit 9160f58
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 36 deletions.
31 changes: 20 additions & 11 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,13 @@ List<String> getStringCredentialsForToken({
}
}

if (vcFormatType == VCFormatType.auto) {
presentLdpVc = true;
presentJwtVc = true;
presentJwtVcJson = true;
presentVcSdJwt = true;
}

if (!presentLdpVc && !presentJwtVc && !presentJwtVcJson && !presentVcSdJwt) {
throw ResponseMessage(
data: {
Expand Down Expand Up @@ -1891,17 +1898,19 @@ List<String> getStringCredentialsForToken({
presentVcSdJwt = true;
}

if ((presentLdpVc && vcFormatType != VCFormatType.ldpVc) ||
(presentJwtVc && vcFormatType != VCFormatType.jwtVc) ||
presentJwtVcJson && vcFormatType != VCFormatType.jwtVcJson ||
presentVcSdJwt && vcFormatType != VCFormatType.vcSdJWT) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Please switch to profile that supports format '
'${supportingFormats.join('/')}.',
},
);
if (vcFormatType != VCFormatType.auto) {
if ((presentLdpVc && vcFormatType != VCFormatType.ldpVc) ||
(presentJwtVc && vcFormatType != VCFormatType.jwtVc) ||
presentJwtVcJson && vcFormatType != VCFormatType.jwtVcJson ||
presentVcSdJwt && vcFormatType != VCFormatType.vcSdJWT) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Please switch to profile that supports format '
'${supportingFormats.join('/')}.',
},
);
}
}

return (presentLdpVc, presentJwtVc, presentJwtVcJson, presentVcSdJwt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class VCFormatWidget extends StatelessWidget {
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
final vcFormatType = VCFormatType.values[index];

if (vcFormatType == VCFormatType.auto) {
return Container();
}

return Column(
children: [
ListTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class HomeCredentialCategoryList extends StatelessWidget {
}
}

if (customOidc4vcProfile.vcFormatType.vcValue ==
VCFormatType.auto.vcValue) {
return true;
}

/// do not load the credential if vc format is different
if (customOidc4vcProfile.vcFormatType.vcValue !=
element.getFormat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,33 @@ List<CredentialModel> filterCredenialListByFormat({
vcFormatType: vcFormatType,
);

credentials.removeWhere(
(CredentialModel credentialModel) {
/// remove ldpVc
if (presentLdpVc) {
return credentialModel.getFormat != VCFormatType.ldpVc.vcValue;
}

/// remove jwtVc
if (presentJwtVc) {
return credentialModel.getFormat != VCFormatType.jwtVc.vcValue;
}

/// remove JwtVcJson
if (presentJwtVcJson) {
return credentialModel.getFormat != VCFormatType.jwtVcJson.vcValue;
}

/// remove vcSdJwt
if (presentVcSdJwt) {
return credentialModel.getFormat != VCFormatType.vcSdJWT.vcValue;
}

return false;
},
);
if (vcFormatType != VCFormatType.auto) {
credentials.removeWhere(
(CredentialModel credentialModel) {
/// remove ldpVc
if (presentLdpVc) {
return credentialModel.getFormat != VCFormatType.ldpVc.vcValue;
}

/// remove jwtVc
if (presentJwtVc) {
return credentialModel.getFormat != VCFormatType.jwtVc.vcValue;
}

/// remove JwtVcJson
if (presentJwtVcJson) {
return credentialModel.getFormat != VCFormatType.jwtVcJson.vcValue;
}

/// remove vcSdJwt
if (presentVcSdJwt) {
return credentialModel.getFormat != VCFormatType.vcSdJWT.vcValue;
}

return false;
},
);
}
}
return credentials;
}

0 comments on commit 9160f58

Please sign in to comment.