Skip to content

Commit

Permalink
Merge pull request #2022 from TalaoDAO/october
Browse files Browse the repository at this point in the history
October
  • Loading branch information
bibash28 authored Oct 17, 2023
2 parents 2f3380c + ddc5ddc commit 06673a7
Show file tree
Hide file tree
Showing 50 changed files with 868 additions and 818 deletions.
10 changes: 10 additions & 0 deletions lib/app/shared/alert_message/alert_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class AlertMessage {
erroDescription = data['error_description'].toString();
}

if (erroDescription == null) {
if (data.containsKey('detail')) {
erroDescription = data['detail'].toString();
}
}

///error_uri
if (data.containsKey('error_uri')) {
errorUrl = data['error_uri'].toString();
Expand All @@ -69,6 +75,10 @@ class AlertMessage {
}
}

if (message.isEmpty) {
message = context.l10n.thisRequestIsNotSupported;
}

if (stateMessage.showDialog) {
showDialog<bool>(
context: context,
Expand Down
4 changes: 2 additions & 2 deletions lib/app/shared/constants/secure_storage_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class SecureStorageKeys {
static const String userPINCodeForAuthentication =
'userPINCodeForAuthentication';

static const String isSecurityLow = 'isSecurityLow';
static const String userPinDigitsLength = 'userPinDigitsLength';
static const String enableSecurity = 'enableSecurity';
static const String enable4DigitPINCode = 'enable4DigitPINCode';
static const String isDeveloperMode = 'isDeveloperMode';
static const String enableJWKThumbprint = 'enableJWKThumbprint';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@ enum ResponseString {
RESPONSE_STRING_credentialIssuanceDenied,
RESPONSE_STRING_thisCredentialFormatIsNotSupported,
RESPONSE_STRING_theCredentialOfferIsInvalid,
RESPONSE_STRING_theServiceIsNotAvailable,
}
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ extension ResponseStringX on ResponseString {

case ResponseString.RESPONSE_STRING_theCredentialOfferIsInvalid:
return globalMessage.RESPONSE_STRING_theCredentialOfferIsInvalid;

case ResponseString.RESPONSE_STRING_theServiceIsNotAvailable:
return globalMessage.RESPONSE_STRING_theServiceIsNotAvailable;
}
}
}
5 changes: 4 additions & 1 deletion lib/app/shared/enum/status/credential_status.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
enum CredentialStatus {
pending,
active,
notVerified,
suspended,
pending,
unknown,
expired,
revoked
}
1 change: 1 addition & 0 deletions lib/app/shared/enum/status/scan_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ enum ScanStatus {
error,
warning,
success,
goBack,
}
2 changes: 1 addition & 1 deletion lib/app/shared/enum/type/did_key_type.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
enum DidKeyType { secp256k1, p256 }
enum DidKeyType { secp256k1, p256, ebsiv3 }
26 changes: 26 additions & 0 deletions lib/app/shared/extension/credential_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ extension CredentialStatusExtension on CredentialStatus {
case CredentialStatus.active:
return l10n.cardsActive;
case CredentialStatus.suspended:
case CredentialStatus.revoked:
case CredentialStatus.expired:
case CredentialStatus.notVerified:
return l10n.cardsProblem;
case CredentialStatus.pending:
return l10n.cardsPending;
Expand All @@ -23,6 +26,9 @@ extension CredentialStatusExtension on CredentialStatus {
case CredentialStatus.active:
return Icons.check_circle;
case CredentialStatus.suspended:
case CredentialStatus.revoked:
case CredentialStatus.expired:
case CredentialStatus.notVerified:
return Icons.error_rounded;
case CredentialStatus.pending:
case CredentialStatus.unknown:
Expand All @@ -35,11 +41,31 @@ extension CredentialStatusExtension on CredentialStatus {
case CredentialStatus.active:
return Theme.of(context).colorScheme.activeColor;
case CredentialStatus.suspended:
case CredentialStatus.revoked:
case CredentialStatus.expired:
case CredentialStatus.notVerified:
return Theme.of(context).colorScheme.inactiveColor;
case CredentialStatus.pending:
return Colors.orange;
case CredentialStatus.unknown:
return Colors.blue;
}
}

String info(BuildContext context) {
final l10n = context.l10n;
switch (this) {
case CredentialStatus.notVerified:
return l10n.incorrectSignature;
case CredentialStatus.suspended:
case CredentialStatus.revoked:
return l10n.revokedOrSuspendedCredential;
case CredentialStatus.expired:
return l10n.credentialExpired;
case CredentialStatus.unknown:
case CredentialStatus.pending:
case CredentialStatus.active:
return '';
}
}
}
48 changes: 32 additions & 16 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,22 @@ Future<String> getP256PrivateKey(SecureStorageProvider secureStorage) async {
}

Future<String> fetchPrivateKey({
OIDC4VC? oidc4vc,
required SecureStorageProvider secureStorage,
required bool isEBSIV3,
required bool? isEBSIV3,
OIDC4VC? oidc4vc,
}) async {
late String privateKey;

final index = getIndexValue(isEBSIV3: true);
final didKeyType = await secureStorage.get(SecureStorageKeys.didKeyType);

if (isEBSIV3) {
if ((isEBSIV3 != null && isEBSIV3) ||
didKeyType == DidKeyType.ebsiv3.toString()) {
privateKey = await getEBSIV3P256PrivateKey(secureStorage);
} else {
final didKeyType = await secureStorage.get(SecureStorageKeys.didKeyType);
if (didKeyType == DidKeyType.secp256k1.toString()) {
if (oidc4vc == null) throw Exception();
final mnemonic = await secureStorage.get(SecureStorageKeys.ssiMnemonic);
final index = getIndexValue(isEBSIV3: true);
privateKey = await oidc4vc.privateKeyFromMnemonic(
mnemonic: mnemonic!,
indexValue: index,
Expand Down Expand Up @@ -419,13 +420,17 @@ String getUtf8Message(String maybeHex) {

Future<(String, String)> getDidAndKid({
required String privateKey,
required bool isEBSIV3,
required SecureStorageProvider secureStorage,
required bool? isEBSIV3,
DIDKitProvider? didKitProvider,
}) async {
late String did;
late String kid;

if (isEBSIV3) {
final didKeyType = await secureStorage.get(SecureStorageKeys.didKeyType);

if ((isEBSIV3 != null && isEBSIV3) ||
didKeyType == DidKeyType.ebsiv3.toString()) {
final private = jsonDecode(privateKey) as Map<String, dynamic>;

//b'\xd1\xd6\x03' in python
Expand Down Expand Up @@ -504,12 +509,8 @@ Future<OIDC4VCType?> getOIDC4VCTypeForIssuance({
final keys = <String>[];
uri.queryParameters.forEach((key, value) => keys.add(key));

late String issuer;
String? issuer;

if (keys.contains('issuer')) {
/// issuance case 1
issuer = uri.queryParameters['issuer'].toString();
}
if (keys.contains('credential_offer') ||
keys.contains('credential_offer_uri')) {
/// issuance case 2
Expand All @@ -520,7 +521,14 @@ Future<OIDC4VCType?> getOIDC4VCTypeForIssuance({
if (credentialOfferJson == null) throw Exception();

issuer = credentialOfferJson['credential_issuer'].toString();
} else {
}

if (keys.contains('issuer')) {
/// issuance case 1
issuer = uri.queryParameters['issuer'].toString();
}

if (issuer == null) {
return null;
}

Expand Down Expand Up @@ -641,7 +649,7 @@ Future<OIDC4VCType?> getOIDC4VCTypeForIssuance({
return null;
}

Future<bool> isEBSIV3ForVerifier({
Future<bool?> isEBSIV3ForVerifiers({
required Uri uri,
required DioClient client,
}) async {
Expand Down Expand Up @@ -684,7 +692,7 @@ Future<bool> isEBSIV3ForVerifier({
return false;
}
} catch (e) {
return false;
return null;
}
}

Expand Down Expand Up @@ -868,6 +876,10 @@ ResponseString getErrorResponseString(String errorString) {

case 'invalid_issuer_metadata':
return ResponseString.RESPONSE_STRING_theCredentialOfferIsInvalid;

case 'server_error':
return ResponseString.RESPONSE_STRING_theServiceIsNotAvailable;

default:
return ResponseString.RESPONSE_STRING_thisRequestIsNotSupported;
}
Expand All @@ -883,7 +895,7 @@ bool isVPTokenOnly(String responseType) {
!responseType.contains('id_token');
}

bool isIDAndVPToken(String responseType) {
bool isIDTokenAndVPToken(String responseType) {
return responseType.contains('id_token') && responseType.contains('vp_token');
}

Expand All @@ -894,3 +906,7 @@ bool hasIDToken(String responseType) {
bool hasVPToken(String responseType) {
return responseType.contains('vp_token');
}

bool hasIDTokenOrVPToken(String responseType) {
return responseType.contains('id_token') || responseType.contains('vp_token');
}
2 changes: 2 additions & 0 deletions lib/app/shared/message_handler/global_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,6 @@ class GlobalMessage {
l10n.thisCredentialFormatIsNotSupported;
String get RESPONSE_STRING_theCredentialOfferIsInvalid =>
l10n.theCredentialOfferIsInvalid;
String get RESPONSE_STRING_theServiceIsNotAvailable =>
l10n.theServiceIsNotAvailable;
}
6 changes: 6 additions & 0 deletions lib/app/shared/message_handler/response_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,12 @@ class ResponseMessage with MessageHandler {
.localise(
context,
);

case ResponseString.RESPONSE_STRING_theServiceIsNotAvailable:
return ResponseString.RESPONSE_STRING_theServiceIsNotAvailable
.localise(
context,
);
}
}
return '';
Expand Down
91 changes: 47 additions & 44 deletions lib/app/shared/widget/dialog/error_details_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,57 @@ class ErrorDetailsDialog extends StatelessWidget {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(25)),
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 25),
if (erroDescription != null) ...[
Text(
erroDescription!,
style: Theme.of(context)
.textTheme
.defaultDialogSubtitle
.copyWith(color: textColor),
textAlign: TextAlign.center,
),
],
if (erroUrl != null) ...[
const SizedBox(height: Sizes.spaceXSmall),
TransparentInkWell(
onTap: () async {
await LaunchUrl.launch(
erroUrl!,
launchMode: LaunchMode.inAppWebView,
);
},
child: Text(
l10n.moreDetails,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.markDownA,
decoration: TextDecoration.underline,
decorationColor: Theme.of(context).colorScheme.markDownA,
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 25),
if (erroDescription != null) ...[
Text(
erroDescription!,
style: Theme.of(context)
.textTheme
.defaultDialogSubtitle
.copyWith(color: textColor),
textAlign: TextAlign.center,
),
],
if (erroUrl != null) ...[
const SizedBox(height: Sizes.spaceXSmall),
TransparentInkWell(
onTap: () async {
await LaunchUrl.launch(
erroUrl!,
launchMode: LaunchMode.inAppWebView,
);
},
child: Text(
l10n.moreDetails,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.markDownA,
decoration: TextDecoration.underline,
decorationColor:
Theme.of(context).colorScheme.markDownA,
),
textAlign: TextAlign.center,
),
),
],
const SizedBox(height: 24),
MyElevatedButton(
text: l10n.ok,
verticalSpacing: 14,
backgroundColor: color,
borderRadius: Sizes.smallRadius,
fontSize: 15,
elevation: 0,
onPressed: () {
Navigator.of(context).pop(true);
},
),
const SizedBox(height: 15),
],
const SizedBox(height: 24),
MyElevatedButton(
text: l10n.ok,
verticalSpacing: 14,
backgroundColor: color,
borderRadius: Sizes.smallRadius,
fontSize: 15,
elevation: 0,
onPressed: () {
Navigator.of(context).pop(true);
},
),
const SizedBox(height: 15),
],
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ part 'wallet_connect_cubit.g.dart';
part 'wallet_connect_state.dart';

class WalletConnectCubit extends Cubit<WalletConnectState> {
WalletConnectCubit(
{required this.connectedDappRepository,
required this.secureStorageProvider,
required this.routeCubit})
: super(const WalletConnectState()) {
WalletConnectCubit({
required this.connectedDappRepository,
required this.secureStorageProvider,
required this.routeCubit,
}) : super(const WalletConnectState()) {
initialise();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/credentials/cubit/credentials_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
CredentialSubjectType.over13,
CredentialSubjectType.over15,
CredentialSubjectType.over18,
CredentialSubjectType.ageRange
CredentialSubjectType.ageRange,
];

///remove old card added by YOTI
Expand Down
Loading

0 comments on commit 06673a7

Please sign in to comment.