Skip to content

Commit

Permalink
Merge pull request #3227 from TalaoDAO/OIDC4VCI-refactor
Browse files Browse the repository at this point in the history
Oidc4 vci refactor
  • Loading branch information
hawkbee1 authored Jan 7, 2025
2 parents 22be525 + 9a6e29a commit 4443285
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 62 deletions.
62 changes: 1 addition & 61 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -773,67 +773,7 @@ Future<
}
}

String? authorizationServer;
if (oidc4vciDraftType == OIDC4VCIDraftType.draft13 ||
oidc4vciDraftType == OIDC4VCIDraftType.draft14) {
/// TODO: code mutualisation. Following logic is duplicate from readAuthorizationEndpoint in oidc4VC package
/// Extract the authorization endpoint from from first element of
/// authorization_servers in opentIdConfiguration.authorizationServers
final listOpenIDConfiguration =
openIdConfiguration.authorizationServers ?? [];

// check if authorization server is present in the credential offer
final authorizationServerFromCredentialOffer = OIDC4VC()
.getAuthorizationServerFromCredentialOffer(credentialOfferJson);
// if authorization server is present in the credential offer
// we check if it is present in the authorization servers
// from credential issuer metadata
// https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-issuer-metadata-p
if (authorizationServerFromCredentialOffer != null) {
if (listOpenIDConfiguration
.contains(authorizationServerFromCredentialOffer)) {
authorizationServer = authorizationServerFromCredentialOffer;
} else {
// that's forbidden and we can't continue the process
throw Exception('AUTHORIZATION_SERVER_NOT_FOUND');
}
}

if (listOpenIDConfiguration.isNotEmpty && authorizationServer == null) {
if (listOpenIDConfiguration.length == 1) {
authorizationServer = listOpenIDConfiguration.first;
} else {
try {
/// Extract the authorization endpoint from from
/// authorization_server in credentialOfferJson
final jsonPathCredentialOffer = JsonPath(
// ignore: lines_longer_than_80_chars
r'$..["urn:ietf:params:oauth:grant-type:pre-authorized_code"].authorization_server',
);
final data = jsonPathCredentialOffer
.read(credentialOfferJson)
.first
.value! as String;
if (listOpenIDConfiguration.contains(data)) {
authorizationServer = data;
}
} catch (e) {
final jsonPathCredentialOffer = JsonPath(
r'$..authorization_code.authorization_server',
);
final data = jsonPathCredentialOffer
.read(credentialOfferJson)
.first
.value! as String;
if (data.isNotEmpty && listOpenIDConfiguration.contains(data)) {
authorizationServer = data;
}
}
}
}
}
authorizationServer ??= openIdConfiguration.authorizationServer;
final authorizationServer = openIdConfiguration.authorizationServer;

Map<String, dynamic>? authorizationServerConfigurationData;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: altme
description: AltMe Flutter App

version: 2.19.3+5597
version: 2.19.4+5598

publish_to: "none" # Remove this line if you wish to publish to pub.dev
environment:
Expand Down

0 comments on commit 4443285

Please sign in to comment.