Skip to content

Commit

Permalink
Merge branch 'main' into ALTME
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Jan 7, 2025
2 parents c0dd612 + 4443285 commit 96a8651
Show file tree
Hide file tree
Showing 50 changed files with 1,003 additions and 548 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@ enum ResponseString {
RESPONSE_STRING_invalidClientErrorDescription,
RESPONSE_STRING_vpFormatsNotSupportedErrorDescription,
RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription,
RESPONSE_STRING_recoveryPhraseIncorrectErrorMessage,
RESPONSE_STRING_invalidCode,
}
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ extension ResponseStringX on ResponseString {
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription:
return globalMessage
.RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription;

case ResponseString.RESPONSE_STRING_recoveryPhraseIncorrectErrorMessage:
return globalMessage
.RESPONSE_STRING_recoveryPhraseIncorrectErrorMessage;

case ResponseString.RESPONSE_STRING_invalidCode:
return globalMessage.RESPONSE_STRING_invalidCode;
}
}
}
15 changes: 1 addition & 14 deletions lib/app/shared/enum/status/mnemonic_status.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@

import 'package:flutter/material.dart';

enum MnemonicStatus {
unselected,
selected,
wrongSelection,
}

extension MnemonicStatusX on MnemonicStatus {
bool get showOrder {
switch (this) {
case MnemonicStatus.unselected:
case MnemonicStatus.wrongSelection:
return false;
case MnemonicStatus.selected:
return true;
}
}

Color color(BuildContext context) {
switch (this) {
case MnemonicStatus.unselected:
return Theme.of(context).colorScheme.secondaryContainer;
case MnemonicStatus.wrongSelection:
return Theme.of(context).colorScheme.error;

case MnemonicStatus.selected:
return Theme.of(context).colorScheme.primary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ part of 'credential_subject_type.dart';

extension CredentialSubjectTypeExtension on CredentialSubjectType {
Color backgroundColor(CredentialModel credentialModel) {
final Color backgroundColor;
if (credentialModel.display?.backgroundColor != null) {
backgroundColor = Color(
int.parse(
'FF${credentialModel.display?.backgroundColor!.replaceAll('#', '')}',
radix: 16,
),
);
} else {
backgroundColor = defaultBackgroundColor;
try {
final Color backgroundColor;
if (credentialModel.display?.backgroundColor != null) {
backgroundColor = Color(
int.parse(
'FF${credentialModel.display?.backgroundColor!.replaceAll('#', '')}',
radix: 16,
),
);
} else {
backgroundColor = defaultBackgroundColor;
}
return backgroundColor;
} catch (e) {
return defaultBackgroundColor;
}
return backgroundColor;
}

Color get defaultBackgroundColor {
Expand All @@ -31,7 +35,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.selfIssued:
return const Color(0xffEFF0F6);
case CredentialSubjectType.defaultCredential:
return Colors.white;
return const Color(0xff6600FF);
case CredentialSubjectType.professionalStudentCard:
return const Color(0xffCAFFBF);
case CredentialSubjectType.kycAgeCredential:
Expand Down Expand Up @@ -88,7 +92,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.identityCredential:
case CredentialSubjectType.eudiPid:
case CredentialSubjectType.pid:
return Colors.white;
return const Color(0xff6600FF);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/app/shared/helper_functions/get_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dynamic getDisplay(dynamic value, String languageCode) {
element['locale'].toString().contains('en'),
orElse: () => displays.firstWhere(
(element) =>
element is Map<String, dynamic> && element.containsKey('locale'),
element is Map<String, dynamic> && !element.containsKey('locale'),
orElse: () => displays.firstWhere(
(element) =>
element is Map<String, dynamic>, // if local is not provided
Expand Down
34 changes: 27 additions & 7 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,10 @@ Future<String> getHost({
).host;
} else {
/// verification case
final clientId = uri.queryParameters['client_id'];
final clientId = getClientIdForPresentation(
uri.queryParameters['client_id'],
);

if (clientId != null) {
return clientId;
Expand Down Expand Up @@ -1349,6 +1352,7 @@ ResponseString getErrorResponseString(String errorString) {
return ResponseString.RESPONSE_STRING_theWalletIsNotRegistered;

case 'invalid_grant':
return ResponseString.RESPONSE_STRING_invalidCode;
case 'invalid_token':
return ResponseString.RESPONSE_STRING_credentialIssuanceDenied;

Expand Down Expand Up @@ -1503,14 +1507,14 @@ Future<dynamic> fetchRequestUriPayload({
String getUpdatedUrlForSIOPV2OIC4VP({
required Uri uri,
required Map<String, dynamic> response,
required String clientId,
}) {
final responseType = response['response_type'];
final redirectUri = response['redirect_uri'];
final scope = response['scope'];
final responseUri = response['response_uri'];
final responseMode = response['response_mode'];
final nonce = response['nonce'];
final clientId = response['client_id'];
final claims = response['claims'];
final stateValue = response['state'];
final presentationDefinition = response['presentation_definition'];
Expand All @@ -1525,7 +1529,7 @@ String getUpdatedUrlForSIOPV2OIC4VP({
queryJson['scope'] = scope;
}

if (!uri.queryParameters.containsKey('client_id') && clientId != null) {
if (!uri.queryParameters.containsKey('client_id')) {
queryJson['client_id'] = clientId;
}

Expand Down Expand Up @@ -1752,7 +1756,7 @@ Future<(String?, String?, String?, String?, String?)> getClientDetails({
(Display display) => display.locale.toString().contains('en'),
) ??
credSupportedDisplay.firstWhereOrNull(
(Display display) => display.locale != null,
(Display display) => display.locale == null,
) ??
credSupportedDisplay.first; // if local is not provided
}
Expand Down Expand Up @@ -1787,7 +1791,8 @@ Future<(String?, String?, String?, String?, String?)> getClientDetails({
) ??
displays.firstWhereOrNull(
(Display display) => display.locale != null,
);
) ??
displays.first; // if local is not provided
}
}
}
Expand All @@ -1804,8 +1809,9 @@ Future<(String?, String?, String?, String?, String?)> getClientDetails({
(Display display) => display.locale.toString().contains('en'),
) ??
displays.firstWhereOrNull(
(Display display) => display.locale != null,
);
(Display display) => display.locale == null,
) ??
displays.first; // if local is not provided;
}
return (display, credentialSupported);
}
Expand Down Expand Up @@ -2425,3 +2431,17 @@ bool isContract(String reciever) {
if (reciever.startsWith('KT1')) return true;
return false;
}

String? getClientIdForPresentation(String? clientId) {
if (clientId == null) return '';
if (clientId.contains(':')) {
final parts = clientId.split(':');
if (parts.length == 2) {
return parts[1];
} else {
return clientId;
}
} else {
return clientId;
}
}
5 changes: 5 additions & 0 deletions lib/app/shared/message_handler/global_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,9 @@ class GlobalMessage {

String get RESPONSE_STRING_invalidPresentationDefinitionUriErrorDescription =>
l10n.invalidPresentationDefinitionUriErrorDescription;

String get RESPONSE_STRING_recoveryPhraseIncorrectErrorMessage =>
l10n.recoveryPhraseIncorrectErrorMessage;

String get RESPONSE_STRING_invalidCode => l10n.invalidCode;
}
11 changes: 11 additions & 0 deletions lib/app/shared/message_handler/response_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,17 @@ class ResponseMessage with MessageHandler {
.localise(
context,
);

case ResponseString.RESPONSE_STRING_recoveryPhraseIncorrectErrorMessage:
return ResponseString
.RESPONSE_STRING_recoveryPhraseIncorrectErrorMessage.localise(
context,
);

case ResponseString.RESPONSE_STRING_invalidCode:
return ResponseString.RESPONSE_STRING_invalidCode.localise(
context,
);
}
}
return '';
Expand Down
8 changes: 3 additions & 5 deletions lib/app/shared/widget/phrase_word.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ import 'package:flutter/material.dart';
class PhraseWord extends StatelessWidget {
const PhraseWord({
super.key,
required this.order,
this.order,
required this.word,
this.color,
this.showOrder = true,
this.onTap,
});

final int order;
final int? order;
final String word;
final Color? color;
final bool showOrder;
final void Function()? onTap;

@override
Expand All @@ -40,7 +38,7 @@ class PhraseWord extends StatelessWidget {
height: 25,
child: Center(
child: MyText(
showOrder ? '$order. $word' : word,
order == null ? word : '$order. $word',
textAlign: TextAlign.center,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:altme/l10n/l10n.dart';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:package_info_plus/package_info_plus.dart';

class AboutAltmeMenu extends StatelessWidget {
const AboutAltmeMenu({super.key});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class Oidc4vcSettingMenuView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SecurityLevelWidget(),
const DidKeyTypeWidget(),
const DraftTypeWidget(),
const KeyIdentifierAndKeyTypeWidget(),
const OIDC4VCDraftTypeWidget(),
const OIDC4VPDraftTypeWidget(),
const CryptographicHolderBindingWidget(),
const ScopeParameterWidget(),
const ClientAuthenticationWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ClientTypeWidget extends StatelessWidget {
return BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return OptionContainer(
title: 'Wallet Client_id Scheme',
title: 'OIDC4VCI client_id value',
body: ListView.builder(
itemCount: ClientType.values.length,
shrinkWrap: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:oidc4vc/oidc4vc.dart';

class DidKeyTypeWidget extends StatelessWidget {
const DidKeyTypeWidget({super.key});
class KeyIdentifierAndKeyTypeWidget extends StatelessWidget {
const KeyIdentifierAndKeyTypeWidget({super.key});

@override
Widget build(BuildContext context) {
return BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return OptionContainer(
title: 'Default DID',
subtitle: 'Select one of the DIDs',
title: 'Key identifier and key type',
subtitle: 'Select jwk thumbprint or a DID method',
body: ListView.builder(
itemCount: DidKeyType.values.length,
shrinkWrap: true,
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,68 @@
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.draft10 ||
draftType == OIDC4VPDraftType.draft13 ||
draftType == OIDC4VPDraftType.draft18 ||
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(),
],
);
},
),
);
},
);
}
}
Loading

0 comments on commit 96a8651

Please sign in to comment.