Skip to content

Commit

Permalink
refactor: Organising codes
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Aug 15, 2023
1 parent 63fb34a commit b029b20
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 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 @@ -289,7 +289,29 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
} else if (state.uri.toString().startsWith('openid://?') ||
state.uri.toString().startsWith('openid-vc://?')) {
/// verifier side (siopv2 oidc4vc) with request_uri
await launchOIDC4VPAndSiopV2RequestAsURIFlow(state.uri);
final OIDC4VCType currentOIIDC4VCType =
profileCubit.state.model.oidc4vcType;

if (!state.uri
.toString()
.startsWith(currentOIIDC4VCType.presentationPrefix)) {
emit(
state.error(
message: StateMessage.error(
messageHandler: ResponseMessage(
ResponseString
.RESPONSE_STRING_pleaseSwitchToCorrectOIDC4VCProfile,
),
showDialog: false,
duration: const Duration(seconds: 20),
),
),
);
return;
}

await launchOIDC4VPAndSiopV2RequestAsURIFlow();
} else {
emit(state.acceptHost(isRequestVerified: true));
}
Expand Down Expand Up @@ -572,27 +594,7 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
}
}

Future<void> launchOIDC4VPAndSiopV2RequestAsURIFlow(Uri? uri) async {
final OIDC4VCType currentOIIDC4VCType =
profileCubit.state.model.oidc4vcType;

if (!state.uri
.toString()
.startsWith(currentOIIDC4VCType.presentationPrefix)) {
emit(
state.error(
message: StateMessage.error(
messageHandler: ResponseMessage(
ResponseString
.RESPONSE_STRING_pleaseSwitchToCorrectOIDC4VCProfile,
),
showDialog: false,
duration: const Duration(seconds: 20),
),
),
);
return;
}
Future<void> launchOIDC4VPAndSiopV2RequestAsURIFlow() async {
final requestUri = state.uri!.queryParameters['request_uri'].toString();

encodedData = await fetchRequestUriPayload(url: requestUri);
Expand Down

0 comments on commit b029b20

Please sign in to comment.