From dcf01f4cd6edd9b5ea7a4eb08f7ae40d82d477bd Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Thu, 19 Dec 2024 16:26:06 +0545 Subject: [PATCH] feat: Add switch for OIDC4VP #3159 --- .../view/oidc4vc_settings_menu.dart | 3 +- ...et.dart => oidc4vc_draft_type_widget.dart} | 4 +- .../widget/oidc4vp_draft_type_widget.dart | 65 +++++++++++++++++++ .../ssi/oidc4vc_settngs/widget/widget.dart | 3 +- .../profile/cubit/profile_cubit.dart | 2 + .../profile/models/profile_setting.dart | 2 +- .../profile/models/profile_setting.g.dart | 3 + .../oidc4vc/lib/src/oidc4vp_draft_type.dart | 12 ++++ 8 files changed, 89 insertions(+), 5 deletions(-) rename lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/{draft_type_widget.dart => oidc4vc_draft_type_widget.dart} (95%) create mode 100644 lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vp_draft_type_widget.dart diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart index bdb9295b9..056d5edd7 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart @@ -37,7 +37,8 @@ class Oidc4vcSettingMenuView extends StatelessWidget { children: [ const SecurityLevelWidget(), const KeyIdentifierAndKeyTypeWidget(), - const DraftTypeWidget(), + const OIDC4VCDraftTypeWidget(), + const OIDC4VPDraftTypeWidget(), const CryptographicHolderBindingWidget(), const ScopeParameterWidget(), const ClientAuthenticationWidget(), diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vc_draft_type_widget.dart similarity index 95% rename from lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart rename to lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vc_draft_type_widget.dart index 349ed25ae..3e512e9d8 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vc_draft_type_widget.dart @@ -5,8 +5,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; -class DraftTypeWidget extends StatelessWidget { - const DraftTypeWidget({super.key}); +class OIDC4VCDraftTypeWidget extends StatelessWidget { + const OIDC4VCDraftTypeWidget({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vp_draft_type_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vp_draft_type_widget.dart new file mode 100644 index 000000000..692988f2c --- /dev/null +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/oidc4vp_draft_type_widget.dart @@ -0,0 +1,65 @@ +import 'package:altme/app/app.dart'; +import 'package:altme/app/shared/widget/divider_for_radio_list.dart'; +import 'package:altme/dashboard/dashboard.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:oidc4vc/oidc4vc.dart'; + +class OIDC4VPDraftTypeWidget extends StatelessWidget { + const OIDC4VPDraftTypeWidget({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return OptionContainer( + title: 'OIDC4VP', + subtitle: 'Protocole standard release', + body: ListView.builder( + itemCount: OIDC4VPDraftType.values.length, + shrinkWrap: true, + physics: const ScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, index) { + final draftType = OIDC4VPDraftType.values[index]; + + if (draftType == OIDC4VPDraftType.draft23) return Container(); + + return Column( + children: [ + ListTile( + onTap: () { + context.read().updateProfileSetting( + oidc4vpDraftType: draftType, + ); + }, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Theme.of(context).colorScheme.onSurface, + width: 0.5, + ), + ), + title: Text( + draftType.formattedString, + style: Theme.of(context).textTheme.bodyLarge, + ), + trailing: Icon( + state.model.profileSetting.selfSovereignIdentityOptions + .customOidc4vcProfile.oidc4vpDraft == + draftType + ? Icons.radio_button_checked + : Icons.radio_button_unchecked, + size: Sizes.icon2x, + color: Theme.of(context).colorScheme.primary, + ), + ), + const DividerForRadioList(), + ], + ); + }, + ), + ); + }, + ); + } +} diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/widget.dart index 3e9eee7ef..fd4c7aab4 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/widget.dart @@ -3,7 +3,8 @@ export 'client_type_widget.dart'; export 'cryptograhic_holder_binding.dart'; export 'did_key_type_widget.dart'; export 'dpop_support_widget.dart'; -export 'draft_type_widget.dart'; +export 'oidc4vc_draft_type_widget.dart'; +export 'oidc4vp_draft_type_widget.dart'; export 'option_container.dart'; export 'pre_registered_widget.dart'; export 'proof_header_widget.dart'; diff --git a/lib/dashboard/profile/cubit/profile_cubit.dart b/lib/dashboard/profile/cubit/profile_cubit.dart index 81ee1d0bf..15c0fe97f 100644 --- a/lib/dashboard/profile/cubit/profile_cubit.dart +++ b/lib/dashboard/profile/cubit/profile_cubit.dart @@ -433,6 +433,7 @@ class ProfileCubit extends Cubit { bool? secureSecurityAuthenticationWithPinCode, bool? verifySecurityIssuerWebsiteIdentity, OIDC4VCIDraftType? oidc4vciDraftType, + OIDC4VPDraftType? oidc4vpDraftType, ClientType? clientType, VCFormatType? vcFormatType, List? formatsSupported, @@ -472,6 +473,7 @@ class ProfileCubit extends Cubit { clientId: clientId, clientSecret: clientSecret, oidc4vciDraft: oidc4vciDraftType, + oidc4vpDraft: oidc4vpDraftType, clientType: clientType, vcFormatType: vcFormatType, proofType: proofType, diff --git a/lib/dashboard/profile/models/profile_setting.dart b/lib/dashboard/profile/models/profile_setting.dart index 6b8c7021e..03836334f 100644 --- a/lib/dashboard/profile/models/profile_setting.dart +++ b/lib/dashboard/profile/models/profile_setting.dart @@ -718,7 +718,7 @@ class CustomOidc4VcProfile extends Equatable { cryptoHolderBinding: true, defaultDid: DidKeyType.edDSA, oidc4vciDraft: OIDC4VCIDraftType.draft13, - oidc4vpDraft: OIDC4VPDraftType.draft18, + oidc4vpDraft: OIDC4VPDraftType.draft21, scope: false, securityLevel: false, siopv2Draft: SIOPV2DraftType.draft12, diff --git a/lib/dashboard/profile/models/profile_setting.g.dart b/lib/dashboard/profile/models/profile_setting.g.dart index cc2d8dff3..185f46866 100644 --- a/lib/dashboard/profile/models/profile_setting.g.dart +++ b/lib/dashboard/profile/models/profile_setting.g.dart @@ -326,6 +326,9 @@ const _$OIDC4VPDraftTypeEnumMap = { OIDC4VPDraftType.draft13: '13', OIDC4VPDraftType.draft18: '18', OIDC4VPDraftType.draft20: '20', + OIDC4VPDraftType.draft21: '21', + OIDC4VPDraftType.draft22: '22', + OIDC4VPDraftType.draft23: '23', }; const _$SIOPV2DraftTypeEnumMap = { diff --git a/packages/oidc4vc/lib/src/oidc4vp_draft_type.dart b/packages/oidc4vc/lib/src/oidc4vp_draft_type.dart index a5e6aab65..3c3e9eba3 100644 --- a/packages/oidc4vc/lib/src/oidc4vp_draft_type.dart +++ b/packages/oidc4vc/lib/src/oidc4vp_draft_type.dart @@ -9,6 +9,12 @@ enum OIDC4VPDraftType { draft18, @JsonValue('20') draft20, + @JsonValue('21') + draft21, + @JsonValue('22') + draft22, + @JsonValue('23') + draft23, } extension OIDC4VPDraftTypeX on OIDC4VPDraftType { @@ -22,6 +28,12 @@ extension OIDC4VPDraftTypeX on OIDC4VPDraftType { return 'Draft 18'; case OIDC4VPDraftType.draft20: return 'Draft 20'; + case OIDC4VPDraftType.draft21: + return 'Draft 21'; + case OIDC4VPDraftType.draft22: + return 'Draft 22 (Partial)'; + case OIDC4VPDraftType.draft23: + return 'Draft 23'; } } }