Skip to content

Commit

Permalink
feat: Show par data to be sent #3054
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Nov 6, 2024
1 parent f998a84 commit bfaad87
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
emit(state.loading());
final scope = customOidc4vcProfile.scope;

await getAuthorizationUriForIssuer(
final authorizationUri = await getAuthorizationUriForIssuer(
scannedResponse: state.uri.toString(),
oidc4vc: oidc4vc,
isEBSI: isEBSI,
Expand All @@ -1338,7 +1338,13 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
walletIssuer: Parameters.walletIssuer,
useOAuthAuthorizationServerLink:
useOauthServerAuthEndPoint(profileCubit.state.model),
profileCubit: profileCubit,
qrCodeScanCubit: qrCodeScanCubit,
);

if (authorizationUri == null) return;

await LaunchUrl.launchUri(authorizationUri);
goBack();
}
} catch (e) {
Expand Down
27 changes: 23 additions & 4 deletions lib/oidc4vc/get_authorization_uri_for_issuer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import 'dart:convert';

import 'package:altme/app/app.dart';
import 'package:altme/app/shared/shared.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';

import 'package:did_kit/did_kit.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:oidc4vc/oidc4vc.dart';
import 'package:uuid/uuid.dart';

Future<void> getAuthorizationUriForIssuer({
Future<Uri?> getAuthorizationUriForIssuer({
required String scannedResponse,
required OIDC4VC oidc4vc,
required bool isEBSI,
Expand All @@ -23,13 +24,15 @@ Future<void> getAuthorizationUriForIssuer({
required ClientAuthentication clientAuthentication,
required OIDC4VCIDraftType oidc4vciDraftType,
required VCFormatType vcFormatType,
String? oAuthClientAttestation,
String? oAuthClientAttestationPop,
required bool secureAuthorizedFlow,
required DioClient client,
required ProfileType profileType,
required String walletIssuer,
required bool useOAuthAuthorizationServerLink,
required ProfileCubit profileCubit,
required QRCodeScanCubit qrCodeScanCubit,
String? oAuthClientAttestation,
String? oAuthClientAttestationPop,
}) async {
/// this is first phase flow for authorization_code
Expand Down Expand Up @@ -129,6 +132,22 @@ Future<void> getAuthorizationUriForIssuer({
final parUrl = openIdConfiguration.pushedAuthorizationRequestEndpoint ??
'$authorizationEndpoint/par';

if (profileCubit.state.model.isDeveloperMode) {
final value = await qrCodeScanCubit.showDataBeforeSending(
title: 'Pushed Authorization Request Data',
data: authorizationRequestParemeters,
);

if (value) {
qrCodeScanCubit.completer = null;
} else {
qrCodeScanCubit.completer = null;
qrCodeScanCubit.resetNonceAndAccessTokenAndAuthorizationDetails();
qrCodeScanCubit.goBack();
return null;
}
}

/// error we shuld get it from
final response = await client.post(
parUrl,
Expand Down Expand Up @@ -157,5 +176,5 @@ Future<void> getAuthorizationUriForIssuer({
Uri.https(url.authority, url.path, authorizationRequestParemeters);
}

await LaunchUrl.launchUri(authorizationUri);
return authorizationUri;
}

0 comments on commit bfaad87

Please sign in to comment.