Skip to content

Commit

Permalink
feat: handle presentation_definition_uri in the url #1846
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Aug 29, 2023
1 parent 109b288 commit 38acd7c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
final clientId = response['client_id'];
final claims = response['claims'];
final presentationDefinition = response['presentation_definition'];
final presentationDefinitionUri =
response['presentation_definition_uri'];

final queryJson = <String, dynamic>{};
if (redirectUri != null) {
Expand All @@ -307,6 +309,11 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
jsonEncode(presentationDefinition).replaceAll('"', "'");
}

if (presentationDefinitionUri != null) {
queryJson['presentation_definition_uri'] =
presentationDefinitionUri;
}

final String queryString = Uri(queryParameters: queryJson).query;

final String newUrl = '${state.uri!}&$queryString';
Expand Down Expand Up @@ -625,6 +632,17 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
as Map<String, dynamic>;

presentationDefinition = PresentationDefinition.fromJson(json);
} else if (keys.contains('presentation_definition_uri')) {
final presentationDefinitionUri = state
.uri!.queryParameters['presentation_definition_uri']
.toString();
final dynamic response = await client.get(presentationDefinitionUri);

final Map<String, dynamic> data = response == String
? jsonDecode(response.toString()) as Map<String, dynamic>
: response as Map<String, dynamic>;

presentationDefinition = PresentationDefinition.fromJson(data);
} else {
throw Exception();
}
Expand Down

0 comments on commit 38acd7c

Please sign in to comment.