Skip to content

Commit

Permalink
feat: Add switch for OIDC4VP #3159
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Dec 19, 2024
1 parent 40a61b2 commit dcf01f4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Oidc4vcSettingMenuView extends StatelessWidget {
children: <Widget>[
const SecurityLevelWidget(),
const KeyIdentifierAndKeyTypeWidget(),
const DraftTypeWidget(),
const OIDC4VCDraftTypeWidget(),
const OIDC4VPDraftTypeWidget(),
const CryptographicHolderBindingWidget(),
const ScopeParameterWidget(),
const ClientAuthenticationWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ProfileCubit, ProfileState>(
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<ProfileCubit>().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(),
],
);
},
),
);
},
);
}
}
3 changes: 2 additions & 1 deletion lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ class ProfileCubit extends Cubit<ProfileState> {
bool? secureSecurityAuthenticationWithPinCode,
bool? verifySecurityIssuerWebsiteIdentity,
OIDC4VCIDraftType? oidc4vciDraftType,
OIDC4VPDraftType? oidc4vpDraftType,
ClientType? clientType,
VCFormatType? vcFormatType,
List<VCFormatType>? formatsSupported,
Expand Down Expand Up @@ -472,6 +473,7 @@ class ProfileCubit extends Cubit<ProfileState> {
clientId: clientId,
clientSecret: clientSecret,
oidc4vciDraft: oidc4vciDraftType,
oidc4vpDraft: oidc4vpDraftType,
clientType: clientType,
vcFormatType: vcFormatType,
proofType: proofType,
Expand Down
2 changes: 1 addition & 1 deletion lib/dashboard/profile/models/profile_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lib/dashboard/profile/models/profile_setting.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions packages/oidc4vc/lib/src/oidc4vp_draft_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ enum OIDC4VPDraftType {
draft18,
@JsonValue('20')
draft20,
@JsonValue('21')
draft21,
@JsonValue('22')
draft22,
@JsonValue('23')
draft23,
}

extension OIDC4VPDraftTypeX on OIDC4VPDraftType {
Expand All @@ -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';
}
}
}

0 comments on commit dcf01f4

Please sign in to comment.